public class KeyStoreHandlerDecorator extends Object implements KeyStoreHandler
KeyStoreHandler
in order to add some commons utility methods to read or write keystore's entries.Constructor and Description |
---|
KeyStoreHandlerDecorator(KeyStoreHandler delegate)
Constructs a new KeyStoreHandlerDecorator.
|
Modifier and Type | Method and Description |
---|---|
String |
getLocation()
Returns the path to the keystore.
|
String |
getPassword()
Returns the password.
|
KeyStore |
getStore()
Get the keystore.
|
String |
getType()
Returns the type of the keystore.
|
PrivateKey |
readPrivateKeyFromKeyStore(String alias)
Get a private key for the alias using the default password from
getPassword() . |
PrivateKey |
readPrivateKeyFromKeyStore(String alias,
String password)
Get the private key with the given alias.
|
PublicKey |
readPublicKeyFromKeyStore(String alias)
Get the public key with the given alias.
|
SecretKey |
readSecretKeyFromKeyStore(String alias)
Get the secret key with the given alias using the default password from
getPassword() . |
SecretKey |
readSecretKeyFromKeyStore(String alias,
String password)
Get the secret key with the given alias.
|
void |
setStore(KeyStore keystore)
Sets the keystore.
|
void |
store()
Saves the keystore.
|
void |
writeToKeyStore(SecretKey secretKey,
String alias)
Writes to the secret storage using the same password than the KeyStoreHandler.
|
void |
writeToKeyStore(SecretKey secretKey,
String alias,
String password)
Writes to the secret storage.
|
public KeyStoreHandlerDecorator(KeyStoreHandler delegate)
delegate
- the KeyStoreHandler to decorate.public void writeToKeyStore(SecretKey secretKey, String alias) throws SecureStorageException
secretKey
- The data to be written to the secret storagealias
- The kind of cryptoMaterial, whether it is a signature or a keySecureStorageException
- if it fails to write secret data from secret storepublic void writeToKeyStore(SecretKey secretKey, String alias, String password) throws SecureStorageException
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 keySecureStorageException
- if it fails to write secret data from secret storepublic PublicKey readPublicKeyFromKeyStore(String alias) throws SecureStorageException
alias
- The alias.SecureStorageException
- If the key could not be read.public PrivateKey readPrivateKeyFromKeyStore(String alias) throws SecureStorageException
getPassword()
.alias
- The alias.SecureStorageException
- If the key could not be read.public PrivateKey readPrivateKeyFromKeyStore(String alias, String password) throws SecureStorageException
alias
- The alias.password
- The password to use to access the keystore.SecureStorageException
- If the key could not be read.public SecretKey readSecretKeyFromKeyStore(String alias) throws SecureStorageException
getPassword()
.alias
- The alias.SecureStorageException
- If the key could not be read.public SecretKey readSecretKeyFromKeyStore(String alias, String password) throws SecureStorageException
alias
- The alias.password
- The password to use to access the keystore.SecureStorageException
- If the key could not be read.public KeyStore getStore()
KeyStoreHandler
getStore
in interface KeyStoreHandler
public void setStore(KeyStore keystore) throws Exception
KeyStoreHandler
setStore
in interface KeyStoreHandler
keystore
- The keystore to useException
- If an error occurspublic String getPassword()
KeyStoreHandler
getPassword
in interface KeyStoreHandler
public String getLocation()
KeyStoreHandler
getLocation
in interface KeyStoreHandler
public String getType()
KeyStoreHandler
getType
in interface KeyStoreHandler
public void store() throws Exception
KeyStoreHandler
store
in interface KeyStoreHandler
Exception
- If an error occurs.Copyright © 2025 Open Identity Platform Community. All rights reserved.