org.apache.geode.security.templates

## Class SimpleAuthenticator

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

- All Implemented Interfaces:
    CacheCallback, Declarable, Authenticator

      public class SimpleAuthenticator
      extends java.lang.Object
      implements Authenticator

  A test implementation of the legacy `Authenticator`, mirroring the structure of `SimpleSecurityManager`. Authenticates a user when the username matches the password, which in turn will match the user's permissions in `SimpleAccessController`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleAuthenticator()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.security.Principal` | `authenticate(java.util.Properties props, DistributedMember member)` Verify the credentials provided in the properties for the client/peer as specified in member ID and returns the principal associated with the client/peer.
    `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 Authenticator` | `create()`
    `void` | `init(java.util.Properties securityProps, LogWriter systemLogger, LogWriter securityLogger)` 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.Authenticator

      `authenticate, init`

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

      `initialize`

- - ### Constructor Detail

    - #### SimpleAuthenticator

          public SimpleAuthenticator()

  - ### Method Detail

    - #### init

          public void init(java.util.Properties securityProps,
                           LogWriter systemLogger,
                           LogWriter securityLogger)
                    throws AuthenticationFailedException

      Description copied from interface: `Authenticator`
      Initialize the callback for a client/peer. This is invoked when a new connection from a client/peer is created with the host.
      Specified by:
        `init` in interface `Authenticator`
      Parameters:
        `securityProps` - the security properties obtained using a call to `DistributedSystem.getSecurityProperties()`
        `systemLogger` - `LogWriter` for system logs
        `securityLogger` - `LogWriter` for security logs
      Throws:
        `AuthenticationFailedException` - if some exception occurs during the initialization

    - #### create

          public static Authenticator create()

    - #### authenticate

          public java.security.Principal authenticate(java.util.Properties props,
                                                      DistributedMember member)
                                               throws AuthenticationFailedException

      Description copied from interface: `Authenticator`
      Verify the credentials provided in the properties for the client/peer as specified in member ID and returns the principal associated with the client/peer.
      Specified by:
        `authenticate` in interface `Authenticator`
      Parameters:
        `props` - the credentials of the client/peer as a set of property key/values
        `member` - the `DistributedMember` object of the connecting client/peer member. NULL when invoked locally on the member initiating the authentication request.
      Returns:
        the principal for the client/peer when authentication succeeded
      Throws:
        `AuthenticationFailedException` - If the authentication of the client/peer fails.

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