Package tigase.io
Class CertificateContainer
- java.lang.Object
-
- tigase.io.CertificateContainer
-
- All Implemented Interfaces:
CertificateContainerIfc,Initializable,UnregisterAware
@Bean(name="certificate-container", parent=Kernel.class, active=true, exportable=true) public class CertificateContainer extends Object implements CertificateContainerIfc, Initializable, UnregisterAware
Class used to keep SSL certificates loaded in memory. To get instance use getter from TLSUtil class.
Created by andrzej on 29.02.2016.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCertificateContainer.CertificateChangeclassCertificateContainer.CertificateChanged
-
Field Summary
Fields Modifier and Type Field Description static StringPER_DOMAIN_CERTIFICATE_KEYstatic StringSNI_DISABLE_KEY-
Fields inherited from interface tigase.io.CertificateContainerIfc
CERTIFICATE_CONTAINER_CLASS_KEY, CERTIFICATE_CONTAINER_CLASS_VAL
-
-
Constructor Summary
Constructors Constructor Description CertificateContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCertificates(Map<String,String> params)MethodaddCertificatesallows to add more certificates at run time after the container has bee already initialized.voidbeforeUnregister()Method called before bean unregister.voidcertificateChange(CertificateContainer.CertificateChange event)KeyManager[]createCertificate(String alias)MethodcreateCertificateallows to generate self-signed certificate for passed domain name.sCertificateEntrygetCertificateEntry(String hostname)StringgetDefCertAlias()Method to retrieve default alias of certificate to use when domain isnullKeyManager[]getKeyManagers(String hostname)Method returns array ofKeyManagerwith certificate for domain ornullif there is no certificate for domainTrustManager[]getTrustManagers()KeyStoregetTrustStore()voidinit(Map<String,Object> params)Method used to pass parameters to initialize instance of classvoidinitialize()Method will be called, when bean will be created, configured and ready to use.
-
-
-
Field Detail
-
PER_DOMAIN_CERTIFICATE_KEY
public static final String PER_DOMAIN_CERTIFICATE_KEY
- See Also:
- Constant Field Values
-
SNI_DISABLE_KEY
public static final String SNI_DISABLE_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
addCertificates
public void addCertificates(Map<String,String> params) throws CertificateParsingException
Description copied from interface:CertificateContainerIfcMethodaddCertificatesallows to add more certificates at run time after the container has bee already initialized. This is to avoid server restart if there are certificates updates or new certificates for new virtual domain. The method should add new certificates or replace existing one if there is already a certificate for a domain.- Specified by:
addCertificatesin interfaceCertificateContainerIfc- Parameters:
params- aMapvalue with configuration parameters.- Throws:
CertificateParsingException
-
createCertificate
public KeyManager[] createCertificate(String alias) throws NoSuchAlgorithmException, CertificateException, SignatureException, NoSuchProviderException, InvalidKeyException, IOException, UnrecoverableKeyException, KeyStoreException
Description copied from interface:CertificateContainerIfcMethodcreateCertificateallows to generate self-signed certificate for passed domain name.s- Specified by:
createCertificatein interfaceCertificateContainerIfc- Parameters:
alias- domain for which certificate should be generated- Returns:
- an array of
KeyManagercontaining generated certificate - Throws:
NoSuchAlgorithmExceptionCertificateExceptionSignatureExceptionNoSuchProviderExceptionInvalidKeyExceptionIOExceptionUnrecoverableKeyExceptionKeyStoreException
-
getDefCertAlias
public String getDefCertAlias()
Description copied from interface:CertificateContainerIfcMethod to retrieve default alias of certificate to use when domain isnull- Specified by:
getDefCertAliasin interfaceCertificateContainerIfc- Returns:
- default alias
-
getCertificateEntry
public CertificateEntry getCertificateEntry(String hostname)
- Specified by:
getCertificateEntryin interfaceCertificateContainerIfc
-
getKeyManagers
public KeyManager[] getKeyManagers(String hostname)
Description copied from interface:CertificateContainerIfcMethod returns array ofKeyManagerwith certificate for domain ornullif there is no certificate for domain- Specified by:
getKeyManagersin interfaceCertificateContainerIfc- Returns:
-
getTrustManagers
public TrustManager[] getTrustManagers()
- Specified by:
getTrustManagersin interfaceCertificateContainerIfc
-
getTrustStore
public KeyStore getTrustStore()
- Specified by:
getTrustStorein interfaceCertificateContainerIfc
-
init
public void init(Map<String,Object> params)
Description copied from interface:CertificateContainerIfcMethod used to pass parameters to initialize instance of class- Specified by:
initin interfaceCertificateContainerIfc
-
initialize
public void initialize()
Description copied from interface:InitializableMethod will be called, when bean will be created, configured and ready to use.- Specified by:
initializein interfaceInitializable
-
beforeUnregister
public void beforeUnregister()
Description copied from interface:UnregisterAwareMethod called before bean unregister.- Specified by:
beforeUnregisterin interfaceUnregisterAware
-
certificateChange
@HandleEvent public void certificateChange(CertificateContainer.CertificateChange event)
-
-