public class RSAEncrypter extends java.lang.Object implements JWEEncrypter
JWE objects. This class
is thread-safe.
Supports the following JWE algorithms:
Supports the following encryption methods:
| Modifier and Type | Field and Description |
|---|---|
protected java.security.Provider |
contentEncryptionProvider
The JCA provider for the content encryption,
null if not
specified (implies default one). |
protected java.security.Provider |
keyEncryptionProvider
The JCA provider for the key encryption,
null if not
specified (implies default one). |
protected java.security.Provider |
macProvider
The JCA provider for the MAC computation,
null if not
specified (implies default one). |
static java.util.Set<JWEAlgorithm> |
SUPPORTED_ALGORITHMS
The supported JWE algorithms.
|
static java.util.Set<EncryptionMethod> |
SUPPORTED_ENCRYPTION_METHODS
The supported encryption methods.
|
| Constructor and Description |
|---|
RSAEncrypter(java.security.interfaces.RSAPublicKey publicKey)
Creates a new RSA encrypter.
|
| Modifier and Type | Method and Description |
|---|---|
JWECryptoParts |
encrypt(ReadOnlyJWEHeader readOnlyJWEHeader,
byte[] bytes)
Encrypts the specified clear text of a
JWE object. |
java.security.interfaces.RSAPublicKey |
getPublicKey()
Gets the public RSA key.
|
protected java.security.SecureRandom |
getSecureRandom()
Returns the secure random generator for this JWE provider.
|
void |
setContentEncryptionProvider(java.security.Provider provider)
Sets a specific JCA provider for the content encryption.
|
void |
setKeyEncryptionProvider(java.security.Provider provider)
Sets a specific JCA provider for the key encryption.
|
void |
setMACProvider(java.security.Provider provider)
Sets a specific JCA provider for MAC computation (where required by
the JWE encryption method).
|
void |
setProvider(java.security.Provider provider)
Sets a specific JCA provider, to be used for all operations.
|
void |
setSecureRandom(java.security.SecureRandom randomGen)
Sets a specific secure random generator for the initialisation
vector and other purposes requiring a random number.
|
java.util.Set<JWEAlgorithm> |
supportedAlgorithms()
Returns the names of the supported JWE algorithms.
|
java.util.Set<EncryptionMethod> |
supportedEncryptionMethods()
Returns the names of the supported encryption methods.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetContentEncryptionProvider, setKeyEncryptionProvider, setMACProvider, setSecureRandom, supportedAlgorithms, supportedEncryptionMethodssetProviderpublic static final java.util.Set<JWEAlgorithm> SUPPORTED_ALGORITHMS
public static final java.util.Set<EncryptionMethod> SUPPORTED_ENCRYPTION_METHODS
protected java.security.Provider keyEncryptionProvider
null if not
specified (implies default one).protected java.security.Provider contentEncryptionProvider
null if not
specified (implies default one).protected java.security.Provider macProvider
null if not
specified (implies default one).public RSAEncrypter(java.security.interfaces.RSAPublicKey publicKey) throws JOSEException
publicKey - The public RSA key. Must not be null.JOSEException - If the underlying secure random generator
couldn't be instantiated.public java.security.interfaces.RSAPublicKey getPublicKey()
public JWECryptoParts encrypt(ReadOnlyJWEHeader readOnlyJWEHeader, byte[] bytes) throws JOSEException
JWEEncrypterJWE object.encrypt in interface JWEEncrypterreadOnlyJWEHeader - The JSON Web Encryption (JWE) header. Must specify a
supported JWE algorithm and must not be
null.bytes - The clear text to encrypt. Must not be null.JOSEException - If the JWE algorithm is not supported or if
encryption failed for some other reason.public java.util.Set<JWEAlgorithm> supportedAlgorithms()
JWEAlgorithmProvideralg JWE header parameter.supportedAlgorithms in interface JWEAlgorithmProviderpublic java.util.Set<EncryptionMethod> supportedEncryptionMethods()
JWEAlgorithmProviderenc JWE header parameter.supportedEncryptionMethods in interface JWEAlgorithmProviderpublic void setProvider(java.security.Provider provider)
AlgorithmProvidersetProvider in interface AlgorithmProviderprovider - The JCA provider, or null to use the default
one.public void setKeyEncryptionProvider(java.security.Provider provider)
JWEAlgorithmProvidersetKeyEncryptionProvider in interface JWEAlgorithmProviderprovider - The JCA provider, or null to use the default
one.public void setContentEncryptionProvider(java.security.Provider provider)
JWEAlgorithmProvidersetContentEncryptionProvider in interface JWEAlgorithmProviderprovider - The JCA provider, or null to use the default
one.public void setMACProvider(java.security.Provider provider)
JWEAlgorithmProvidersetMACProvider in interface JWEAlgorithmProviderprovider - The JCA provider, or null to use the default
one.public void setSecureRandom(java.security.SecureRandom randomGen)
JWEAlgorithmProvidersetSecureRandom in interface JWEAlgorithmProviderrandomGen - The secure random generator, or null to use
the default one.protected java.security.SecureRandom getSecureRandom()
Copyright © 2014 Connect2id Ltd.. All Rights Reserved.