public class KeystoreService extends Object
The service is implemented as a singleton to avoid concurrent access from different clients.
| Modifier and Type | Field and Description |
|---|---|
static String |
ENV_SIGNATURE_KEYSTORE_PASSWORD |
static String |
ENV_SIGNATURE_KEYSTORE_PATH |
static String |
ENV_SIGNATURE_KEYSTORE_TYPE |
| Constructor and Description |
|---|
KeystoreService() |
KeystoreService(String keyStorePath,
String keyStorePassword,
String keyStoreType) |
| Modifier and Type | Method and Description |
|---|---|
Certificate[] |
loadCertificate(String alias)
Loads a certificate chain by a given alias.
|
PrivateKey |
loadPrivateKey(String alias)
Loads a private key by a given alias name with an empty password.
|
PrivateKey |
loadPrivateKey(String alias,
String password)
Loads a private key by a given alias name and password.
|
KeyStore |
openKeyStore()
Open a java keyStore based on the environment variables
SIGNATURE_KEYSTORE_PATH , SIGNATURE_KEYSTORE_TYPE and
SIGNATURE_KEYSTORE_PASSWORD
|
void |
storeCertificate(Certificate[] certificateChain,
PrivateKey privKey,
String password,
String alias)
This method stores the certificate into the keystore.
|
public static final String ENV_SIGNATURE_KEYSTORE_PATH
public static final String ENV_SIGNATURE_KEYSTORE_PASSWORD
public static final String ENV_SIGNATURE_KEYSTORE_TYPE
public KeystoreService(String keyStorePath, String keyStorePassword, String keyStoreType)
public KeystoreService()
public KeyStore openKeyStore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException
public Certificate[] loadCertificate(String alias)
If a certificate for the given alias name does not exist in the keystore than the default alias (SIGNATURE_KEYSTORE_DEFAULT_ALIAS) will be loaded.
The method returns null if no certificate was found!
public PrivateKey loadPrivateKey(String alias, String password)
alias - public PrivateKey loadPrivateKey(String alias)
alias - public void storeCertificate(Certificate[] certificateChain, PrivateKey privKey, String password, String alias) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
certificateChain - - the certificate chain to be storedprivKey - - the associated private keypassword - - optional password to protect the entry, can be nullalias - - alias name to store the entryKeyStoreExceptionIOExceptionCertificateExceptionNoSuchAlgorithmExceptionExceptionCopyright © 2016–2021 Imixs Software Solutions GmbH. All rights reserved.