Package org.forgerock.audit.secure
Class KeyStoreHandlerDecorator
java.lang.Object
org.forgerock.audit.secure.KeyStoreHandlerDecorator
- All Implemented Interfaces:
KeyStoreHandler
Decorate a
KeyStoreHandler in order to add some commons utility methods to read or write keystore's entries.-
Constructor Summary
ConstructorsConstructorDescriptionKeyStoreHandlerDecorator(KeyStoreHandler delegate) Constructs a new KeyStoreHandlerDecorator. -
Method Summary
Modifier and TypeMethodDescriptionReturns the path to the keystore.Returns the password.getStore()Get the keystore.getType()Returns the type of the keystore.readPrivateKeyFromKeyStore(String alias) Get a private key for the alias using the default password fromgetPassword().readPrivateKeyFromKeyStore(String alias, String password) Get the private key with the given alias.readPublicKeyFromKeyStore(String alias) Get the public key with the given alias.readSecretKeyFromKeyStore(String alias) Get the secret key with the given alias using the default password fromgetPassword().readSecretKeyFromKeyStore(String alias, String password) Get the secret key with the given alias.voidSets the keystore.voidstore()Saves the keystore.voidwriteToKeyStore(SecretKey secretKey, String alias) Writes to the secret storage using the same password than the KeyStoreHandler.voidwriteToKeyStore(SecretKey secretKey, String alias, String password) Writes to the secret storage.
-
Constructor Details
-
KeyStoreHandlerDecorator
Constructs a new KeyStoreHandlerDecorator.- Parameters:
delegate- the KeyStoreHandler to decorate.
-
-
Method Details
-
writeToKeyStore
Writes to the secret storage using the same password than the KeyStoreHandler.- Parameters:
secretKey- The data to be written to the secret storagealias- The kind of cryptoMaterial, whether it is a signature or a key- Throws:
SecureStorageException- if it fails to write secret data from secret store
-
writeToKeyStore
public void writeToKeyStore(SecretKey secretKey, String alias, String password) throws SecureStorageException Writes to the secret storage.- Parameters:
secretKey- The data to be written to the secret storagealias- The kind of cryptoMaterial, whether it is a signature or a keypassword- The password to read the key- Throws:
SecureStorageException- if it fails to write secret data from secret store
-
readPublicKeyFromKeyStore
Get the public key with the given alias.- Parameters:
alias- The alias.- Returns:
- The key.
- Throws:
SecureStorageException- If the key could not be read.
-
readPrivateKeyFromKeyStore
Get a private key for the alias using the default password fromgetPassword().- Parameters:
alias- The alias.- Returns:
- The key.
- Throws:
SecureStorageException- If the key could not be read.
-
readPrivateKeyFromKeyStore
public PrivateKey readPrivateKeyFromKeyStore(String alias, String password) throws SecureStorageException Get the private key with the given alias.- Parameters:
alias- The alias.password- The password to use to access the keystore.- Returns:
- The key.
- Throws:
SecureStorageException- If the key could not be read.
-
readSecretKeyFromKeyStore
Get the secret key with the given alias using the default password fromgetPassword().- Parameters:
alias- The alias.- Returns:
- The key.
- Throws:
SecureStorageException- If the key could not be read.
-
readSecretKeyFromKeyStore
public SecretKey readSecretKeyFromKeyStore(String alias, String password) throws SecureStorageException Get the secret key with the given alias.- Parameters:
alias- The alias.password- The password to use to access the keystore.- Returns:
- The key.
- Throws:
SecureStorageException- If the key could not be read.
-
getStore
Description copied from interface:KeyStoreHandlerGet the keystore.- Specified by:
getStorein interfaceKeyStoreHandler- Returns:
- the keystore.
-
setStore
Description copied from interface:KeyStoreHandlerSets the keystore.- Specified by:
setStorein interfaceKeyStoreHandler- Parameters:
keystore- The keystore to use- Throws:
Exception- If an error occurs
-
getPassword
Description copied from interface:KeyStoreHandlerReturns the password.- Specified by:
getPasswordin interfaceKeyStoreHandler- Returns:
- the password used to access the keystore
-
getLocation
Description copied from interface:KeyStoreHandlerReturns the path to the keystore.- Specified by:
getLocationin interfaceKeyStoreHandler- Returns:
- the path
-
getType
Description copied from interface:KeyStoreHandlerReturns the type of the keystore.- Specified by:
getTypein interfaceKeyStoreHandler- Returns:
- the keystore type
-
store
Description copied from interface:KeyStoreHandlerSaves the keystore.- Specified by:
storein interfaceKeyStoreHandler- Throws:
Exception- If an error occurs.
-