Class CWTClaimsSet
-
Constructor Summary
ConstructorsConstructorDescriptionCWTClaimsSet
(List<? extends CBORPair> pairs) A constructor with label-value pairs that represent claims. -
Method Summary
Modifier and TypeMethodDescriptionstatic CWTClaimsSet
Build an instance of theCWTClaimsSet
class based on the given CBOR item.static CWTClaimsSet
Build an instance of theCWTClaimsSet
class using the key-value pairs in the given map as claims.getAud()
Get the value of the "aud (3)" claim.byte[]
getCti()
Get the value of the "cti (7)" claim.Get the value of the "cti (7)" claim as a string.Get the value of the "cti (7)" claim as a string.getExp()
Get the value of the "exp (4)" claim.getIat()
Get the value of the "iat (6)" claim.getIss()
Get the value of the "iss (1)" claim.getNbf()
Get the value of the "nbf (5)" claim.byte[]
getNonce()
Get the value of the "Nonce (10)" claim.Get the value of the "Nonce (10)" claim as a string.Get the value of the "Nonce (10)" claim as a string.getSub()
Get the value of the "sub (2)" claim.Methods inherited from class com.authlete.cbor.CBORPairList
encode, findByKey, getPairs, parse, prettify, toString
Methods inherited from class com.authlete.cbor.CBORItem
encode, encodeMajorWithNumber, encodeToBase64, encodeToBase64Url, encodeToHex, getComment, prettify, setComment, toString
-
Constructor Details
-
CWTClaimsSet
A constructor with label-value pairs that represent claims.- Parameters:
pairs
- Claims.- Throws:
IllegalArgumentException
- There is one or more claims that do not conform to the requirements of RFC 8392 Section 3. Claims.
-
-
Method Details
-
getIss
Get the value of the "iss (1)" claim.- Returns:
- The value of the "iss (1)" claim.
-
getSub
Get the value of the "sub (2)" claim.- Returns:
- The value of the "sub (2)" claim.
-
getAud
Get the value of the "aud (3)" claim.- Returns:
- The value of the "aud (3)" claim.
-
getExp
Get the value of the "exp (4)" claim.- Returns:
- The value of the "exp (4)" claim.
-
getNbf
Get the value of the "nbf (5)" claim.- Returns:
- The value of the "nbf (5)" claim.
-
getIat
Get the value of the "iat (6)" claim.- Returns:
- The value of the "iat (6)" claim.
-
getCti
public byte[] getCti()Get the value of the "cti (7)" claim.- Returns:
- The value of the "cti (7)" claim.
-
getCtiAsString
Get the value of the "cti (7)" claim as a string.This method assumes that the value of the
cti
claim represents a UTF-8 byte sequence. Character sequences that are unmappable to the UTF-8 encoding are replaced with the default replacement string. if you want an exception to be raised when unmappable character sequences are found, use thegetCtiAsStringWithException()
method.- Returns:
- The value of the "cti (7)" claim as a string.
- See Also:
-
getCtiAsStringWithException
Get the value of the "cti (7)" claim as a string.This method assumes that the value of the
cti
claim represents a UTF-8 byte sequence. When unmappable character sequences are found, an exception is raised.- Returns:
- The value of the "cti (7)" claim as a string.
- Throws:
CharacterCodingException
- Unmappable character sequences are found.- See Also:
-
getNonce
public byte[] getNonce()Get the value of the "Nonce (10)" claim.- Returns:
- The value of the "Nonce (10)" claim.
-
getNonceAsString
Get the value of the "Nonce (10)" claim as a string.This method assumes that the value of the
Nonce
claim represents a UTF-8 byte sequence. Character sequences that are unmappable to the UTF-8 encoding are replaced with the default replacement string. if you want an exception to be raised when unmappable character sequences are found, use thegetNonceAsStringWithException()
method.- Returns:
- The value of the "Nonce (10)" claim as a string.
- See Also:
-
getNonceAsStringWithException
Get the value of the "Nonce (10)" claim as a string.This method assumes that the value of the
Nonce
claim represents a UTF-8 byte sequence. When unmappable character sequences are found, an exception is raised.- Returns:
- The value of the "Nonce (10)" claim as a string.
- Throws:
CharacterCodingException
- Unmappable character sequences are found.- See Also:
-
build
Build an instance of theCWTClaimsSet
class based on the given CBOR item.When the given CBOR item is an instance of
CWTClaimsSet
, the given item is returned as is.When the given CBOR item is null or an instance of
CBORNull
(which represents a CBOR null), aCWTClaimsSet
instance that has no claim is returned.When the given CBOR item is an instance of
CBORPairList
(which represents a CBOR map), the key-value pairs in the instance are used as claims of the returnedCWTClaimsSet
instance.When the given CBOR item is an instance of
CBORByteArray
(which represents a CBOR byte string), this method interprets the content of the byte string as a CBOR map and uses the key-value pairs in the map as claims of the returnedCWTClaimsSet
instance. If the content of the byte string is not a valid CBOR map, an exception is raised.In other case, an exception is raised.
- Parameters:
payload
- Data that represents CWT claims set.- Returns:
- A new
CWTClaimsSet
instance built based on the given data. When the given data is an instance of theCWTClaimsSet
class, the given data is returned as is. - Throws:
CBORDecoderException
- The given data is invalid.
-
build
Build an instance of theCWTClaimsSet
class using the key-value pairs in the given map as claims.- Parameters:
map
- Data that represents CWT claims set. If null is given, aCWTClaimsSet
instance that has no claim is returned.- Returns:
- A new
CWTClaimsSet
instance built based on the given map. - Throws:
IllegalArgumentException
- There is one or more claims that do not conform to the requirements of RFC 8392 Section 3. Claims.
-