From a3771177a169e824f53b0b21f59c2f91e8a779f0 Mon Sep 17 00:00:00 2001 From: Amanda Anganes Date: Mon, 29 Apr 2013 11:17:36 -0400 Subject: [PATCH] Updated json serialization of approved site objects --- .../connect/view/JsonApprovedSiteView.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/JsonApprovedSiteView.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/JsonApprovedSiteView.java index ebeeb8961..14a957a45 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/JsonApprovedSiteView.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/JsonApprovedSiteView.java @@ -5,6 +5,7 @@ package org.mitre.openid.connect.view; import java.io.IOException; import java.io.Writer; +import java.lang.reflect.Type; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -22,6 +23,10 @@ import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; /** * @author jricher @@ -37,13 +42,6 @@ public class JsonApprovedSiteView extends AbstractView { public boolean shouldSkipField(FieldAttributes f) { - if (f.getDeclaringClass() == OAuth2AccessTokenEntity.class) { - if (f.getName().equals("id")) { - return false; - } - return true; - } - return false; } @@ -55,6 +53,15 @@ public class JsonApprovedSiteView extends AbstractView { return false; } + }) + .registerTypeAdapter(OAuth2AccessTokenEntity.class, new JsonSerializer() { + + @Override + public JsonElement serialize(OAuth2AccessTokenEntity src, + Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.getId()); + } + }) .serializeNulls() .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")