Package org.forgerock.json.jose.jwt
Class JWObject
- java.lang.Object
-
- org.forgerock.json.jose.jwt.JWObject
-
- Direct Known Subclasses:
JWKSet
,JwtClaimsSet
,JwtHeader
public abstract class JWObject extends Object
A base implementation class for a JSON Web object.Provides a set of methods which are common across JWT, JWS, JWE and JWK implementations.
- Since:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description JWObject()
Constructs a new, empty JWObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkListValuesAreOfType(List<?> value, Class<?> requiredClazz)
Checks that the given List's type is of an assignable type from the required class.protected void
checkValueIsOfType(Object value, Class<?> requiredClazz)
Checks that the given value is of an assignable type from the required class.boolean
equals(Object o)
JsonValue
get(String key)
Returns the specified item value.int
hashCode()
boolean
isDefined(String key)
Returnstrue
if this JWObject contains the specified item.protected boolean
isValueOfType(Object value, Class<?> requiredClazz)
Checks to see if the given value is of an assignable type from the required class.Set<String>
keys()
Returns the set of keys for this JWObject's values.void
put(String key, Object value)
Sets or removes the value of the specified member.JsonValue
toJsonValue()
Returns a json representation of the JWObject.String
toString()
Returns a string representation of the JWObject.
-
-
-
Method Detail
-
checkValueIsOfType
protected void checkValueIsOfType(Object value, Class<?> requiredClazz)
Checks that the given value is of an assignable type from the required class.Will throw a JwtRuntimeException if the value is not of the required type
- Parameters:
value
- The value to check is of the required type.requiredClazz
- The class of the required type.- See Also:
isValueOfType(Object, Class)
-
checkListValuesAreOfType
protected void checkListValuesAreOfType(List<?> value, Class<?> requiredClazz)
Checks that the given List's type is of an assignable type from the required class.Will throw a JwtRuntimeException if the value is not of the required type
- Parameters:
value
- The List to check the type is of the required type.requiredClazz
- The class of the required type.- See Also:
checkValueIsOfType(Object, Class)
-
isValueOfType
protected boolean isValueOfType(Object value, Class<?> requiredClazz)
Checks to see if the given value is of an assignable type from the required class.- Parameters:
value
- The value to check is of the required type.requiredClazz
- The class of the required type.- Returns:
true
if the value if of the required type.- See Also:
checkValueIsOfType(Object, Class)
-
put
public void put(String key, Object value)
Sets or removes the value of the specified member.If the value is not null, then the value is set as the value of the given key.
Otherwise, if the value is null and the key already exist with a value assigned to it, then the key and its value will be removed. If the specified key is not defined, calling this method has no effect.
- Parameters:
key
- theMap
key identifying the value to set or to remove.value
- the object value to assign to the member.
-
get
public JsonValue get(String key)
Returns the specified item value. If no such member value exists, then a JSON value containingnull
is returned.- Parameters:
key
- theMap
key identifying the item to return.- Returns:
- a JSON value containing the value or
null
.
-
isDefined
public boolean isDefined(String key)
Returnstrue
if this JWObject contains the specified item.- Parameters:
key
- theMap
key of the item to seek.- Returns:
true
if this JSON value contains the specified member.
-
keys
public Set<String> keys()
Returns the set of keys for this JWObject's values.The order of the resulting keys is undefined. If there are no values set, this method returns an empty set.
- Returns:
- A Set of keys.
-
toString
public String toString()
Returns a string representation of the JWObject. The result is guaranteed to be valid JSON object syntax.
-
toJsonValue
public JsonValue toJsonValue()
Returns a json representation of the JWObject.- Returns:
- A JSON representation.
-
-