com.h3c.nbio

## Class SecureContextFactory

- java.lang.Object
- - com.h3c.nbio.SecureContextFactory

-     public class SecureContextFactory
      extends Object

  A factory for creating `SSLContext`s for TLS connections.

  During construction, the factory attempts to create and initialize an `SSLContext` for the given `SecurityContext`. Any exceptions encountered along the way will be logged and captured. The state of the factory can be examined with `hasErrors()`, and the captured exceptions examined with `getErrors()`. Assuming all went well, the `SSLContext` will be available via `secureContext()`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SecureContextFactory(SecurityContext context)` Creates a secure context factory that generates an `SSLContext` for the given security context.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<Exception>` | `getErrors()` Returns the exceptions that were caught and logged during construction.
    `boolean` | `hasErrors()` Returns `true` if any exceptions were caught and logged during construction.
    `SSLContext` | `secureContext()` Returns the SSL context.
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### SecureContextFactory

          public SecureContextFactory(SecurityContext context)

      Creates a secure context factory that generates an `SSLContext` for the given security context.

      Any exceptions encountered while attempting to create the `SSLContext` will be logged and captured. A caller can discover if there were any errors via `hasErrors()`, and can examine the logged exceptions via `getErrors()`.

      Parameters:
        `context` - the security context

  - ### Method Detail

    - #### hasErrors

          public boolean hasErrors()

      Returns `true` if any exceptions were caught and logged during construction.
      Returns:
        true, if errors during construction

    - #### getErrors

          public List<Exception> getErrors()

      Returns the exceptions that were caught and logged during construction.
      Returns:
        the logged exceptions

    - #### secureContext

          public SSLContext secureContext()

      Returns the SSL context.
      Returns:
        the SSL context

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2014. All Rights Reserved.