Package com.auth0.jwt

Class JWTDecoder

java.lang.Object
com.auth0.jwt.JWTDecoder
All Implemented Interfaces:
DecodedJWT, Header, Payload

final class JWTDecoder extends Object implements DecodedJWT
The JWTDecoder class holds the decode method to parse a given JWT token into it's JWT representation.
  • Field Details

    • parts

      private final String[] parts
    • payload

      private final Payload payload
  • Constructor Details

  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      Description copied from interface: Header
      Getter for the Algorithm "alg" claim defined in the JWT's Header. If the claim is missing it will return null.
      Specified by:
      getAlgorithm in interface Header
      Returns:
      the Algorithm defined or null.
    • getType

      public String getType()
      Description copied from interface: Header
      Getter for the Type "typ" claim defined in the JWT's Header. If the claim is missing it will return null.
      Specified by:
      getType in interface Header
      Returns:
      the Type defined or null.
    • getContentType

      public String getContentType()
      Description copied from interface: Header
      Getter for the Content Type "cty" claim defined in the JWT's Header. If the claim is missing it will return null.
      Specified by:
      getContentType in interface Header
      Returns:
      the Content Type defined or null.
    • getKeyId

      public String getKeyId()
      Description copied from interface: Header
      Get the value of the "kid" claim, or null if it's not available.
      Specified by:
      getKeyId in interface Header
      Returns:
      the Key ID value or null.
    • getHeaderClaim

      public Claim getHeaderClaim(String name)
      Description copied from interface: Header
      Get a Private Claim given it's name. If the Claim wasn't specified in the Header, a NullClaim will be returned.
      Specified by:
      getHeaderClaim in interface Header
      Parameters:
      name - the name of the Claim to retrieve.
      Returns:
      a non-null Claim.
    • getIssuer

      public String getIssuer()
      Description copied from interface: Payload
      Get the value of the "iss" claim, or null if it's not available.
      Specified by:
      getIssuer in interface Payload
      Returns:
      the Issuer value or null.
    • getSubject

      public String getSubject()
      Description copied from interface: Payload
      Get the value of the "sub" claim, or null if it's not available.
      Specified by:
      getSubject in interface Payload
      Returns:
      the Subject value or null.
    • getAudience

      public List<String> getAudience()
      Description copied from interface: Payload
      Get the value of the "aud" claim, or null if it's not available.
      Specified by:
      getAudience in interface Payload
      Returns:
      the Audience value or null.
    • getExpiresAt

      public Date getExpiresAt()
      Description copied from interface: Payload
      Get the value of the "exp" claim, or null if it's not available.
      Specified by:
      getExpiresAt in interface Payload
      Returns:
      the Expiration Time value or null.
    • getNotBefore

      public Date getNotBefore()
      Description copied from interface: Payload
      Get the value of the "nbf" claim, or null if it's not available.
      Specified by:
      getNotBefore in interface Payload
      Returns:
      the Not Before value or null.
    • getIssuedAt

      public Date getIssuedAt()
      Description copied from interface: Payload
      Get the value of the "iat" claim, or null if it's not available.
      Specified by:
      getIssuedAt in interface Payload
      Returns:
      the Issued At value or null.
    • getId

      public String getId()
      Description copied from interface: Payload
      Get the value of the "jti" claim, or null if it's not available.
      Specified by:
      getId in interface Payload
      Returns:
      the JWT ID value or null.
    • getClaim

      public Claim getClaim(String name)
      Description copied from interface: Payload
      Get a Claim given it's name. If the Claim wasn't specified in the Payload, a NullClaim will be returned.
      Specified by:
      getClaim in interface Payload
      Parameters:
      name - the name of the Claim to retrieve.
      Returns:
      a non-null Claim.
    • getClaims

      public Map<String,Claim> getClaims()
      Description copied from interface: Payload
      Get the Claims defined in the Token.
      Specified by:
      getClaims in interface Payload
      Returns:
      a non-null Map containing the Claims defined in the Token.
    • getHeader

      public String getHeader()
      Description copied from interface: DecodedJWT
      Getter for the Header contained in the JWT as a Base64 encoded String. This represents the first part of the token.
      Specified by:
      getHeader in interface DecodedJWT
      Returns:
      the Header of the JWT.
    • getPayload

      public String getPayload()
      Description copied from interface: DecodedJWT
      Getter for the Payload contained in the JWT as a Base64 encoded String. This represents the second part of the token.
      Specified by:
      getPayload in interface DecodedJWT
      Returns:
      the Payload of the JWT.
    • getSignature

      public String getSignature()
      Description copied from interface: DecodedJWT
      Getter for the Signature contained in the JWT as a Base64 encoded String. This represents the third part of the token.
      Specified by:
      getSignature in interface DecodedJWT
      Returns:
      the Signature of the JWT.
    • getToken

      public String getToken()
      Description copied from interface: DecodedJWT
      Getter for the String Token used to create this JWT instance.
      Specified by:
      getToken in interface DecodedJWT
      Returns:
      the String Token.