Package com.nimbusds.jose.crypto.impl
Class BaseJWEProvider
java.lang.Object
com.nimbusds.jose.crypto.impl.BaseJWEProvider
- All Implemented Interfaces:
JCAAware<JWEJCAContext>
,JOSEProvider
,JWEProvider
- Direct Known Subclasses:
AESCryptoProvider
,DirectCryptoProvider
,ECDH1PUCryptoProvider
,ECDHCryptoProvider
,MultiCryptoProvider
,PasswordBasedCryptoProvider
,RSACryptoProvider
The base abstract class for JSON Web Encryption (JWE) encrypters and
decrypters.
- Version:
- 2023-09-18
- Author:
- Vladimir Dzhuvinov
-
Constructor Summary
ConstructorDescriptionBaseJWEProvider
(Set<JWEAlgorithm> algs, Set<EncryptionMethod> encs) Creates a new base JWE provider.BaseJWEProvider
(Set<JWEAlgorithm> algs, Set<EncryptionMethod> encs, SecretKey cek) Creates a new base JWE provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected SecretKey
getCEK
(EncryptionMethod enc) Returns the content encryption key (CEK) to use.Returns the Java Cryptography Architecture (JCA) context.protected boolean
Returnstrue
if a content encryption key (CEK) was provided at construction time.Returns the names of the supported encryption methods by the JWE provier.Returns the names of the supported algorithms by the JWE provider instance.
-
Constructor Details
-
BaseJWEProvider
Creates a new base JWE provider.- Parameters:
algs
- The supported algorithms by the JWE provider instance. Must not benull
.encs
- The supported encryption methods by the JWE provider instance. Must not benull
.
-
BaseJWEProvider
Creates a new base JWE provider.- Parameters:
algs
- The supported algorithms by the JWE provider instance. Must not benull
.encs
- The supported encryption methods by the JWE provider instance. Must not benull
.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"). Ifnull
a CEK will be generated for each JWE.
-
-
Method Details
-
supportedJWEAlgorithms
Description copied from interface:JWEProvider
Returns the names of the supported algorithms by the JWE provider instance. These correspond to thealg
JWE header parameter.- Specified by:
supportedJWEAlgorithms
in interfaceJWEProvider
- Returns:
- The supported JWE algorithms, empty set if none.
-
supportedEncryptionMethods
Description copied from interface:JWEProvider
Returns the names of the supported encryption methods by the JWE provier. These correspond to theenc
JWE header parameter.- Specified by:
supportedEncryptionMethods
in interfaceJWEProvider
- Returns:
- The supported encryption methods, empty set if none.
-
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 interfaceJCAAware<JWEJCAContext>
- Returns:
- The JCA context. Not
null
.
-
isCEKProvided
Returnstrue
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
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 benull
.- Returns:
- The content encryption key (CEK).
- Throws:
JOSEException
- If an internal exception is encountered.
-