Class JWEObject

    • Constructor Detail

      • JWEObject

        public JWEObject​(JWEHeader header,
                         Payload payload)
        Creates a new to-be-encrypted JSON Web Encryption (JWE) object with the specified header and payload. The initial state will be unencrypted.
        Parameters:
        header - The JWE header. Must not be null.
        payload - The payload. Must not be null.
      • JWEObject

        public JWEObject​(Base64URL firstPart,
                         Base64URL secondPart,
                         Base64URL thirdPart,
                         Base64URL fourthPart,
                         Base64URL fifthPart)
                  throws ParseException
        Creates a new encrypted JSON Web Encryption (JWE) object with the specified serialised parts. The state will be encrypted.
        Parameters:
        firstPart - The first part, corresponding to the JWE header. Must not be null.
        secondPart - The second part, corresponding to the encrypted key. Empty or null if none.
        thirdPart - The third part, corresponding to the initialisation vector. Empty or null if none.
        fourthPart - The fourth part, corresponding to the cipher text. Must not be null.
        fifthPart - The fifth part, corresponding to the authentication tag. Empty of null if none.
        Throws:
        ParseException - If parsing of the serialised parts failed.
    • Method Detail

      • getEncryptedKey

        public Base64URL getEncryptedKey()
        Returns the encrypted key of this JWE object.
        Returns:
        The encrypted key, null not applicable or the JWE object has not been encrypted yet.
      • getIV

        public Base64URL getIV()
        Returns the initialisation vector (IV) of this JWE object.
        Returns:
        The initialisation vector (IV), null if not applicable or the JWE object has not been encrypted yet.
      • getCipherText

        public Base64URL getCipherText()
        Returns the cipher text of this JWE object.
        Returns:
        The cipher text, null if the JWE object has not been encrypted yet.
      • getAuthTag

        public Base64URL getAuthTag()
        Returns the authentication tag of this JWE object.
        Returns:
        The authentication tag, null if not applicable or the JWE object has not been encrypted yet.
      • serialize

        public String serialize()
        Serialises this JWE object to its compact format consisting of Base64URL-encoded parts delimited by period ('.') characters. It must be in a encrypted or decrypted state.
         [header-base64url].[encryptedKey-base64url].[iv-base64url].[cipherText-base64url].[authTag-base64url]
         
        Specified by:
        serialize in class JOSEObject
        Returns:
        The serialised JWE object.
        Throws:
        IllegalStateException - If the JWE object is not in a encrypted or decrypted state.
      • parse

        public static JWEObject parse​(String s)
                               throws ParseException
        Parses a JWE object from the specified string in compact form. The parsed JWE object will be given an JWEObject.State.ENCRYPTED state.
        Parameters:
        s - The string to parse. Must not be null.
        Returns:
        The JWE object.
        Throws:
        ParseException - If the string couldn't be parsed to a valid JWE object.