Package com.codedx.security
Class SingleCertManager
- java.lang.Object
-
- com.codedx.security.SingleCertManager
-
- All Implemented Interfaces:
ExtraCertManager
public class SingleCertManager extends Object implements ExtraCertManager
ExtraCertManager implementation that only allows a single accepted certificate at once. Any time a certificate is added (be it temporarily or permanently), any previous certificates will be forgotten. At any given time, theasKeyStore()method should return a KeyStore with 0 or 1 certificates registered.
-
-
Constructor Summary
Constructors Constructor Description SingleCertManager(String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPermanentCert(Certificate cert)Add a certificate that will be accepted until this manager is "purged".voidaddTemporaryCert(Certificate cert)Add a certificate that will be accepted until some event (as determined by the implementation of this interface) occurs, causing it to be "forgotten".KeyStoreasKeyStore()Return a representation of this manager as a KeyStore instance.voidpurgeAllCerts()Remove all certificates that have been added either byExtraCertManager.addTemporaryCert(Certificate)orExtraCertManager.addPermanentCert(Certificate).voidpurgePermanentCerts()Remove all certificates that have been added viaExtraCertManager.addPermanentCert(Certificate).voidpurgeTemporaryCerts()Remove all certificates that have been added viaExtraCertManager.addTemporaryCert(Certificate).
-
-
-
Constructor Detail
-
SingleCertManager
public SingleCertManager(String password)
-
-
Method Detail
-
addTemporaryCert
public void addTemporaryCert(Certificate cert)
Description copied from interface:ExtraCertManagerAdd a certificate that will be accepted until some event (as determined by the implementation of this interface) occurs, causing it to be "forgotten".- Specified by:
addTemporaryCertin interfaceExtraCertManager- Parameters:
cert- The certificate to add
-
addPermanentCert
public void addPermanentCert(Certificate cert) throws IOException, GeneralSecurityException
Description copied from interface:ExtraCertManagerAdd a certificate that will be accepted until this manager is "purged". Certificates added in this way will generally be written to disk, and will be available upon restarting the program.- Specified by:
addPermanentCertin interfaceExtraCertManager- Parameters:
cert- The certificate to add- Throws:
IOException- if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrectGeneralSecurityException- if there is a problem reading/writing data within the keystore
-
purgeTemporaryCerts
public void purgeTemporaryCerts()
Description copied from interface:ExtraCertManagerRemove all certificates that have been added viaExtraCertManager.addTemporaryCert(Certificate).- Specified by:
purgeTemporaryCertsin interfaceExtraCertManager
-
purgePermanentCerts
public void purgePermanentCerts()
Description copied from interface:ExtraCertManagerRemove all certificates that have been added viaExtraCertManager.addPermanentCert(Certificate).- Specified by:
purgePermanentCertsin interfaceExtraCertManager
-
purgeAllCerts
public void purgeAllCerts()
Description copied from interface:ExtraCertManagerRemove all certificates that have been added either byExtraCertManager.addTemporaryCert(Certificate)orExtraCertManager.addPermanentCert(Certificate).- Specified by:
purgeAllCertsin interfaceExtraCertManager
-
asKeyStore
public KeyStore asKeyStore() throws GeneralSecurityException
Description copied from interface:ExtraCertManagerReturn a representation of this manager as a KeyStore instance.- Specified by:
asKeyStorein interfaceExtraCertManager- Returns:
- A new KeyStore that represents the contents of this certificate manager
- Throws:
GeneralSecurityException- if there is a problem reading/writing data within the keystore
-
-