Package org.forgerock.secrets.keys
Class KeyEncryptionKey
- java.lang.Object
-
- org.forgerock.secrets.Secret
-
- org.forgerock.secrets.keys.CryptoKey
-
- org.forgerock.secrets.keys.KeyEncryptionKey
-
- All Implemented Interfaces:
AutoCloseable
,EncryptionKey<KeyEncryptionKey>
public class KeyEncryptionKey extends CryptoKey implements EncryptionKey<KeyEncryptionKey>
A key that is used to encrypt ("wrap") other keys.
-
-
Constructor Summary
Constructors Constructor Description KeyEncryptionKey(SecretBuilder builder)
Initialises the key with the given secret data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyEncryptionKey
asCryptoKey()
Returns the same object as a specificCryptoKey
subclass.Cipher
getCipher()
Returns an initialized cipher object for an appropriate default algorithm and parameters.Cipher
getCipher(String algorithm)
Returns an initialized cipher object with default parameters.Cipher
getCipher(String algorithm, AlgorithmParameters parameters)
Returns an initialized cipher object for the given algorithm and parameters.Cipher
getCipher(String algorithm, AlgorithmParameterSpec parameterSpec)
Returns an initialized cipher object for the given algorithm and parameters.-
Methods inherited from class org.forgerock.secrets.keys.CryptoKey
allowsAlgorithm, close, export, getCertificate, getCertificate, getCertificateChain, getCertificateChain, getKeyAlgorithm, getKeyType, getKeyUsages, getPublicKey, getPublicKey, isClosed, isExtractable, reveal, revealAndClose, toBuilder, toString
-
Methods inherited from class org.forgerock.secrets.Secret
equals, getExpiryTime, getStableId, hashCode, isExpired
-
-
-
-
Constructor Detail
-
KeyEncryptionKey
public KeyEncryptionKey(SecretBuilder builder) throws NoSuchSecretException
Initialises the key with the given secret data.- Parameters:
builder
- the builder object.- Throws:
NoSuchSecretException
- if the raw secret cannot be extracted.
-
-
Method Detail
-
getCipher
public Cipher getCipher()
Returns an initialized cipher object for an appropriate default algorithm and parameters. A best-effort attempt will be made to pick a strong cipher algorithm based on the type of key.- Returns:
- the initialized cipher object.
-
asCryptoKey
public KeyEncryptionKey asCryptoKey()
Description copied from interface:EncryptionKey
Returns the same object as a specificCryptoKey
subclass.- Specified by:
asCryptoKey
in interfaceEncryptionKey<KeyEncryptionKey>
- Returns:
- the same key as a CryptoKey.
-
getCipher
public Cipher getCipher(String algorithm, AlgorithmParameterSpec parameterSpec)
Returns an initialized cipher object for the given algorithm and parameters.- Parameters:
algorithm
- the cipher algorithm.parameterSpec
- the parameters to initialise the cipher with.- Returns:
- the initialized cipher object.
-
getCipher
public Cipher getCipher(String algorithm, AlgorithmParameters parameters)
Returns an initialized cipher object for the given algorithm and parameters.- Parameters:
algorithm
- the cipher algorithm.parameters
- the parameters to initialise the cipher with.- Returns:
- the initialized cipher object.
-
-