diff --git a/.classpath b/.classpath index 6be21badf..9cdeb0e94 100644 --- a/.classpath +++ b/.classpath @@ -4,11 +4,11 @@ - - + + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 45ba36f2a..688e39a7e 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,11 +4,11 @@ - - + + diff --git a/src/main/java/org/mitre/jwt/model/ClaimSet.java b/src/main/java/org/mitre/jwt/model/ClaimSet.java index 9107afea7..badd967da 100644 --- a/src/main/java/org/mitre/jwt/model/ClaimSet.java +++ b/src/main/java/org/mitre/jwt/model/ClaimSet.java @@ -8,8 +8,16 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +/** + * Generic container for JSON-based claims. Backed with a {@link Map} that preserves + * insertion order. Several convenience methods for getting and setting claims in different + * formats. + * @author jricher + * + */ public class ClaimSet { + // the LinkedHashMap preserves insertion order private Map claims = new LinkedHashMap(); /** @@ -85,9 +93,16 @@ public class ClaimSet { public JsonObject getAsJsonObject() { JsonObject o = new JsonObject(); + + /* + * We step through the claims object and serialize the internal values as + * appropriate to JsonElements. + */ + if (this.claims != null) { for (Map.Entry claim : this.claims.entrySet()) { if (claim.getValue() instanceof JsonElement) { + // raw JSON elements get passed through directly o.add(claim.getKey(), (JsonElement)claim.getValue()); } else if (claim.getValue() instanceof String) { o.addProperty(claim.getKey(), (String)claim.getValue());