Class CWTClaimsSetBuilder

java.lang.Object
com.authlete.cwt.CWTClaimsSetBuilder

public class CWTClaimsSetBuilder extends Object
A utility to build an instance of the CWTClaimsSet class.
Since:
1.4
See Also:
  • Constructor Details

    • CWTClaimsSetBuilder

      public CWTClaimsSetBuilder()
  • Method Details

    • put

      public CWTClaimsSetBuilder put(Object key, Object value)
      Add a claim.
      Parameters:
      key - The key of the claim. A pre-defined numeric claim key (e.g. CWTClaims.ISS) or a string name.
      value - The value of the claim.
      Returns:
      this object.
    • iss

      public CWTClaimsSetBuilder iss(String issuer)
      Set the "iss (1)" claim.
      Parameters:
      issuer - The value of the iss claim.
      Returns:
      this object.
    • sub

      public CWTClaimsSetBuilder sub(String subject)
      Set the "sub (2)" claim.
      Parameters:
      subject - The value of the sub claim.
      Returns:
      this object.
    • aud

      public CWTClaimsSetBuilder aud(String audience)
      Set the "aud (3)" claim.
      Parameters:
      audience - The value of the aud claim.
      Returns:
      this object.
    • exp

      public CWTClaimsSetBuilder exp(Date expirationTime)
      Set the "exp (4)" claim.
      Parameters:
      expirationTime - The value of the exp claim.
      Returns:
      this object.
    • exp

      public CWTClaimsSetBuilder exp(long expirationTime)
      Set the "exp (4)" claim.
      Parameters:
      expirationTime - The value of the exp claim. A time expressed in seconds elapsed since the Unix epoch.
      Returns:
      this object.
    • nbf

      public CWTClaimsSetBuilder nbf(Date notBefore)
      Set the "nbf (5)" claim.
      Parameters:
      notBefore - The value of the nbf claim.
      Returns:
      this object.
    • nbf

      public CWTClaimsSetBuilder nbf(long notBefore)
      Set the "nbf (5)" claim.
      Parameters:
      notBefore - The value of the nbf claim. A time expressed in seconds elapsed since the Unix epoch.
      Returns:
      this object.
    • iat

      public CWTClaimsSetBuilder iat(Date issuedAt)
      Set the "iat (6)" claim.
      Parameters:
      issuedAt - The value of the iat claim.
      Returns:
      this object.
    • iat

      public CWTClaimsSetBuilder iat(long issuedAt)
      Set the "iat (6)" claim.
      Parameters:
      issuedAt - The value of the iat claim. A time expressed in seconds elapsed since the Unix epoch.
      Returns:
      this object.
    • cti

      public CWTClaimsSetBuilder cti(String identifier)
      Set the "cti (7)" claim.
      Parameters:
      identifier - The value of the cti claim (CWT ID). The UTF-8 byte sequence of the given string is used as the actual value of the claim.
      Returns:
      this object.
    • cti

      public CWTClaimsSetBuilder cti(byte[] identifier)
      Set the "cti (7)" claim.
      Parameters:
      identifier - The value of the cti claim (CWT ID).
      Returns:
      this object.
    • nonce

      public CWTClaimsSetBuilder nonce(String nonce)
      Set the "Nonce (10)" claim.
      Parameters:
      nonce - The value of the Nonce claim. The UTF-8 byte sequence of the given string is used as the actual value of the claim.
      Returns:
      this object.
    • nonce

      public CWTClaimsSetBuilder nonce(byte[] nonce)
      Set the "Nonce (10)" claim.
      Parameters:
      nonce - The value of the Nonce claim.
      Returns:
      this object.
    • build

      public CWTClaimsSet build()
      Build an instance of the CWTClaimsSet class.
      Returns:
      An instance of the CWTClaimsSet class.