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 and Description
    --- | ---
    `static class` | `CertificateContainer.CertificateChange`
    `class` | `CertificateContainer.CertificateChanged`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PER_DOMAIN_CERTIFICATE_KEY`
    `static String` | `SNI_DISABLE_KEY`

    - ### Fields inherited from interface tigase.io.CertificateContainerIfc

      `CERTIFICATE_CONTAINER_CLASS_KEY, CERTIFICATE_CONTAINER_CLASS_VAL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CertificateContainer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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` | `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.

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

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

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

  - ### Constructor Detail

    - #### CertificateContainer

          public CertificateContainer()

  - ### Method Detail

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

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

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

Copyright © 2004–2021 "Tigase, Inc.". All rights reserved.