added azp, addresses #247

pull/263/head
Justin Richer 2013-01-18 18:09:32 -05:00
parent 8831bc64a2
commit e4284353e8
1 changed files with 11 additions and 37 deletions

View File

@ -38,8 +38,8 @@ import com.google.gson.JsonParser;
public class IdTokenClaims extends JwtClaims { public class IdTokenClaims extends JwtClaims {
public static final String AUTHENTICATION_CONTEXT_CLASS_REFERENCE = "acr"; public static final String AUTHENTICATION_CONTEXT_CLASS_REFERENCE = "acr";
public static final String NONCE = "nonce";
public static final String AUTH_TIME = "auth_time"; public static final String AUTH_TIME = "auth_time";
public static final String AUTHORIZED_PARTY = "azp";
private Long id; private Long id;
@ -85,15 +85,6 @@ public class IdTokenClaims extends JwtClaims {
setClaim(AUTHENTICATION_CONTEXT_CLASS_REFERENCE, acr); setClaim(AUTHENTICATION_CONTEXT_CLASS_REFERENCE, acr);
} }
@Transient
public String getNonce() {
return getClaimAsString(NONCE);
}
public void setNonce(String nonce) {
setClaim(NONCE, nonce);
}
@Transient @Transient
public Date getAuthTime() { public Date getAuthTime() {
return getClaimAsDate(AUTH_TIME); return getClaimAsDate(AUTH_TIME);
@ -103,33 +94,16 @@ public class IdTokenClaims extends JwtClaims {
setClaim(AUTH_TIME, authTime); setClaim(AUTH_TIME, authTime);
} }
@Transient
/** public String getAuthorizedParty() {
* Get the seraialized form of this claim set return getClaimAsString(AUTHORIZED_PARTY);
*/
@Basic
public String getSerializedForm() {
// TODO Auto-generated method stub
JsonObject o = super.getAsJsonObject();
return o.toString();
} }
/** public void setAuthorizedParty(String azp) {
* Set up the claims in this object from the serialized form. This clears all current claims from the object. setClaim(AUTHORIZED_PARTY, azp);
* @param s a JSON Object string to load into this object
* @throws IllegalArgumentException if s is not a valid JSON object string
*/
public void setSerializedForm(String s) {
JsonParser parser = new JsonParser();
JsonElement json = parser.parse(s);
if (json != null && json.isJsonObject()) {
loadFromJsonObject(json.getAsJsonObject());
} else {
throw new IllegalArgumentException("Could not parse: " + s);
}
} }
/** /**
* Load this IdToken from a JSON Object * Load this IdToken from a JSON Object
*/ */
@ -142,10 +116,10 @@ public class IdTokenClaims extends JwtClaims {
pass.add(element.getKey(), element.getValue()); pass.add(element.getKey(), element.getValue());
} else if (element.getKey().equals(AUTHENTICATION_CONTEXT_CLASS_REFERENCE)) { } else if (element.getKey().equals(AUTHENTICATION_CONTEXT_CLASS_REFERENCE)) {
setAuthContext(element.getValue().getAsString()); setAuthContext(element.getValue().getAsString());
} else if (element.getKey().equals(NONCE)) {
setNonce(element.getValue().getAsString());
} else if (element.getKey().equals(AUTH_TIME)) { } else if (element.getKey().equals(AUTH_TIME)) {
setAuthTime(new Date(element.getValue().getAsLong() * 1000L)); setAuthTime(new Date(element.getValue().getAsLong() * 1000L));
} else if (element.getKey().equals(AUTHORIZED_PARTY)) {
setAuthorizedParty(element.getValue().getAsString());
} else { } else {
pass.add(element.getKey(), element.getValue()); pass.add(element.getKey(), element.getValue());
} }