org.apache.geode.security

## Class SimpleTestSecurityManager

- java.lang.Object
- - org.apache.geode.security.SimpleTestSecurityManager

- All Implemented Interfaces:
    SecurityManager
  Direct Known Subclasses:
    SpySecurityManager

      public class SimpleTestSecurityManager
      extends java.lang.Object
      implements SecurityManager

  This class provides a simple implementation of `SecurityManager` for authentication and authorization solely based on the username and password provided. It is meant for demo purpose, not for production. Authentication: All users whose password matches the username are authenticated. e.g. username/password = test/test, user/user, admin/admin Authorization: users whose username is a substring (case insensitive) of the permission required are authorized. e.g. username = data: is authorized for all data operations: data; data:manage data:read data:write username = dataWrite: is authorized for data writes on all regions: data:write data:write:regionA username = cluster: authorized for all cluster operations username = clusterRead: authorized for all cluster read operations a user could be a comma separated list of roles as well.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleTestSecurityManager()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `authenticate(java.util.Properties credentials)` Verify the credentials provided in the properties Your security manager needs to validate credentials coming from all communication channels.
    `boolean` | `authorize(java.lang.Object principal, ResourcePermission permission)` Authorize the ResourcePermission for a given Principal
    `void` | `close()` Close any resources used by the SecurityManager, called when a cache is closed.
    `void` | `init(java.util.Properties securityProps)` Initialize the SecurityManager.

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

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

- - ### Constructor Detail

    - #### SimpleTestSecurityManager

          public SimpleTestSecurityManager()

  - ### Method Detail

    - #### init

          public void init(java.util.Properties securityProps)

      Description copied from interface: `SecurityManager`
      Initialize the SecurityManager. This is invoked when a cache is created
      Specified by:
        `init` in interface `SecurityManager`
      Parameters:
        `securityProps` - the security properties obtained using a call to `DistributedSystem.getSecurityProperties()`

    - #### authenticate

          public java.lang.Object authenticate(java.util.Properties credentials)
                                        throws AuthenticationFailedException

      Description copied from interface: `SecurityManager`
      Verify the credentials provided in the properties Your security manager needs to validate credentials coming from all communication channels. If you use AuthInitialize to generate your client/peer credentials, then the input of this method is the output of your AuthInitialize.getCredentials method. But remember that this method will also need to validate credentials coming from gfsh/jmx/rest client, the framework is putting the username/password under security-username and security-password keys in the property, so your securityManager implementation needs to validate these kind of properties as well.
      Specified by:
        `authenticate` in interface `SecurityManager`
      Parameters:
        `credentials` - it contains the security-username and security-password as keys of the properties, also the properties generated by your AuthInitialize interface
      Returns:
        a serializable principal object
      Throws:
        `AuthenticationFailedException`

    - #### authorize

          public boolean authorize(java.lang.Object principal,
                                   ResourcePermission permission)

      Description copied from interface: `SecurityManager`
      Authorize the ResourcePermission for a given Principal
      Specified by:
        `authorize` in interface `SecurityManager`
      Parameters:
        `principal` - The principal that's requesting the permission
        `permission` - The permission requested
      Returns:
        true if authorized, false if not

    - #### close

          public void close()

      Description copied from interface: `SecurityManager`
      Close any resources used by the SecurityManager, called when a cache is closed.
      Specified by:
        `close` in interface `SecurityManager`