Package org.forgerock.audit.secure
Class KeyStoreSecureStorage
java.lang.Object
org.forgerock.audit.secure.KeyStoreSecureStorage
- All Implemented Interfaces:
SecureStorage
Implementation of a secure storage using a keystore.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The current key used to calculate the HEADER_HMAC.static final String
The last signature inserted into the file.static final String
The initial key used to calculate the HEADER_HMAC.static final String
The alias to lookup the private/public signature key into the keystore.static final String
The HMAC algorithm to use.static final String
The name of the Java Cryptography Extension KeyStore (JCEKS) type.static final String
The algorithm to use for signing and verifying. -
Constructor Summary
ConstructorDescriptionKeyStoreSecureStorage
(KeyStoreHandler keyStoreHandler, PrivateKey privateKey) Creates the storage with a keystore handler, initialized to verify only.KeyStoreSecureStorage
(KeyStoreHandler keyStoreHandler, PublicKey publicKey) Creates the storage with a keystore handler, initialized to verify only.KeyStoreSecureStorage
(KeyStoreHandler keyStoreHandler, PublicKey publicKey, PrivateKey privateKey) Creates the storage with a keystore handler, initialized to verify only. -
Method Summary
Modifier and TypeMethodDescriptionReturns the password used to access the storage.Reads the current key.Reads the initial key.void
setKeyStoreHandler
(KeyStoreHandler keyStoreHandler) Set the key store handler.byte[]
sign
(byte[] signedData) Signs the provided data.boolean
verify
(byte[] signedData, byte[] signature) Verifies that signed data corresponds to signature.void
writeCurrentKey
(SecretKey key) Writes the current key.void
Writes the current signature key.void
writeInitialKey
(SecretKey key) Writes the initial key.
-
Field Details
-
ENTRY_INITIAL_KEY
The initial key used to calculate the HEADER_HMAC.- See Also:
-
ENTRY_SIGNATURE
The alias to lookup the private/public signature key into the keystore.- See Also:
-
ENTRY_CURRENT_SIGNATURE
The last signature inserted into the file.- See Also:
-
ENTRY_CURRENT_KEY
The current key used to calculate the HEADER_HMAC.- See Also:
-
SIGNATURE_ALGORITHM
The algorithm to use for signing and verifying.- See Also:
-
HMAC_ALGORITHM
The HMAC algorithm to use.- See Also:
-
JCEKS_KEYSTORE_TYPE
The name of the Java Cryptography Extension KeyStore (JCEKS) type.- See Also:
-
-
Constructor Details
-
KeyStoreSecureStorage
Creates the storage with a keystore handler, initialized to verify only.- Parameters:
keyStoreHandler
- Handler of a keystore.privateKey
- The private key used to initialize the signer
-
KeyStoreSecureStorage
Creates the storage with a keystore handler, initialized to verify only.- Parameters:
keyStoreHandler
- Handler of a keystore.publicKey
- The public key used to initialize the verifier
-
KeyStoreSecureStorage
public KeyStoreSecureStorage(KeyStoreHandler keyStoreHandler, PublicKey publicKey, PrivateKey privateKey) Creates the storage with a keystore handler, initialized to verify only.- Parameters:
keyStoreHandler
- Handler of a keystore.publicKey
- The public key used to initialize the verifierprivateKey
- The private key used to initialize the signer
-
-
Method Details
-
setKeyStoreHandler
Set the key store handler.- Parameters:
keyStoreHandler
- The handler.
-
getPassword
Description copied from interface:SecureStorage
Returns the password used to access the storage.- Specified by:
getPassword
in interfaceSecureStorage
- Returns:
- the password
-
readCurrentKey
Description copied from interface:SecureStorage
Reads the current key.- Specified by:
readCurrentKey
in interfaceSecureStorage
- Returns:
- the current key
- Throws:
SecureStorageException
- If an errors occurs.
-
readInitialKey
Description copied from interface:SecureStorage
Reads the initial key.- Specified by:
readInitialKey
in interfaceSecureStorage
- Returns:
- the initial key
- Throws:
SecureStorageException
- If an errors occurs.
-
writeCurrentSignatureKey
Description copied from interface:SecureStorage
Writes the current signature key.- Specified by:
writeCurrentSignatureKey
in interfaceSecureStorage
- Parameters:
key
- The secret key- Throws:
SecureStorageException
- If an errors occurs.
-
writeCurrentKey
Description copied from interface:SecureStorage
Writes the current key.- Specified by:
writeCurrentKey
in interfaceSecureStorage
- Parameters:
key
- the current key- Throws:
SecureStorageException
- If an errors occurs.
-
writeInitialKey
Description copied from interface:SecureStorage
Writes the initial key.- Specified by:
writeInitialKey
in interfaceSecureStorage
- Parameters:
key
- the initial key- Throws:
SecureStorageException
- If an errors occurs.
-
sign
Description copied from interface:SecureStorage
Signs the provided data.- Specified by:
sign
in interfaceSecureStorage
- Parameters:
signedData
- The data to sign.- Returns:
- the signed data
- Throws:
SecureStorageException
- If an error occured during signing process.
-
verify
Description copied from interface:SecureStorage
Verifies that signed data corresponds to signature.- Specified by:
verify
in interfaceSecureStorage
- Parameters:
signedData
- the data to verifysignature
- the signature- Returns:
true
if data corresponds,false
otherwise- Throws:
SecureStorageException
- If an error occured during the verification process.
-