Package tigase.io

# Class CertificateContainer

java.lang.Object
tigase.io.CertificateContainer

All Implemented Interfaces:
  `RepositoryChangeListenerIfc<CertificateItem>`, `CertificateContainerIfc`, `Initializable`, `RegistrarBean`, `UnregisterAware`

@Bean(name="certificate-container", parent=Kernel.class, active=true, exportable=true) public class CertificateContainer extends Object implements CertificateContainerIfc, Initializable, UnregisterAware, RegistrarBean, RepositoryChangeListenerIfc<CertificateItem>
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 class`
  `CertificateContainer.CertificateChange`
  Event indicating certificate change that will be distributed in the cluster.
  `class`
  `CertificateContainer.CertificateChanged`

  ## Nested classes/interfaces inherited from interface tigase.io.CertificateContainerIfc

  `CertificateContainerIfc.CertificateEntity`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `PER_DOMAIN_CERTIFICATE_KEY`
  `static final String`
  `SNI_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

  Modifier and Type
  Method
  Description
  `void`
  `addCertificates(Map<String,String> params)`
  Method `addCertificates` allows to add more certificates at run time after the container has bee already initialized.
  `void`
  `addCertificates(CertificateContainerIfc.CertificateEntity certificateEntity)`
  `void`
  `beforeUnregister()`
  Method called before bean unregister.
  `void`
  `certificateChange(CertificateContainer.CertificateChange event)`
  `KeyManager[]`
  `createCertificate(String alias)`
  Method `createCertificate` allows to generate self-signed certificate for passed domain name.s
  `CertificateEntry`
  `getCertificateEntry(String hostname)`
  `String`
  `getDefCertAlias()`
  Method to retrieve default alias of certificate to use when domain is `null`
  `KeyManager[]`
  `getKeyManagers(String hostname)`
  Method returns array of `KeyManager` with certificate for domain or `null` if there is no certificate for domain
  `TrustManager[]`
  `getTrustManagers()`
  `KeyStore`
  `getTrustStore()`
  `void`
  `init(Map<String,Object> params)`
  Method used to pass parameters to initialize instance of class
  `void`
  `initialize()`
  Method will be called, when bean will be created, configured and ready to use.
  `void`
  `itemAdded(CertificateItem item)`
  `void`
  `itemRemoved(CertificateItem item)`
  `void`
  `itemUpdated(CertificateItem item)`
  `void`
  `register(Kernel kernel)`
  Method called when bean is being registered allowing developer to programatically register other beans.
  `void`
  `setRepository(CertificateRepository repository)`
  `void`
  `unregister(Kernel kernel)`
  Method called while bean is being unregistered.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### 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

- ## Constructor Details

  - ### CertificateContainer

    public CertificateContainer()

- ## Method Details

  - ### setRepository

    public void setRepository(CertificateRepository repository)

  - ### addCertificates

    public void addCertificates(Map<String,String> params) throws CertificateParsingException
    Description copied from interface: `CertificateContainerIfc`
    Method `addCertificates` allows 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:
      `addCertificates` in interface `CertificateContainerIfc`
    Parameters:
      `params` - a `Map` value with configuration parameters.
    Throws:
      `CertificateParsingException`

  - ### addCertificates

    public void addCertificates(CertificateContainerIfc.CertificateEntity certificateEntity) throws CertificateParsingException
    Specified by:
      `addCertificates` in interface `CertificateContainerIfc`
    Throws:
      `CertificateParsingException`

  - ### createCertificate

    public KeyManager[] createCertificate(String alias) throws NoSuchAlgorithmException, CertificateException, SignatureException, NoSuchProviderException, InvalidKeyException, IOException, UnrecoverableKeyException, KeyStoreException
    Description copied from interface: `CertificateContainerIfc`
    Method `createCertificate` allows to generate self-signed certificate for passed domain name.s
    Specified by:
      `createCertificate` in interface `CertificateContainerIfc`
    Parameters:
      `alias` - domain for which certificate should be generated
    Returns:
      an array of `KeyManager` containing generated certificate
    Throws:
      `NoSuchAlgorithmException`
      `CertificateException`
      `SignatureException`
      `NoSuchProviderException`
      `InvalidKeyException`
      `IOException`
      `UnrecoverableKeyException`
      `KeyStoreException`

  - ### getDefCertAlias

    public String getDefCertAlias()
    Description copied from interface: `CertificateContainerIfc`
    Method to retrieve default alias of certificate to use when domain is `null`
    Specified by:
      `getDefCertAlias` in interface `CertificateContainerIfc`
    Returns:
      default alias

  - ### getCertificateEntry

    public CertificateEntry getCertificateEntry(String hostname)
    Specified by:
      `getCertificateEntry` in interface `CertificateContainerIfc`

  - ### getKeyManagers

    public KeyManager[] getKeyManagers(String hostname)
    Description copied from interface: `CertificateContainerIfc`
    Method returns array of `KeyManager` with certificate for domain or `null` if there is no certificate for domain
    Specified by:
      `getKeyManagers` in interface `CertificateContainerIfc`

  - ### getTrustManagers

    public TrustManager[] getTrustManagers()
    Specified by:
      `getTrustManagers` in interface `CertificateContainerIfc`

  - ### getTrustStore

    public KeyStore getTrustStore()
    Specified by:
      `getTrustStore` in interface `CertificateContainerIfc`

  - ### init

    public void init(Map<String,Object> params)
    Description copied from interface: `CertificateContainerIfc`
    Method used to pass parameters to initialize instance of class
    Specified by:
      `init` in interface `CertificateContainerIfc`

  - ### itemAdded

    public void itemAdded(CertificateItem item)
    Specified by:
      `itemAdded` in interface `RepositoryChangeListenerIfc<CertificateItem>`

  - ### itemUpdated

    public void itemUpdated(CertificateItem item)
    Specified by:
      `itemUpdated` in interface `RepositoryChangeListenerIfc<CertificateItem>`

  - ### itemRemoved

    public void itemRemoved(CertificateItem item)
    Specified by:
      `itemRemoved` in interface `RepositoryChangeListenerIfc<CertificateItem>`

  - ### initialize

    public void initialize()
    Description copied from interface: `Initializable`
    Method will be called, when bean will be created, configured and ready to use.
    Specified by:
      `initialize` in interface `Initializable`

  - ### beforeUnregister

    public void beforeUnregister()
    Description copied from interface: `UnregisterAware`
    Method called before bean unregister.
    Specified by:
      `beforeUnregister` in interface `UnregisterAware`

  - ### certificateChange

    @HandleEvent public void certificateChange(CertificateContainer.CertificateChange event)

  - ### register

    public void register(Kernel kernel)
    Description copied from interface: `RegistrarBean`
    Method called when bean is being registered allowing developer to programatically register other beans.
    Specified by:
      `register` in interface `RegistrarBean`
    Parameters:
      `kernel` - - instance from local scope

  - ### unregister

    public void unregister(Kernel kernel)
    Description copied from interface: `RegistrarBean`
    Method called while bean is being unregistered.
    Specified by:
      `unregister` in interface `RegistrarBean`
    Parameters:
      `kernel` - - instance from local scope