Skip to content

Commit

Permalink
Merge branch 'git/configure-debug-broker-support' of https://github.c…
Browse files Browse the repository at this point in the history
  • Loading branch information
gitaumoses4 committed Feb 15, 2022
2 parents 0f7ee88 + 8694b36 commit 800f1b1
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ public final class TokenCacheItemSerializationAdapater
implements JsonDeserializer<ADALTokenCacheItem>, JsonSerializer<ADALTokenCacheItem> {

private static final String TAG = TokenCacheItemSerializationAdapater.class.getSimpleName();

@Override
public JsonElement serialize(final ADALTokenCacheItem tokenCacheItem,
final Type type,
final JsonSerializationContext context) {
final JsonSerializationContext context)
throws JsonParseException {
throwIfParameterNull(tokenCacheItem.getAuthority(), OAuth2.AUTHORITY);
throwIfParameterNull(tokenCacheItem.getRefreshToken(), OAuth2.REFRESH_TOKEN);
throwIfParameterNull(tokenCacheItem.getRawIdToken(), OAuth2.ID_TOKEN);
throwIfParameterNull(tokenCacheItem.getFamilyClientId(), OAuth2.ADAL_CLIENT_FAMILY_ID);
JsonObject jsonObj = new JsonObject();
jsonObj.add(OAuth2.AUTHORITY, new JsonPrimitive(tokenCacheItem.getAuthority()));
jsonObj.add(OAuth2.REFRESH_TOKEN, new JsonPrimitive(tokenCacheItem.getRefreshToken()));
Expand Down Expand Up @@ -84,4 +89,10 @@ private void throwIfParameterMissing(JsonObject json, String name) {
throw new JsonParseException(TAG + "Attribute " + name + " is missing for deserialization.");
}
}
}

private void throwIfParameterNull(String parameter, String name) {
if (null == parameter) {
throw new JsonParseException(TAG + "Attribute " + name + " is null for serialization.");
}
}
}

0 comments on commit 800f1b1

Please sign in to comment.