Class CWTClaimsSet


public class CWTClaimsSet extends CBORPairList
CWT Claims Set
Since:
1.4
See Also:
  • Constructor Details

  • Method Details

    • getIss

      public String getIss()
      Get the value of the "iss (1)" claim.
      Returns:
      The value of the "iss (1)" claim.
    • getSub

      public String getSub()
      Get the value of the "sub (2)" claim.
      Returns:
      The value of the "sub (2)" claim.
    • getAud

      public String getAud()
      Get the value of the "aud (3)" claim.
      Returns:
      The value of the "aud (3)" claim.
    • getExp

      public Date getExp()
      Get the value of the "exp (4)" claim.
      Returns:
      The value of the "exp (4)" claim.
    • getNbf

      public Date getNbf()
      Get the value of the "nbf (5)" claim.
      Returns:
      The value of the "nbf (5)" claim.
    • getIat

      public Date 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

      public String 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 the getCtiAsStringWithException() method.

      Returns:
      The value of the "cti (7)" claim as a string.
      See Also:
    • getCtiAsStringWithException

      public String getCtiAsStringWithException() throws CharacterCodingException
      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

      public String 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 the getNonceAsStringWithException() method.

      Returns:
      The value of the "Nonce (10)" claim as a string.
      See Also:
    • getNonceAsStringWithException

      public String getNonceAsStringWithException() throws CharacterCodingException
      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

      public static CWTClaimsSet build(CBORItem payload) throws CBORDecoderException
      Build an instance of the CWTClaimsSet 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), a CWTClaimsSet 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 returned CWTClaimsSet 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 returned CWTClaimsSet 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 the CWTClaimsSet class, the given data is returned as is.
      Throws:
      CBORDecoderException - The given data is invalid.
    • build

      public static CWTClaimsSet build(Map<Object,Object> map) throws IllegalArgumentException
      Build an instance of the CWTClaimsSet class using the key-value pairs in the given map as claims.
      Parameters:
      map - Data that represents CWT claims set. If null is given, a CWTClaimsSet 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.