Class BaseJWEProvider

    • Constructor Detail

      • BaseJWEProvider

        public BaseJWEProvider​(Set<JWEAlgorithm> algs,
                               Set<EncryptionMethod> encs)
        Creates a new base JWE provider.
        Parameters:
        algs - The supported algorithms by the JWE provider instance. Must not be null.
        encs - The supported encryption methods by the JWE provider instance. Must not be null.
      • BaseJWEProvider

        public BaseJWEProvider​(Set<JWEAlgorithm> algs,
                               Set<EncryptionMethod> encs,
                               SecretKey cek)
        Creates a new base JWE provider.
        Parameters:
        algs - The supported algorithms by the JWE provider instance. Must not be null.
        encs - The supported encryption methods by the JWE provider instance. Must not be null.
        cek - The content encryption key (CEK) to use. If specified its algorithm must be "AES" or "ChaCha20" and its length must match the expected for the JWE encryption method ("enc"). If null a CEK will be generated for each JWE.
    • Method Detail

      • getJCAContext

        public JWEJCAContext getJCAContext()
        Description copied from interface: JCAAware
        Returns the Java Cryptography Architecture (JCA) context. May be used to set a specific JCA security provider or secure random generator.
        Specified by:
        getJCAContext in interface JCAAware<JWEJCAContext>
        Returns:
        The JCA context. Not null.
      • isCEKProvided

        protected boolean isCEKProvided()
        Returns true if a content encryption key (CEK) was provided at construction time.
        Returns:
        true if a CEK was provided at construction time, false if CEKs will be internally generated.
      • getCEK

        protected SecretKey getCEK​(EncryptionMethod enc)
                            throws JOSEException
        Returns the content encryption key (CEK) to use. Unless a CEK was provided at construction time this will be a new internally generated CEK.
        Parameters:
        enc - The encryption method. Must not be null.
        Returns:
        The content encryption key (CEK).
        Throws:
        JOSEException - If an internal exception is encountered.