Package com.auth0.jwt

Class JWTDecoder

  • All Implemented Interfaces:
    DecodedJWT, Header, Payload

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

      Constructors 
      Constructor Description
      JWTDecoder​(JWTParser converter, java.lang.String jwt)  
      JWTDecoder​(java.lang.String jwt)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAlgorithm()
      Getter for the Algorithm "alg" claim defined in the JWT's Header.
      java.util.List<java.lang.String> getAudience()
      Get the value of the "aud" claim, or null if it's not available.
      Claim getClaim​(java.lang.String name)
      Get a Claim given it's name.
      java.util.Map<java.lang.String,​Claim> getClaims()
      Get the Claims defined in the Token.
      java.lang.String getContentType()
      Getter for the Content Type "cty" claim defined in the JWT's Header.
      java.util.Date getExpiresAt()
      Get the value of the "exp" claim, or null if it's not available.
      java.lang.String getHeader()
      Getter for the Header contained in the JWT as a Base64 encoded String.
      Claim getHeaderClaim​(java.lang.String name)
      Get a Private Claim given it's name.
      java.lang.String getId()
      Get the value of the "jti" claim, or null if it's not available.
      java.util.Date getIssuedAt()
      Get the value of the "iat" claim, or null if it's not available.
      java.lang.String getIssuer()
      Get the value of the "iss" claim, or null if it's not available.
      java.lang.String getKeyId()
      Get the value of the "kid" claim, or null if it's not available.
      java.util.Date getNotBefore()
      Get the value of the "nbf" claim, or null if it's not available.
      java.lang.String getPayload()
      Getter for the Payload contained in the JWT as a Base64 encoded String.
      java.lang.String getSignature()
      Getter for the Signature contained in the JWT as a Base64 encoded String.
      java.lang.String getSubject()
      Get the value of the "sub" claim, or null if it's not available.
      java.lang.String getToken()
      Getter for the String Token used to create this JWT instance.
      java.lang.String getType()
      Getter for the Type "typ" claim defined in the JWT's Header.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • parts

        private final java.lang.String[] parts
      • header

        private final Header header
      • payload

        private final Payload payload
    • Method Detail

      • getAlgorithm

        public java.lang.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 java.lang.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 java.lang.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 java.lang.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​(java.lang.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 java.lang.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 java.lang.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 java.util.List<java.lang.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 java.util.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 java.util.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 java.util.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 java.lang.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​(java.lang.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 java.util.Map<java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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.