org.apache.geode.security.generator

## Class CredentialGenerator

- java.lang.Object
- - org.apache.geode.security.generator.CredentialGenerator

- Direct Known Subclasses:
    DummyCredentialGenerator, LdapUserCredentialGenerator, PKCSCredentialGenerator, SSLCredentialGenerator

      public abstract class CredentialGenerator
      extends java.lang.Object

  Encapsulates obtaining valid and invalid credentials. Implementations will be for different kinds of authentication schemes.
  Since:
    GemFire 5.5

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CredentialGenerator.ClassCode` Enumeration for various `CredentialGenerator` implementations.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Properties` | `javaProperties` A set of properties that should be added to the java system properties before using the authentication module.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CredentialGenerator()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract CredentialGenerator.ClassCode` | `classCode()` The `CredentialGenerator.ClassCode` of this particular implementation.
    `static CredentialGenerator` | `create(CredentialGenerator.ClassCode classCode)` A factory method to create a new instance of an `CredentialGenerator` for the given `CredentialGenerator.ClassCode`.
    `abstract java.lang.String` | `getAuthenticator()` The name of the `Authenticator` factory function that should be used in conjunction with the credentials generated by this generator.
    `abstract java.lang.String` | `getAuthInit()` The name of the `AuthInitialize` factory function that should be used in conjunction with the credentials generated by this generator.
    `abstract java.util.Properties` | `getInvalidCredentials(int index)` Get a set of invalid credentials generated using the given index.
    `java.util.Properties` | `getJavaProperties()`
    `java.util.Properties` | `getSystemProperties()`
    `abstract java.util.Properties` | `getValidCredentials(int index)` Get a set of valid credentials generated using the given index.
    `abstract java.util.Properties` | `getValidCredentials(java.security.Principal principal)` Get a set of valid credentials for the given `Principal`.
    `void` | `init()` Initialize the credential generator.
    `protected abstract java.util.Properties` | `initialize()` Initialize the credential generator.

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

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

- - ### Field Detail

    - #### javaProperties

          protected java.util.Properties javaProperties

      A set of properties that should be added to the java system properties before using the authentication module.

  - ### Constructor Detail

    - #### CredentialGenerator

          public CredentialGenerator()

  - ### Method Detail

    - #### create

          public static CredentialGenerator create(CredentialGenerator.ClassCode classCode)

      A factory method to create a new instance of an `CredentialGenerator` for the given `CredentialGenerator.ClassCode`. Caller is supposed to invoke `init()` immediately after obtaining the instance.
      Parameters:
        `classCode` - the `ClassCode` of the `CredentialGenerator` implementation
      Returns:
        an instance of `CredentialGenerator` for the given class code

    - #### init

          public void init()
                    throws java.lang.IllegalArgumentException

      Initialize the credential generator.
      Throws:
        `java.lang.IllegalArgumentException` - when there is a problem during initialization

    - #### getSystemProperties

          public java.util.Properties getSystemProperties()

      Returns:
        A set of extra properties that should be added to Gemfire system properties when not null.

    - #### getJavaProperties

          public java.util.Properties getJavaProperties()

      Returns:
        A set of extra properties that should be added to Gemfire system properties when not null.

    - #### classCode

          public abstract CredentialGenerator.ClassCode classCode()

      The `CredentialGenerator.ClassCode` of this particular implementation.
      Returns:
        the `ClassCode`

    - #### getAuthInit

          public abstract java.lang.String getAuthInit()

      The name of the `AuthInitialize` factory function that should be used in conjunction with the credentials generated by this generator.
      Returns:
        name of the `AuthInitialize` factory function

    - #### getAuthenticator

          public abstract java.lang.String getAuthenticator()

      The name of the `Authenticator` factory function that should be used in conjunction with the credentials generated by this generator.
      Returns:
        name of the `Authenticator` factory function

    - #### getValidCredentials

          public abstract java.util.Properties getValidCredentials(int index)

      Get a set of valid credentials generated using the given index.

    - #### getValidCredentials

          public abstract java.util.Properties getValidCredentials(java.security.Principal principal)

      Get a set of valid credentials for the given `Principal`.
      Returns:
        credentials for the given `Principal` or null if none possible.

    - #### getInvalidCredentials

          public abstract java.util.Properties getInvalidCredentials(int index)

      Get a set of invalid credentials generated using the given index.

    - #### initialize

          protected abstract java.util.Properties initialize()
                                                      throws java.lang.IllegalArgumentException

      Initialize the credential generator. This is provided separately from the `init()` method for convenience of implementations so that they do not need to store in `systemProperties`. The latter is convenient for the users who do not need to store these properties rather can obtain it later by invoking `getSystemProperties()`

      Required to be implemented by concrete classes that implement this abstract class.

      Returns:
        A set of extra properties that should be added to Gemfire system properties when not null.
      Throws:
        `java.lang.IllegalArgumentException` - when there is a problem during initialization