Class UserInfo
- java.lang.Object
-
- com.nimbusds.openid.connect.sdk.claims.ClaimsSet
-
- com.nimbusds.openid.connect.sdk.claims.PersonClaims
-
- com.nimbusds.openid.connect.sdk.claims.UserInfo
-
- All Implemented Interfaces:
net.minidev.json.JSONAware
public class UserInfo extends PersonClaims
UserInfo claims set, serialisable to a JSON object.Supports normal, aggregated and distributed claims.
Example UserInfo claims set:
{ "sub" : "248289761001", "name" : "Jane Doe", "given_name" : "Jane", "family_name" : "Doe", "preferred_username" : "j.doe", "email" : "[email protected]", "picture" : "http://example.com/janedoe/me.jpg" }
Related specifications:
- OpenID Connect Core 1.0, sections 5.1 and 5.6.
- OpenID Connect for Identity Assurance 1.0, section 3.1.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SUB_CLAIM_NAME
The subject claim name.static String
VERIFIED_CLAIMS_CLAIM_NAME
The verified claims claim name.-
Fields inherited from class com.nimbusds.openid.connect.sdk.claims.PersonClaims
ADDRESS_CLAIM_NAME, ALSO_KNOWN_AS, BIRTH_FAMILY_NAME_CLAIM_NAME, BIRTH_GIVEN_NAME_CLAIM_NAME, BIRTH_MIDDLE_NAME_CLAIM_NAME, BIRTHDATE_CLAIM_NAME, BIRTHPLACE_CLAIM_NAME, EMAIL_CLAIM_NAME, EMAIL_VERIFIED_CLAIM_NAME, FAMILY_NAME_CLAIM_NAME, GENDER_CLAIM_NAME, GIVEN_NAME_CLAIM_NAME, LOCALE_CLAIM_NAME, MIDDLE_NAME_CLAIM_NAME, MSISDN_CLAIM_NAME, NAME_CLAIM_NAME, NATIONALITIES_CLAIM_NAME, NICKNAME_CLAIM_NAME, PHONE_NUMBER_CLAIM_NAME, PHONE_NUMBER_VERIFIED_CLAIM_NAME, PICTURE_CLAIM_NAME, PLACE_OF_BIRTH_CLAIM_NAME, PREFERRED_USERNAME_CLAIM_NAME, PROFILE_CLAIM_NAME, SALUTATION_CLAIM_NAME, TITLE_CLAIM_NAME, UPDATED_AT_CLAIM_NAME, WEBSITE_CLAIM_NAME, ZONEINFO_CLAIM_NAME
-
Fields inherited from class com.nimbusds.openid.connect.sdk.claims.ClaimsSet
AUD_CLAIM_NAME, claims, ISS_CLAIM_NAME
-
-
Constructor Summary
Constructors Constructor Description UserInfo(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet)
Creates a new UserInfo claims set from the specified JSON Web Token (JWT) claims set.UserInfo(Subject sub)
Creates a new minimal UserInfo claims set.UserInfo(net.minidev.json.JSONObject jsonObject)
Creates a new UserInfo claims set from the specified JSON object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAggregatedClaims(AggregatedClaims aggregatedClaims)
Adds the specified aggregated claims provided by an external claims source.void
addDistributedClaims(DistributedClaims distributedClaims)
Adds the specified distributed claims from an external claims source.Set<AggregatedClaims>
getAggregatedClaims()
Gets the included aggregated claims provided by each external claims source.Set<DistributedClaims>
getDistributedClaims()
Gets the included distributed claims provided by each external claims source.static Set<String>
getStandardClaimNames()
Gets the names of the standard top-level UserInfo claims.Subject
getSubject()
Gets the UserInfo subject.List<VerifiedClaimsSet>
getVerifiedClaims()
Gets the verified claims.static UserInfo
parse(String json)
Parses a UserInfo claims set from the specified JSON object string.void
putAll(UserInfo other)
Puts all claims from the specified other UserInfo claims set.void
setVerifiedClaims(VerifiedClaimsSet verifiedClaims)
Sets the verified claims.void
setVerifiedClaims(List<VerifiedClaimsSet> verifiedClaimsList)
Sets a list of verified claims with separate verifications.-
Methods inherited from class com.nimbusds.openid.connect.sdk.claims.PersonClaims
getAddress, getAddress, getAddressEntries, getAlsoKnownAs, getAlsoKnownAs, getAlsoKnownAsEntries, getBirthdate, getBirthFamilyName, getBirthFamilyName, getBirthFamilyNameEntries, getBirthGivenName, getBirthGivenName, getBirthGivenNameEntries, getBirthMiddleName, getBirthMiddleName, getBirthMiddleNameEntries, getBirthplace, getEmailAddress, getEmailVerified, getFamilyName, getFamilyName, getFamilyNameEntries, getGender, getGivenName, getGivenName, getGivenNameEntries, getLocale, getMiddleName, getMiddleName, getMiddleNameEntries, getMSISDN, getName, getName, getNameEntries, getNationalities, getNickname, getNickname, getNicknameEntries, getPhoneNumber, getPhoneNumberVerified, getPicture, getPlaceOfBirth, getPreferredUsername, getProfile, getSalutation, getSalutation, getSalutationEntries, getTitle, getTitle, getTitleEntries, getUpdatedTime, getWebsite, getZoneinfo, setAddress, setAddress, setAlsoKnownAs, setAlsoKnownAs, setBirthdate, setBirthFamilyName, setBirthFamilyName, setBirthGivenName, setBirthGivenName, setBirthMiddleName, setBirthMiddleName, setBirthplace, setEmailAddress, setEmailVerified, setFamilyName, setFamilyName, setGender, setGivenName, setGivenName, setLocale, setMiddleName, setMiddleName, setMSISDN, setName, setName, setNationalities, setNickname, setNickname, setPhoneNumber, setPhoneNumberVerified, setPicture, setPlaceOfBirth, setPreferredUsername, setProfile, setSalutation, setSalutation, setTitle, setTitle, setUpdatedTime, setWebsite, setZoneinfo
-
Methods inherited from class com.nimbusds.openid.connect.sdk.claims.ClaimsSet
equals, getAudience, getBooleanClaim, getClaim, getClaim, getDateClaim, getIssuer, getJSONObjectClaim, getLangTaggedClaim, getNumberClaim, getStringClaim, getStringClaim, getStringListClaim, getURIClaim, getURLClaim, hashCode, putAll, putAll, setAudience, setAudience, setClaim, setClaim, setDateClaim, setIssuer, setURIClaim, setURLClaim, toJSONObject, toJSONString, toJWTClaimsSet
-
-
-
-
Field Detail
-
SUB_CLAIM_NAME
public static final String SUB_CLAIM_NAME
The subject claim name.- See Also:
- Constant Field Values
-
VERIFIED_CLAIMS_CLAIM_NAME
public static final String VERIFIED_CLAIMS_CLAIM_NAME
The verified claims claim name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UserInfo
public UserInfo(Subject sub)
Creates a new minimal UserInfo claims set.- Parameters:
sub
- The subject. Must not benull
.
-
UserInfo
public UserInfo(net.minidev.json.JSONObject jsonObject)
Creates a new UserInfo claims set from the specified JSON object.- Parameters:
jsonObject
- The JSON object. Must not benull
.- Throws:
IllegalArgumentException
- If the JSON object doesn't contain a subjectsub
string claim.
-
UserInfo
public UserInfo(com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet)
Creates a new UserInfo claims set from the specified JSON Web Token (JWT) claims set.- Parameters:
jwtClaimsSet
- The JWT claims set. Must not benull
.- Throws:
IllegalArgumentException
- If the JWT claims set doesn't contain a subjectsub
string claim.
-
-
Method Detail
-
getStandardClaimNames
public static Set<String> getStandardClaimNames()
Gets the names of the standard top-level UserInfo claims.- Returns:
- The names of the standard top-level UserInfo claims (read-only set).
-
putAll
public void putAll(UserInfo other)
Puts all claims from the specified other UserInfo claims set. Aggregated and distributed claims are properly merged.- Parameters:
other
- The other UserInfo. Must have the samesubject
. Must not benull
.- Throws:
IllegalArgumentException
- If the other UserInfo claims set doesn't have an identical subject, or if the external claims source ID of the other UserInfo matches an existing source ID.
-
getSubject
public Subject getSubject()
Gets the UserInfo subject. Corresponds to thesub
claim.- Returns:
- The subject.
-
getVerifiedClaims
public List<VerifiedClaimsSet> getVerifiedClaims()
Gets the verified claims. Corresponds to theverified_claims
claim from OpenID Connect for Identity Assurance 1.0.- Returns:
- List of the verified claims sets,
null
if not specified or parsing failed.
-
setVerifiedClaims
public void setVerifiedClaims(VerifiedClaimsSet verifiedClaims)
Sets the verified claims. Corresponds to theverified_claims
claim from OpenID Connect for Identity Assurance 1.0.- Parameters:
verifiedClaims
- The verified claims set,null
if not specified.
-
setVerifiedClaims
public void setVerifiedClaims(List<VerifiedClaimsSet> verifiedClaimsList)
Sets a list of verified claims with separate verifications. Corresponds to theverified_claims
claim from OpenID Connect for Identity Assurance 1.0.- Parameters:
verifiedClaimsList
- List of the verified claims sets,null
if not specified or parsing failed.
-
addAggregatedClaims
public void addAggregatedClaims(AggregatedClaims aggregatedClaims)
Adds the specified aggregated claims provided by an external claims source.- Parameters:
aggregatedClaims
- The aggregated claims instance, ifnull
nothing will be added.
-
getAggregatedClaims
public Set<AggregatedClaims> getAggregatedClaims()
Gets the included aggregated claims provided by each external claims source.- Returns:
- The aggregated claims,
null
if none are found.
-
addDistributedClaims
public void addDistributedClaims(DistributedClaims distributedClaims)
Adds the specified distributed claims from an external claims source.- Parameters:
distributedClaims
- The distributed claims instance, ifnull
nothing will be added.
-
getDistributedClaims
public Set<DistributedClaims> getDistributedClaims()
Gets the included distributed claims provided by each external claims source.- Returns:
- The distributed claims,
null
if none are found.
-
parse
public static UserInfo parse(String json) throws ParseException
Parses a UserInfo claims set from the specified JSON object string.- Parameters:
json
- The JSON object string to parse. Must not benull
.- Returns:
- The UserInfo claims set.
- Throws:
ParseException
- If parsing failed.
-
-