com.nimbusds.openid.connect.sdk.claims
Class ClaimsSet

java.lang.Object
  extended by com.nimbusds.openid.connect.sdk.claims.ClaimsSet
Direct Known Subclasses:
Address, UserInfo

public abstract class ClaimsSet
extends Object

Claims set serialisable to a JSON object.

Author:
Vladimir Dzhuvinov

Constructor Summary
protected ClaimsSet()
          Creates a new empty claims set.
protected ClaimsSet(net.minidev.json.JSONObject jsonObject)
          Creates a new claims set from the specified JSON object.
 
Method Summary
 Boolean getBooleanClaim(String name)
          Gets a boolean-based claim.
 Object getClaim(String name)
          Gets a claim.
<T> T
getClaim(String name, Class<T> clazz)
          Gets a claim that casts to the specified class.
 Date getDateClaim(String name)
          Gets a date / time based claim, represented as the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date / time.
 javax.mail.internet.InternetAddress getEmailClaim(String name)
          Gets an email string based claim.
 net.minidev.json.JSONObject getJSONObject()
          Gets the JSON object representation of this claims set.
<T> Map<com.nimbusds.langtag.LangTag,T>
getLangTaggedClaim(String name, Class<T> clazz)
          Returns a map of all instances, including language-tagged, of a claim with the specified base name.
 Number getNumberClaim(String name)
          Gets a number-based claim.
 String getStringClaim(String name)
          Gets a string-based claim.
 String getStringClaim(String name, com.nimbusds.langtag.LangTag langTag)
          Gets a string-based claim with an optional language tag.
 URL getURLClaim(String name)
          Gets an URL string based claim.
 void setClaim(String name, Object value)
          Sets a claim.
<T> void
setClaim(String name, Object value, com.nimbusds.langtag.LangTag langTag)
          Sets a claim with an optional language tag.
 void setDateClaim(String name, Date value)
          Sets a date / time based claim, represented as the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date / time.
 void setEmailClaim(String name, javax.mail.internet.InternetAddress value)
          Sets an email string based claim.
 void setURLClaim(String name, URL value)
          Sets an URL string based claim.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClaimsSet

protected ClaimsSet()
Creates a new empty claims set.


ClaimsSet

protected ClaimsSet(net.minidev.json.JSONObject jsonObject)
Creates a new claims set from the specified JSON object.

Parameters:
jsonObject - The JSON object. Must not be null.
Method Detail

getClaim

public Object getClaim(String name)
Gets a claim.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified.

getClaim

public <T> T getClaim(String name,
                      Class<T> clazz)
Gets a claim that casts to the specified class.

Parameters:
name - The claim name. Must not be null.
clazz - The Java class that the claim value should cast to. Must not be null.
Returns:
The claim value, null if not specified or casting failed.

getLangTaggedClaim

public <T> Map<com.nimbusds.langtag.LangTag,T> getLangTaggedClaim(String name,
                                                                  Class<T> clazz)
Returns a map of all instances, including language-tagged, of a claim with the specified base name.

Example JSON serialised claims set:

 {
   "month"    : "January",
   "month#de" : "Januar"
   "month#es" : "enero",
   "month#it" : "gennaio"
 }
 

The "month" claim instances as java.util.Map:

 null => "January" (no language tag)
 "de" => "Januar"
 "es" => "enero"
 "it" => "gennaio"
 

Parameters:
name - The claim name. Must not be null.
clazz - The Java class that the claim values should cast to. Must not be null.
Returns:
The matching language-tagged claim values, empty map if none. A null key indicates the value has no language tag (corresponds to the base name).

setClaim

public void setClaim(String name,
                     Object value)
Sets a claim.

Parameters:
name - The claim name, with an optional language tag. Must not be null.
value - The claim value. Should serialise to a JSON entity. If null any existing claim with the same name will be removed.

setClaim

public <T> void setClaim(String name,
                         Object value,
                         com.nimbusds.langtag.LangTag langTag)
Sets a claim with an optional language tag.

Parameters:
name - The claim name. Must not be null.
value - The claim value. Should serialise to a JSON entity. If null any existing claim with the same name and language tag (if any) will be removed.
langTag - The language tag of the claim value, null if not tagged.

getStringClaim

public String getStringClaim(String name)
Gets a string-based claim.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified or casting failed.

getStringClaim

public String getStringClaim(String name,
                             com.nimbusds.langtag.LangTag langTag)
Gets a string-based claim with an optional language tag.

Parameters:
name - The claim name. Must not be null.
langTag - The language tag of the claim value, null to get the non-tagged value.
Returns:
The claim value, null if not specified or casting failed.

getBooleanClaim

public Boolean getBooleanClaim(String name)
Gets a boolean-based claim.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified or casting failed.

getNumberClaim

public Number getNumberClaim(String name)
Gets a number-based claim.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified or casting failed.

getURLClaim

public URL getURLClaim(String name)
Gets an URL string based claim.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified or parsing failed.

setURLClaim

public void setURLClaim(String name,
                        URL value)
Sets an URL string based claim.

Parameters:
name - The claim name. Must not be null.
value - The claim value. If null any existing claim with the same name will be removed.

getEmailClaim

public javax.mail.internet.InternetAddress getEmailClaim(String name)
Gets an email string based claim.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified or parsing failed.

setEmailClaim

public void setEmailClaim(String name,
                          javax.mail.internet.InternetAddress value)
Sets an email string based claim.

Parameters:
name - The claim name. Must not be null.
value - The claim value. If null any existing claim with the same name will be removed.

getDateClaim

public Date getDateClaim(String name)
Gets a date / time based claim, represented as the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date / time.

Parameters:
name - The claim name. Must not be null.
Returns:
The claim value, null if not specified or parsing failed.

setDateClaim

public void setDateClaim(String name,
                         Date value)
Sets a date / time based claim, represented as the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date / time.

Parameters:
name - The claim name. Must not be null.
value - The claim value. If null any existing claim with the same name will be removed.

getJSONObject

public net.minidev.json.JSONObject getJSONObject()
Gets the JSON object representation of this claims set.

Example:

 {
   "country"       : "USA",
   "country#en"    : "USA",
   "country#de_DE" : "Vereinigte Staaten",
   "country#fr_FR" : "Etats Unis"
 }
 

Returns:
The JSON object representation.


Copyright © 2013 NimbusDS. All Rights Reserved.