PKCSAuthInit (Apache Geode 1.8.0)
Date: 2018-11-29

org.apache.geode.security.templates

## Class PKCSAuthInit

- java.lang.Object
- - org.apache.geode.security.templates.PKCSAuthInit

- All Implemented Interfaces:
    CacheCallback, Declarable, AuthInitialize

      public class PKCSAuthInit
      extends java.lang.Object
      implements AuthInitialize

  An `AuthInitialize` implementation that obtains the digital signature for use with PKCS scheme on server from the given set of properties. To use this class the `security-client-auth-init` property should be set to the fully qualified name the static `create` function viz. `org.apache.geode.security.templates.PKCSAuthInit.create`
  Since:
    GemFire 5.5

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `KEYSTORE_ALIAS`
    `static java.lang.String` | `KEYSTORE_FILE_PATH`
    `static java.lang.String` | `KEYSTORE_PASSWORD`
    `protected LogWriter` | `securityLogWriter`
    `static java.lang.String` | `SIGNATURE_DATA`
    `protected LogWriter` | `systemLogWriter`

    - ### Fields inherited from interface org.apache.geode.security.AuthInitialize

      `SECURITY_PASSWORD, SECURITY_USERNAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PKCSAuthInit()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an `AttributesMutator`.
    `static AuthInitialize` | `create()`
    `java.util.Properties` | `getCredentials(java.util.Properties securityProperties, DistributedMember server, boolean isPeer)` Initialize with the given set of security properties and return the credentials for the peer/client as properties.
    `void` | `init(LogWriter systemLogWriter, LogWriter securityLogWriter)` Initialize the callback for a client/peer.

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

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

    - ### Methods inherited from interface org.apache.geode.security.AuthInitialize

      `getCredentials, init`

    - ### Methods inherited from interface org.apache.geode.cache.Declarable

      `init, initialize`

- - ### Field Detail

    - #### KEYSTORE_FILE_PATH

          public static final java.lang.String KEYSTORE_FILE_PATH

      See Also:
        Constant Field Values

    - #### KEYSTORE_ALIAS

          public static final java.lang.String KEYSTORE_ALIAS

      See Also:
        Constant Field Values

    - #### KEYSTORE_PASSWORD

          public static final java.lang.String KEYSTORE_PASSWORD

      See Also:
        Constant Field Values

    - #### SIGNATURE_DATA

          public static final java.lang.String SIGNATURE_DATA

      See Also:
        Constant Field Values

    - #### systemLogWriter

          protected LogWriter systemLogWriter

    - #### securityLogWriter

          protected LogWriter securityLogWriter

  - ### Constructor Detail

    - #### PKCSAuthInit

          public PKCSAuthInit()

  - ### Method Detail

    - #### create

          public static AuthInitialize create()

    - #### init

          public void init(LogWriter systemLogWriter,
                           LogWriter securityLogWriter)
                    throws AuthenticationFailedException

      Description copied from interface: `AuthInitialize`
      Initialize the callback for a client/peer. This is invoked when a new connection from a client/peer is created with the host. For future implementations, do not use these loggers, use log4j logger directly.
      Specified by:
        `init` in interface `AuthInitialize`
      Parameters:
        `systemLogWriter` - `LogWriter` for system logs
        `securityLogWriter` - `LogWriter` for security logs
      Throws:
        `AuthenticationFailedException` - if some exception occurs during the initialization

    - #### getCredentials

          public java.util.Properties getCredentials(java.util.Properties securityProperties,
                                                     DistributedMember server,
                                                     boolean isPeer)
                                              throws AuthenticationFailedException

      Description copied from interface: `AuthInitialize`
      Initialize with the given set of security properties and return the credentials for the peer/client as properties. This method can modify the given set of properties. For example it may invoke external agents or even interact with the user. Normally it is expected that implementations will filter out security-* properties that are needed for credentials and return only those.
      Specified by:
        `getCredentials` in interface `AuthInitialize`
      Parameters:
        `securityProperties` - the security properties obtained using a call to `DistributedSystem.getSecurityProperties()` that will be used for obtaining the credentials
        `server` - the `DistributedMember` object of the server/group-coordinator to which connection is being attempted
        `isPeer` - true when this is invoked for peer initialization and false when invoked for client initialization
      Returns:
        the credentials to be used for the given `server` It needs to contain "security-username" and "security-password" When using Integrated security, all members, peer/client will use the same credentials. but we still need to use these params to support the old authenticator
      Throws:
        `AuthenticationFailedException` - in case of failure to obtain the credentials

    - #### close

          public void close()

      Description copied from interface: `CacheCallback`
      Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an `AttributesMutator`.

      Implementations should cleanup any external resources such as database connections. Any runtime exceptions this method throws will be logged.

      It is possible for this method to be called multiple times on a single callback instance, so implementations must be tolerant of this.

      Specified by:
        `close` in interface `CacheCallback`
      See Also:
        `RegionService.close()`, `Region.close()`, `Region.localDestroyRegion()`, `Region.destroyRegion()`, `AttributesMutator`