Skip to content

Commit

Permalink
fix other claims in IDToken
Browse files Browse the repository at this point in the history
  • Loading branch information
patriot1burke committed Mar 5, 2015
1 parent 453ef80 commit 98831ec
Show file tree
Hide file tree
Showing 15 changed files with 692 additions and 403 deletions.
@@ -0,0 +1,76 @@
package org.keycloak.representations;

import org.codehaus.jackson.annotate.JsonProperty;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class AddressClaimSet {
@JsonProperty("formatted")
protected String formattedAddress;

@JsonProperty("street_address")
protected String streetAddress;

@JsonProperty("locality")
protected String locality;

@JsonProperty("region")
protected String region;

@JsonProperty("postal_code")
protected String postalCode;

@JsonProperty("country")
protected String country;

public String getFormattedAddress() {
return this.formattedAddress;
}

public void setFormattedAddress(String formattedAddress) {
this.formattedAddress = formattedAddress;
}

public String getStreetAddress() {
return this.streetAddress;
}

public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}

public String getLocality() {
return this.locality;
}

public void setLocality(String locality) {
this.locality = locality;
}

public String getRegion() {
return this.region;
}

public void setRegion(String region) {
this.region = region;
}

public String getPostalCode() {
return this.postalCode;
}

public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}

public String getCountry() {
return this.country;
}

public void setCountry(String country) {
this.country = country;
}

}
235 changes: 221 additions & 14 deletions core/src/main/java/org/keycloak/representations/IDToken.java
Expand Up @@ -13,15 +13,73 @@
* @version $Revision: 1 $ * @version $Revision: 1 $
*/ */
public class IDToken extends JsonWebToken { public class IDToken extends JsonWebToken {

// NOTE!!! WE used to use @JsonUnwrapped on a UserClaimSet object. This screws up otherClaims and the won't work
// anymore. So don't have any @JsonUnwrapped!
@JsonProperty("nonce") @JsonProperty("nonce")
protected String nonce; protected String nonce;


@JsonProperty("session_state") @JsonProperty("session_state")
protected String sessionState; protected String sessionState;


@JsonUnwrapped @JsonProperty("name")
protected UserClaimSet userClaimSet = new UserClaimSet(); protected String name;

@JsonProperty("given_name")
protected String givenName;

@JsonProperty("family_name")
protected String familyName;

@JsonProperty("middle_name")
protected String middleName;

@JsonProperty("nickname")
protected String nickName;

@JsonProperty("preferred_username")
protected String preferredUsername;

@JsonProperty("profile")
protected String profile;

@JsonProperty("picture")
protected String picture;

@JsonProperty("website")
protected String website;

@JsonProperty("email")
protected String email;

@JsonProperty("email_verified")
protected Boolean emailVerified;

@JsonProperty("gender")
protected String gender;

@JsonProperty("birthdate")
protected String birthdate;

@JsonProperty("zoneinfo")
protected String zoneinfo;

@JsonProperty("locale")
protected String locale;

@JsonProperty("phone_number")
protected String phoneNumber;

@JsonProperty("phone_number_verified")
protected Boolean phoneNumberVerified;

@JsonProperty("address")
protected AddressClaimSet address;

@JsonProperty("updated_at")
protected Long updatedAt;

@JsonProperty("claims_locales")
protected String claimsLocales;


protected Map<String, Object> otherClaims = new HashMap<String, Object>(); protected Map<String, Object> otherClaims = new HashMap<String, Object>();


Expand All @@ -41,17 +99,166 @@ public void setSessionState(String sessionState) {
this.sessionState = sessionState; this.sessionState = sessionState;
} }


/**
* Standardized OpenID Connect claims
* public String getName() {
* @return return this.name;
*/ }
public UserClaimSet getUserClaimSet() {
return this.userClaimSet; public void setName(String name) {
this.name = name;
}

public String getGivenName() {
return this.givenName;
}

public void setGivenName(String givenName) {
this.givenName = givenName;
}

public String getFamilyName() {
return this.familyName;
}

public void setFamilyName(String familyName) {
this.familyName = familyName;
}

public String getMiddleName() {
return this.middleName;
}

public void setMiddleName(String middleName) {
this.middleName = middleName;
}

public String getNickName() {
return this.nickName;
}

public void setNickName(String nickName) {
this.nickName = nickName;
}

public String getPreferredUsername() {
return this.preferredUsername;
}

public void setPreferredUsername(String preferredUsername) {
this.preferredUsername = preferredUsername;
}

public String getProfile() {
return this.profile;
}

public void setProfile(String profile) {
this.profile = profile;
}

public String getPicture() {
return this.picture;
}

public void setPicture(String picture) {
this.picture = picture;
}

public String getWebsite() {
return this.website;
}

public void setWebsite(String website) {
this.website = website;
}

public String getEmail() {
return this.email;
}

public void setEmail(String email) {
this.email = email;
}

public Boolean getEmailVerified() {
return this.emailVerified;
}

public void setEmailVerified(Boolean emailVerified) {
this.emailVerified = emailVerified;
}

public String getGender() {
return this.gender;
}

public void setGender(String gender) {
this.gender = gender;
}

public String getBirthdate() {
return this.birthdate;
}

public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}

public String getZoneinfo() {
return this.zoneinfo;
}

public void setZoneinfo(String zoneinfo) {
this.zoneinfo = zoneinfo;
}

public String getLocale() {
return this.locale;
}

public void setLocale(String locale) {
this.locale = locale;
}

public String getPhoneNumber() {
return this.phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}

public Boolean getPhoneNumberVerified() {
return this.phoneNumberVerified;
}

public void setPhoneNumberVerified(Boolean phoneNumberVerified) {
this.phoneNumberVerified = phoneNumberVerified;
}

public AddressClaimSet getAddress() {
return address;
}

public void setAddress(AddressClaimSet address) {
this.address = address;
}

public Long getUpdatedAt() {
return this.updatedAt;
}

public void setUpdatedAt(Long updatedAt) {
this.updatedAt = updatedAt;
}

public String getClaimsLocales() {
return this.claimsLocales;
} }


public void setUserClaimSet(UserClaimSet userClaimSet) { public void setClaimsLocales(String claimsLocales) {
this.userClaimSet = userClaimSet; this.claimsLocales = claimsLocales;
} }


/** /**
Expand All @@ -65,7 +272,7 @@ public Map<String, Object> getOtherClaims() {
} }


@JsonAnySetter @JsonAnySetter
public void setOtherClaims(Map<String, Object> otherClaims) { public void setOtherClaims(String name, Object value) {
this.otherClaims = otherClaims; otherClaims.put(name, value);
} }
} }

0 comments on commit 98831ec

Please sign in to comment.