Class SignedJWT

  • All Implemented Interfaces:
    JWT, java.io.Serializable

    @ThreadSafe
    public class SignedJWT
    extends JWSObject
    implements JWT
    Signed JSON Web Token (JWT).
    Version:
    2021-02-22
    Author:
    Vladimir Dzhuvinov
    See Also:
    Serialized Form
    • Constructor Detail

      • SignedJWT

        public SignedJWT​(JWSHeader header,
                         JWTClaimsSet claimsSet)
        Creates a new to-be-signed JSON Web Token (JWT) with the specified header and claims set. The initial state will be unsigned.
        Parameters:
        header - The JWS header. Must not be null.
        claimsSet - The JWT claims set. Must not be null.
      • SignedJWT

        public SignedJWT​(Base64URL firstPart,
                         Base64URL secondPart,
                         Base64URL thirdPart)
                  throws java.text.ParseException
        Creates a new signed JSON Web Token (JWT) with the specified serialised parts. The state will be signed.
        Parameters:
        firstPart - The first part, corresponding to the JWS header. Must not be null.
        secondPart - The second part, corresponding to the claims set (payload). Must not be null.
        thirdPart - The third part, corresponding to the signature. Must not be null.
        Throws:
        java.text.ParseException - If parsing of the serialised parts failed.
    • Method Detail

      • getJWTClaimsSet

        public JWTClaimsSet getJWTClaimsSet()
                                     throws java.text.ParseException
        Description copied from interface: JWT
        Gets the claims set of the JSON Web Token (JWT).
        Specified by:
        getJWTClaimsSet in interface JWT
        Returns:
        The claims set, null if not available (for an encrypted JWT that isn't decrypted).
        Throws:
        java.text.ParseException - If the payload of the JWT doesn't represent a valid JSON object and a JWT claims set.
      • setPayload

        protected void setPayload​(Payload payload)
        Description copied from class: JOSEObject
        Sets the payload of this JOSE object.
        Overrides:
        setPayload in class JOSEObject
        Parameters:
        payload - The payload, null if not available (e.g. for an encrypted JWE object).
      • parse

        public static SignedJWT parse​(java.lang.String s)
                               throws java.text.ParseException
        Parses a signed JSON Web Token (JWT) from the specified string in compact format.
        Parameters:
        s - The string to parse. Must not be null.
        Returns:
        The signed JWT.
        Throws:
        java.text.ParseException - If the string couldn't be parsed to a valid signed JWT.