CompositeKeyStore¶
-
public class
CompositeKeyStore
¶ Composite keystore which manages keystores of different types. A typical Java keystore supports only one keystore type per file. That will be inconvenient for applications to manage several types of keystore. Also, this composite keystore supports managing multiple keystore files. This can be viewed as a keystore registry, that is, this object manages a pool of keystore files.
Author: kcyee
Fields¶
Constructors¶
Methods¶
addKeyStoreFile¶
addKeyStoreFile¶
aliases¶
-
public Enumeration
aliases
()¶ Gets all the aliases of the keystores pointed by this composite keystore.
Returns: an enumeration of string, holding the aliases of the keys
containsAlias¶
getCertificate¶
-
public Certificate
getCertificate
(String alias)¶ Gets the certificate named by the given alias, from the collection of keystores pointed by this composite keystore.
Parameters: - alias – the alias of the key/certificate
Throws: - KeyStoreException – the keystore is corrupted
Returns: the certificate named by the given alias, null if not found
getCertificateAlias¶
-
public String
getCertificateAlias
(Certificate cert)¶ Gets the alias of the specified certificate.
Parameters: - cert – the certificate
Returns: the alias of the certificate, if the certificate can be found in the collection of keystores pointed by this composite keystore. Otherwise, null will be returned
getCertificateChain¶
-
public Certificate[]
getCertificateChain
(String alias)¶ Gets the certificate chain by the specified alias.
Parameters: - alias – the alias of the key/certificate
Throws: - KeyStoreException – the keystore is corrupted
Returns: the certificate chain by the specified alias, null if not found
getCreationDate¶
-
public Date
getCreationDate
(String alias)¶ Gets the creation date of the key/certificate by the specified alias.
Parameters: - alias – the alias of the key/certificate
Throws: - KeyStoreException – the keystore is corrupted
Returns: the creation date of the key/certificate by the specified alias, null if not found
getKey¶
-
public Key
getKey
(String alias, char[] password)¶ Gets the key by the specified alias. A password should be given also to retrieve the key.
Parameters: - alias – the alias of the key/certificate
- password – the password to retrieve the key
Throws: - KeyStoreException – the keystore is corrupted
- NoSuchAlgorithmException – the keystore cannot be read
- UnrecoverableKeyException – the keystore cannot be read
Returns: the key specified by the alias, null if not found
getKeyStore¶
isCertificateEntry¶
isKeyEntry¶
load¶
-
public void
load
(String storeFileName)¶ Loads the composite keystore from a persistent file in the file system.
Parameters: - storeFileName – the name of the composite keystore persistent file
Throws: - InitializationException – the persistent file is corrupted
load¶
-
public void
load
(File storeFile)¶ Loads the composite keystore from a persistent file in the file system.
Parameters: - storeFile – the composite keystore persistent file
Throws: - InitializationException – the persistent file is corrupted
loadCache¶
-
protected void
loadCache
()¶ Loads the keystores pointed by this composite keystore into memory and create a caching of aliases.
loadKeyStore¶
-
protected KeyStore
loadKeyStore
(String fileName, KeyStoreFileProp ksp)¶ Gets an instance of the keystore of correct type. This function will consider the Java version and determine whether to use JSSE or not. For Java version 1.4 or above, JSSE is built in. So, no need to call an external provider to create an instance of PKCS#12 formatted keystore. Otherwise, JSSE should be used, and we make use of dynamic binding to load the JSSE library.
Parameters: - fileName – the keystore file name to load
- ksp – other keystore parameters for loading
Returns: keystore instance of the correct type
removeKeyStoreFile¶
removeKeyStoreFile¶
size¶
-
public int
size
()¶ Gets the total number of keys/certificates in all the keystores pointed by this composite keystore.
Returns: the total number of keys/certificates
store¶
-
public void
store
(String storeFileName)¶ Stores the composite keystore to a persistent file in the file system.
Parameters: - storeFileName – the name of the composite keystore persistent file
Throws: - StoreException – the composite keystore is not successfully stored
store¶
-
public void
store
(File storeFile)¶ Stores the composite keystore to a persistent file in the file system.
Parameters: - storeFile – the composite keystore persistent file
Throws: - StoreException – the composite keystore is not successfully stored