com.h3c.keystone

## Class AuthClientFactory

- java.lang.Object
- - com.h3c.keystone.AuthClientFactory

- Direct Known Subclasses:
    HttpClientFactory

      public abstract class AuthClientFactory
      extends Object

  A factory for building `AuthenticationClient`s.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AuthClientFactory()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static AuthClientFactory` | `build(String host, int port, int timeout, boolean clientAuth, String keyStore, String keyPass, String trustStore, String trustPass, int maxActive, int maxIdle, long timeBetweenEvictionRunsMillis, long minEvictableIdleTimeMillis, String adminToken)` Builds an AuthClientFactory singleton instance.
    `static void` | `destroy()` Destroy the previously built factory.
    `void` | `discard(AuthenticationClient client)` Call this if the client is unusable, i.e.
    `AuthenticationClient` | `getClient()` Get a client.
    `static AuthClientFactory` | `instance()` Get the previously created instance.
    `protected abstract org.apache.commons.pool.PoolableObjectFactory` | `objectFactory()` Returns an implementation-specific object factory so we can do object pooling.
    `void` | `recycle(AuthenticationClient client)` Recycle the client for next usage.
    `protected void` | `shutdown()` Shut down this factory.

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

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

- - ### Constructor Detail

    - #### AuthClientFactory

          public AuthClientFactory()

  - ### Method Detail

    - #### build

          public static AuthClientFactory build(String host,
                                int port,
                                int timeout,
                                boolean clientAuth,
                                String keyStore,
                                String keyPass,
                                String trustStore,
                                String trustPass,
                                int maxActive,
                                int maxIdle,
                                long timeBetweenEvictionRunsMillis,
                                long minEvictableIdleTimeMillis,
                                String adminToken)

      Builds an AuthClientFactory singleton instance.
      Parameters:
        `host` - Auth host
        `port` - Auth port
        `timeout` - Auth connection timeout
        `clientAuth` - 2-way SSL (if false, 1-way SSL is used)
        `keyStore` - Keystore
        `keyPass` - Keystore password
        `trustStore` - Truststore
        `trustPass` - Truststore password
        `maxActive` - Maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. When non-positive, there is no limit to the number of objects that can be managed by the pool at one time. When maxActive is reached, the pool is said to be exhausted. The default setting for this parameter is 8.
        `maxIdle` - Maximum number of objects that can sit idle in the pool at any time. When negative, there is no limit to the number of objects that may be idle at one time. The default setting for this parameter is 8.
        `timeBetweenEvictionRunsMillis` - How long the eviction thread should sleep before "runs" of examining idle objects. When non-positive, no eviction thread will be launched. The default setting for this parameter is -1 (i.e., idle object eviction is disabled by default).
        `minEvictableIdleTimeMillis` - Minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due to idle time. When non-positive, no object will be dropped from the pool due to idle time alone. This setting has no effect unless timeBetweenEvictionRunsMillis > 0. The default setting for this parameter is 30 minutes.
        `adminToken` - Admin token for use with Keystone.
      Returns:
        AuthClientFactory singleton

    - #### instance

          public static AuthClientFactory instance()

      Get the previously created instance.
      Returns:
        authentication factory instance; null if one had not been built yet

    - #### objectFactory

          protected abstract org.apache.commons.pool.PoolableObjectFactory objectFactory()

      Returns an implementation-specific object factory so we can do object pooling.
      Returns:
        A PoolableObjectFactory

    - #### getClient

          public AuthenticationClient getClient()

      Get a client. Don't forget to `recycle(AuthenticationClient)` after you are done using it, successfully or not.
      Returns:
        authentication client
      Throws:
        `KeystoneConnectionException` - if a client cannot be borrowed

    - #### recycle

          public void recycle(AuthenticationClient client)

      Recycle the client for next usage.
      Parameters:
        `client` - client to recycle
      Throws:
        `KeystoneConnectionException` - if a client cannot be recycled

    - #### discard

          public void discard(AuthenticationClient client)

      Call this if the client is unusable, i.e. if an exception was encountered while using it.
      Parameters:
        `client` - client to discard
      Throws:
        `KeystoneConnectionException` - if a client cannot be discarded

    - #### shutdown

          protected void shutdown()

      Shut down this factory.
      Throws:
        `KeystoneConnectionException` - if the factory cannot be shutdown

    - #### destroy

          public static void destroy()

      Destroy the previously built factory. This enables another to be built.

Copyright © 2014. All Rights Reserved.