Class CertificateStore
- java.lang.Object
-
- org.jivesoftware.openfire.keystore.CertificateStore
-
- Direct Known Subclasses:
IdentityStore
,TrustStore
public abstract class CertificateStore extends Object
A wrapper class for a Java store of certificates, its metadata (password, location) and related functionality. A subclass of this class exists for each of the two distinct types of key store.- one that is used to provide credentials, an identity store, in
IdentityStore
- one that is used to verify credentials, a trust store, in
TrustStore
- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description protected CertificateStoreConfiguration
configuration
protected static Provider
PROVIDER
protected KeyStore
store
-
Constructor Summary
Constructors Constructor Description CertificateStore(CertificateStoreConfiguration configuration, boolean createIfAbsent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Path
backup()
Copies the file that is the persistent storage for this store to a new file in the backup location.void
delete(String alias)
Deletes an entry (by entry) in this store.Map<String,X509Certificate>
getAllCertificates()
Returns a collection of all x.509 certificates in this store.CertificateStoreConfiguration
getConfiguration()
KeyStore
getStore()
void
persist()
Saves the current state of the store to disk.void
reload()
Reloads the content of the store from disk.
-
-
-
Field Detail
-
PROVIDER
protected static final Provider PROVIDER
-
store
protected final KeyStore store
-
configuration
protected final CertificateStoreConfiguration configuration
-
-
Constructor Detail
-
CertificateStore
public CertificateStore(CertificateStoreConfiguration configuration, boolean createIfAbsent) throws CertificateStoreConfigException
- Throws:
CertificateStoreConfigException
-
-
Method Detail
-
reload
public void reload() throws CertificateStoreConfigException
Reloads the content of the store from disk. Useful when the store content has been modified outside of the Openfire process, or when changes that have not been persisted need to be undone.- Throws:
CertificateStoreConfigException
- if the store could not be reloaded
-
persist
public void persist() throws CertificateStoreConfigException
Saves the current state of the store to disk. Useful when certificates have been added or removed from the store.- Throws:
CertificateStoreConfigException
- of the configuration could not be persisted
-
backup
public Path backup()
Copies the file that is the persistent storage for this store to a new file in the backup location.- Returns:
- The path in which the backup was created, or null if the creation of the backup failed.
-
getAllCertificates
public Map<String,X509Certificate> getAllCertificates() throws KeyStoreException
Returns a collection of all x.509 certificates in this store. Certificates returned by this method can be of any state (eg: invalid, on a revocation list, etc).- Returns:
- A collection (possibly empty, never null) of all certificates in this store, mapped by their alias.
- Throws:
KeyStoreException
- if a keystore has not been initialized
-
delete
public void delete(String alias) throws CertificateStoreConfigException
Deletes an entry (by entry) in this store. All information related to this entry will be removed, including certificates and keys. When the store does not contain an entry that matches the provided alias, this method does nothing.- Parameters:
alias
- The alias for which to delete an entry (cannot be null or empty).- Throws:
CertificateStoreConfigException
- if the entry could not be deleted
-
getStore
public KeyStore getStore()
-
getConfiguration
public CertificateStoreConfiguration getConfiguration()
-
-