Class ClaimsConstraint
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,VerifiedClaimConstraint>
-
- com.authlete.common.assurance.constraint.ClaimsConstraint
-
- All Implemented Interfaces:
Constraint,Serializable,Cloneable,Map<String,VerifiedClaimConstraint>
public class ClaimsConstraint extends LinkedHashMap<String,VerifiedClaimConstraint> implements Constraint
The class that represents the constraint forverified_claims/claims.- Since:
- 2.63
- See Also:
- OpenID Connect for Identity Assurance 1.0, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description ClaimsConstraint()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexists()Check if the key that represents the constraint exists.static ClaimsConstraintextract(Map<?,?> map, String key)Create aClaimsConstraintinstance from an object in the given map.booleanisNull()Check if the value of the constraint is null.ClaimsConstraintputClaim(String claimName, VerifiedClaimConstraint constraint)Put a claim constraint to this object.voidsetExists(boolean exists)Set the existence of the constraint.voidsetNull(boolean isNull)Set the boolean flag that indicates that the value of the constraint is null.StringtoJson()Convert this object into JSON in the way conforming to the structure defined in 5.StringtoJson(boolean pretty)Convert this object into JSON in the way conforming to the structure defined in 5.Map<String,Object>toMap()Create aMapinstance that represents this object in the way conforming to the structure defined in 5.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Method Detail
-
exists
public boolean exists()
Description copied from interface:ConstraintCheck if the key that represents the constraint exists. It does not matter whether the value of the key is null or not.For example,
exists()method of an instance that representsgiven_namein the JSON below will returntrue.{ "verified_claims": { "claims": { "given_name": null } } }- Specified by:
existsin interfaceConstraint- Returns:
trueif the key that represents the constraint exists.
-
setExists
public void setExists(boolean exists)
Set the existence of the constraint.- Parameters:
exists-trueto indicate that the constraint exists.
-
isNull
public boolean isNull()
Description copied from interface:ConstraintCheck if the value of the constraint is null.For example,
isNull()method of an instance that representsgiven_namein the JSON below will returntrue.{ "verified_claims": { "claims": { "given_name": null } } }But, the method returnsfalsein the following case.{ "verified_claims": { "claims": { "given_name": { } } } }- Specified by:
isNullin interfaceConstraint- Returns:
trueif the value of the constraint is null.
-
setNull
public void setNull(boolean isNull)
Set the boolean flag that indicates that the value of the constraint is null.- Parameters:
isNull-trueto indicate that the value of the constraint is null.
-
putClaim
public ClaimsConstraint putClaim(String claimName, VerifiedClaimConstraint constraint)
Put a claim constraint to this object.This method internally calls
put(String, VerifiedClaimConstraint)method to register the given pair of claim name and constraint and then returnsthisobject.- Parameters:
claimName- The claim name.constraint- The constraint for the claim.- Returns:
thisobject.- Since:
- 2.65
-
extract
public static ClaimsConstraint extract(Map<?,?> map, String key) throws ConstraintException
Create aClaimsConstraintinstance from an object in the given map.- Parameters:
map- A map that may contain"claims".key- The key that identifies the object in the map. In normal cases, the key is"claims".- Returns:
- A
ClaimsConstraintinstance that represents"claims". Even if the map does not contain the given key, an instance ofClaimsConstraintis returned. - Throws:
ConstraintException- The structure of the map does not conform to the specification (OpenID Connect for Identity Assurance 1.0).
-
toMap
public Map<String,Object> toMap()
Create aMapinstance that represents this object in the way conforming to the structure defined in 5. Requesting Verified Claims of OpenID Connect for Identity Assurance 1.0.
-
toJson
public String toJson()
Convert this object into JSON in the way conforming to the structure defined in 5. Requesting Verified Claims of OpenID Connect for Identity Assurance 1.0.This method is an alias of
toJson(false).- Returns:
- JSON that represents this object. If
toMap()returns null, this method returns"null"(aStringinstance which consists of'n','u','l'and'l').
-
toJson
public String toJson(boolean pretty)
Convert this object into JSON in the way conforming to the structure defined in 5. Requesting Verified Claims of OpenID Connect for Identity Assurance 1.0.- Parameters:
pretty-trueto make the output more human-readable.- Returns:
- JSON that represents this object. If
toMap()returns null, this method returns"null"(aStringinstance which consists of'n','u','l'and'l').
-
-