public final class KeyStoreManager extends Object implements ESKeyStoreManager
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CERTIFICATE
Certificate Alias for development test certificate.
|
static String |
KEYSTORENAME
Name of keyStore file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificate(String alias,
InputStream certificate)
Adds a certificate to the KeyStore.
|
void |
addCertificate(String alias,
String path)
Adds a certificate to the KeyStore.
|
boolean |
certificateExists(String alias)
Checks whether a certificate for a given alias exists.
|
boolean |
contains(String alias)
Returns true if the given alias maps to an existing certificate.
|
void |
deleteCertificate(String alias)
Deletes a certificate in the keystore.
|
String |
encrypt(String password,
ServerInfo server)
Encrypts a password.
|
Certificate |
getCertificate(String alias)
Returns the certificate mapped by the given alias.
|
ArrayList<String> |
getCertificates()
Lists all certificates in the client's KeyStore.
|
String |
getDefaultCertificate()
Returns the default certificate alias.
|
static KeyStoreManager |
getInstance()
Returns an instance of the
KeyStoreManager. |
String |
getPathToKeyStore()
Returns the path to the KeyStore.
|
SSLContext |
getSSLContext()
Returns a SSL Context.
|
boolean |
isDefaultCertificate(String alias)
Test whether a given alias is the default certificate alias.
|
boolean |
keyStoreExists()
True if a KeyStore file exists.
|
void |
reloadKeyStore()
Reloads the keystore.
|
void |
removeCertificate(String alias)
Remove certificate with the given alias.
|
void |
setDefaultCertificate(String defaultCertificate)
Sets the alias for the default certificate.
|
void |
setupKeys()
This method sets the JVM properties in order to use SSL encryption.
|
public static final String KEYSTORENAME
public static final String DEFAULT_CERTIFICATE
public static KeyStoreManager getInstance()
KeyStoreManager.KeyStoreManagerpublic void setupKeys()
public ArrayList<String> getCertificates() throws ESCertificateException
ESCertificateException - is thrown when problems occur with the CertificateStore, i.e.
illegal operations.public void deleteCertificate(String alias) throws ESCertificateException
alias - alias of certificateESCertificateException - is thrown when problems occur with the CertificateStore, i.e.
illegal operations.public void addCertificate(String alias, String path) throws ESCertificateException
addCertificate in interface ESKeyStoreManageralias - alias for the certificatepath - path to the certificate fileESCertificateException - if problems occur with storing, accessing or identifying the certificateESKeyStoreManager.addCertificate(java.lang.String,
java.lang.String)public void removeCertificate(String alias) throws ESCertificateException
alias - the certificate aliasESCertificateException - if removal failspublic void addCertificate(String alias, InputStream certificate) throws ESCertificateException
addCertificate in interface ESKeyStoreManageralias - alias for the certificatecertificate - InputStream delivering the certificate. Stream is used by
CertificateFactory.generateCertificate(InputStream).ESCertificateException - if problems occur with storing, accessing or identifying the certificateESKeyStoreManager.addCertificate(java.lang.String,
java.io.InputStream)public void reloadKeyStore()
throws ESCertificateException
ESCertificateException - in case of failurepublic SSLContext getSSLContext() throws ESCertificateException
ESCertificateException - in case of failure retrieving the contextpublic boolean keyStoreExists()
public String getPathToKeyStore()
public String encrypt(String password, ServerInfo server)
password - the password to be encryptedserver - the server from which to fetch the public key that is used for encryptionpublic boolean isDefaultCertificate(String alias)
alias - alias under testpublic String getDefaultCertificate()
getDefaultCertificate in interface ESKeyStoreManagerESKeyStoreManager.getDefaultCertificate()public boolean contains(String alias) throws ESCertificateException
alias - Certificate aliasESCertificateException - is thrown when problems occur with the CertificateStore, i.e.
illegal operations.public void setDefaultCertificate(String defaultCertificate)
setDefaultCertificate in interface ESKeyStoreManagerdefaultCertificate - certificate alias, use null to unset the currently set default certificateESKeyStoreManager.setDefaultCertificate(java.lang.String)public Certificate getCertificate(String alias) throws ESCertificateException
alias - StringESCertificateException - is thrown when problems occur with the CertificateStore, i.e.
illegal operations.public boolean certificateExists(String alias) throws ESCertificateException
certificateExists in interface ESKeyStoreManageralias - the alias which needs to be checktrue if a certificate with the given alias exists, false otherwiseESCertificateException - in case of failureESKeyStoreManager.certificateExists(java.lang.String)Copyright © 2017. All rights reserved.