@ThreadSafe public class PasswordBasedEncrypter extends Object implements JWEEncrypter
JWE objects.
Expects a password.
See RFC 7518 section 4.8 for more information.
This class is thread-safe.
Supports the following key management algorithms:
Supports the following content encryption algorithms:
| Modifier and Type | Field and Description |
|---|---|
static int |
MIN_RECOMMENDED_ITERATION_COUNT
The minimum recommended iteration count (1000).
|
static int |
MIN_SALT_LENGTH
The minimum salt length (8 bytes).
|
static Set<JWEAlgorithm> |
SUPPORTED_ALGORITHMS
The supported JWE algorithms by the password-based crypto provider
class.
|
static Set<EncryptionMethod> |
SUPPORTED_ENCRYPTION_METHODS
The supported encryption methods by the password-base crypto
provider class.
|
| Constructor and Description |
|---|
PasswordBasedEncrypter(byte[] password,
int saltLength,
int iterationCount)
Creates a new password-based encrypter.
|
PasswordBasedEncrypter(String password,
int saltLength,
int iterationCount)
Creates a new password-based encrypter.
|
| Modifier and Type | Method and Description |
|---|---|
JWECryptoParts |
encrypt(JWEHeader header,
byte[] clearText)
Encrypts the specified clear text of a
JWE object. |
int |
getIterationCount()
Returns the pseudo-random function (PRF) iteration count.
|
JWEJCAContext |
getJCAContext()
Returns the Java Cryptography Architecture (JCA) context.
|
byte[] |
getPassword()
Returns the password.
|
String |
getPasswordString()
Returns the password.
|
int |
getSaltLength()
Returns the length of the generated cryptographic salts.
|
Set<EncryptionMethod> |
supportedEncryptionMethods()
Returns the names of the supported encryption methods by the JWE
provier.
|
Set<JWEAlgorithm> |
supportedJWEAlgorithms()
Returns the names of the supported algorithms by the JWE provider
instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsupportedEncryptionMethods, supportedJWEAlgorithmsgetJCAContextpublic static final int MIN_SALT_LENGTH
public static final int MIN_RECOMMENDED_ITERATION_COUNT
public static final Set<JWEAlgorithm> SUPPORTED_ALGORITHMS
public static final Set<EncryptionMethod> SUPPORTED_ENCRYPTION_METHODS
public PasswordBasedEncrypter(byte[] password, int saltLength, int iterationCount)
password - The password bytes. Must not be empty or
null.saltLength - The length of the generated cryptographic
salts, in bytes. Must be at least 8 bytes.iterationCount - The pseudo-random function (PRF) iteration
count. Must be at least 1000.public PasswordBasedEncrypter(String password, int saltLength, int iterationCount)
password - The password, as a UTF-8 encoded string. Must
not be empty or null.saltLength - The length of the generated cryptographic
salts, in bytes. Must be at least 8 bytes.iterationCount - The pseudo-random function (PRF) iteration
count. Must be at least 1000.public JWECryptoParts encrypt(JWEHeader header, byte[] clearText) throws JOSEException
JWEEncrypterJWE object.encrypt in interface JWEEncrypterheader - The JSON Web Encryption (JWE) header. Must specify
a supported JWE algorithm and method. Must not be
null.clearText - The clear text to encrypt. Must not be null.JOSEException - If the JWE algorithm or method is not
supported or if encryption failed for some
other internal reason.public int getSaltLength()
public int getIterationCount()
public byte[] getPassword()
public String getPasswordString()
public Set<JWEAlgorithm> supportedJWEAlgorithms()
JWEProvideralg JWE header parameter.supportedJWEAlgorithms in interface JWEProviderpublic Set<EncryptionMethod> supportedEncryptionMethods()
JWEProviderenc JWE header parameter.supportedEncryptionMethods in interface JWEProviderpublic JWEJCAContext getJCAContext()
JCAAwaregetJCAContext in interface JCAAware<JWEJCAContext>null.Copyright © 2018 Connect2id Ltd.. All rights reserved.