public class AMKeyProvider extends Object implements KeyProvider
KeyProvider interface for retrieving X509 Certificates and private
keys from the user data store.| Constructor and Description |
|---|
AMKeyProvider()
Constructor.
|
AMKeyProvider(boolean alreadyResolved,
String keyStoreFile,
String keyStorePass,
String keyStoreType,
String privateKeyPass)
Constructor.
|
AMKeyProvider(KeyStoreConfig kc)
Create a new instance of AMKeyProvider from a KeyStoreConfiguration object.
|
AMKeyProvider(String keyStoreFilePropName,
String keyStorePassFilePropName,
String keyStoreTypePropName,
String privateKeyPassFilePropName)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(String alias)
Whether the key alias exists in the keystore.
|
static String |
decodePassword(String password)
Decodes the given password and returns it.
|
Certificate |
getCertificate(PublicKey publicKey)
Return Certificate for the specified PublicKey.
|
Certificate |
getCertificate(String certAlias)
Get the Certificate named certAlias.
|
String |
getCertificateAlias(Certificate cert)
Get the alias name of the first keystore entry whose certificate matches
the given certificate.
|
KeyPair |
getKeyPair(String certAlias)
|
String |
getKeyPasswordFilePath()
Get the .keypass path.
|
KeyStore |
getKeyStore()
Get the keystore.
|
String |
getKeystoreFilePath()
Gets the Keystore File path.
|
char[] |
getKeystorePass()
Gets the Keystore password.
|
String |
getKeystorePasswordFilePath()
Get the storepass path.
|
String |
getKeystoreType()
Gets the Keystore type.
|
PrivateKey |
getPrivateKey(String certAlias)
Return java.security.PrivateKey for the specified certAlias.
|
PrivateKey |
getPrivateKey(String certAlias,
String encryptedKeyPass)
Return the
PrivateKey for the specified certAlias and encrypted private key password. |
String |
getPrivateKeyPass()
Get the private key password.
|
PublicKey |
getPublicKey(String keyAlias)
Return java.security.PublicKey for the specified keyAlias.
|
String |
getSecret(String alias)
Retrieve store secret (usually a password).
|
SecretKey |
getSecretKey(String certAlias)
Retrieves the secret key for the given certificate alias.
|
X509Certificate |
getX509Certificate(String certAlias)
Return java.security.cert.X509Certificate for the specified certAlias.
|
protected String |
readPasswordFile(String filePath)
Read a keystore password file (example: .storepass / .keypass ).
|
void |
setCertificateEntry(String certAlias,
Certificate cert)
Set the Certificate with name certAlias in the keystore.
|
void |
setKey(String storepass,
String keypass)
Set the key to access key store database.
|
void |
setLogger(Debug logger)
Sets the debug logger.
|
void |
setSecretKeyEntry(String alias,
String password)
Store a secret (typically a password) in the keystore
The secret is protected with the same password as the keystore itself.
|
void |
store()
Store the keystore changes.
|
public AMKeyProvider()
public AMKeyProvider(KeyStoreConfig kc) throws KeyStoreException, IOException
kc - The KeyStore configurationKeyStoreException - if the keystore could not be opened or initializedIOException - If the storepass or keypass files could not be openedpublic AMKeyProvider(String keyStoreFilePropName, String keyStorePassFilePropName, String keyStoreTypePropName, String privateKeyPassFilePropName)
keyStoreFilePropName - The key store file property name.keyStorePassFilePropName - The key store password property name.keyStoreTypePropName - The key store type property name.privateKeyPassFilePropName - The key store private key password property name.public AMKeyProvider(boolean alreadyResolved,
String keyStoreFile,
String keyStorePass,
String keyStoreType,
String privateKeyPass)
alreadyResolved - true if already resolved.keyStoreFile - The key store file.keyStorePass - The key store password.keyStoreType - The key store type.privateKeyPass - The key store private key password.protected String readPasswordFile(String filePath)
filePath - Path to the password filepublic static String decodePassword(String password)
password - The password that requires decoding.public void setLogger(Debug logger)
logger - The debug logger.public void setKey(String storepass, String keypass)
setKey in interface KeyProviderstorepass - password for the key storekeypass - password for the certificatepublic X509Certificate getX509Certificate(String certAlias)
getX509Certificate in interface KeyProvidercertAlias - Certificate alias namepublic PublicKey getPublicKey(String keyAlias)
getPublicKey in interface KeyProviderkeyAlias - Key alias namepublic PrivateKey getPrivateKey(String certAlias)
getPrivateKey in interface KeyProvidercertAlias - Certificate alias namepublic SecretKey getSecretKey(String certAlias)
KeyProvidergetSecretKey in interface KeyProvidercertAlias - the certificate alieaspublic PrivateKey getPrivateKey(String certAlias, String encryptedKeyPass)
PrivateKey for the specified certAlias and encrypted private key password.getPrivateKey in interface KeyProvidercertAlias - Certificate alias nameencryptedKeyPass - The encrypted key password to use when getting the private certificatepublic KeyPair getKeyPair(String certAlias)
certAlias - Certificate alias namepublic String getCertificateAlias(Certificate cert)
getCertificateAlias in interface KeyProvidercert - Certificatepublic char[] getKeystorePass()
public String getPrivateKeyPass()
public String getKeystoreType()
public String getKeystoreFilePath()
public String getKeystorePasswordFilePath()
public String getKeyPasswordFilePath()
public KeyStore getKeyStore()
getKeyStore in interface KeyProviderpublic void setCertificateEntry(String certAlias, Certificate cert) throws KeyStoreException
certAlias - Certificate's name Aliascert - CertificateKeyStoreException - If an error occurs when setting the certificate entry.public Certificate getCertificate(String certAlias)
certAlias - Certificate's name Aliaspublic void store()
throws IOException,
CertificateException,
NoSuchAlgorithmException,
KeyStoreException
IOException - If an error occurs when saving the keystore.CertificateException - If an error occurs when saving the keystore.NoSuchAlgorithmException - If an error occurs when saving the keystore.KeyStoreException - If an error occurs when saving the keystore.public Certificate getCertificate(PublicKey publicKey)
getCertificate in interface KeyProviderpublicKey - Certificate public keypublic boolean containsKey(String alias)
KeyProvidercontainsKey in interface KeyProvideralias - the key aliaspublic void setSecretKeyEntry(String alias, String password) throws KeyStoreException
alias - - the alias to store the password underpassword - - password or secret to storeKeyStoreException - if the password can not be stored in the keystorepublic String getSecret(String alias) throws KeyStoreException
alias - the alias of the secretKeyStoreException - if the password can not be readCopyright © 2010–2023 Open Identity Platform Community. All rights reserved.