PasswordAuthenticator (apache-cassandra API)
Date: 2014-10-21

org.apache.cassandra.auth

## Class PasswordAuthenticator

- java.lang.Object
- - org.apache.cassandra.auth.PasswordAuthenticator

- All Implemented Interfaces:
    IAuthenticator, ISaslAwareAuthenticator

      public class PasswordAuthenticator
      extends java.lang.Object
      implements ISaslAwareAuthenticator

  PasswordAuthenticator is an IAuthenticator implementation that keeps credentials (usernames and bcrypt-hashed passwords) internally in C* - in system_auth.credentials CQL3 table.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.cassandra.auth.ISaslAwareAuthenticator

      `ISaslAwareAuthenticator.SaslAuthenticator`

    - ### Nested classes/interfaces inherited from interface org.apache.cassandra.auth.IAuthenticator

      `IAuthenticator.Option`

  - ### Field Summary

    - ### Fields inherited from interface org.apache.cassandra.auth.IAuthenticator

      `PASSWORD_KEY, USERNAME_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PasswordAuthenticator()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `alter(java.lang.String username, java.util.Map<IAuthenticator.Option,java.lang.Object> options)` Called during execution of ALTER USER query.
    `java.util.Set<IAuthenticator.Option>` | `alterableOptions()` Subset of supportedOptions that users are allowed to alter when performing ALTER USER [themselves].
    `AuthenticatedUser` | `authenticate(java.util.Map<java.lang.String,java.lang.String> credentials)` Authenticates a user given a Map of credentials.
    `void` | `create(java.lang.String username, java.util.Map<IAuthenticator.Option,java.lang.Object> options)` Called during execution of CREATE USER query (also may be called on startup, see seedSuperuserOptions method).
    `void` | `drop(java.lang.String username)` Called during execution of DROP USER query.
    `ISaslAwareAuthenticator.SaslAuthenticator` | `newAuthenticator()` Provide a SaslAuthenticator to be used by the CQL binary protocol server.
    `java.util.Set<DataResource>` | `protectedResources()` Set of resources that should be made inaccessible to users and only accessible internally.
    `boolean` | `requireAuthentication()` Whether or not the authenticator requires explicit login.
    `void` | `setup()` Setup is called once upon system startup to initialize the IAuthenticator.
    `java.util.Set<IAuthenticator.Option>` | `supportedOptions()` Set of options supported by CREATE USER and ALTER USER queries.
    `void` | `validateConfiguration()` Validates configuration of IAuthenticator implementation (if configurable).

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

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

- - ### Constructor Detail

    - #### PasswordAuthenticator

          public PasswordAuthenticator()

  - ### Method Detail

    - #### requireAuthentication

          public boolean requireAuthentication()

      Description copied from interface: `IAuthenticator`
      Whether or not the authenticator requires explicit login. If false will instantiate user with AuthenticatedUser.ANONYMOUS_USER.
      Specified by:
        `requireAuthentication` in interface `IAuthenticator`

    - #### supportedOptions

          public java.util.Set<IAuthenticator.Option> supportedOptions()

      Description copied from interface: `IAuthenticator`
      Set of options supported by CREATE USER and ALTER USER queries. Should never return null - always return an empty set instead.
      Specified by:
        `supportedOptions` in interface `IAuthenticator`

    - #### alterableOptions

          public java.util.Set<IAuthenticator.Option> alterableOptions()

      Description copied from interface: `IAuthenticator`
      Subset of supportedOptions that users are allowed to alter when performing ALTER USER [themselves]. Should never return null - always return an empty set instead.
      Specified by:
        `alterableOptions` in interface `IAuthenticator`

    - #### authenticate

          public AuthenticatedUser authenticate(java.util.Map<java.lang.String,java.lang.String> credentials)
                                         throws AuthenticationException

      Description copied from interface: `IAuthenticator`
      Authenticates a user given a Map of credentials. Should never return null - always throw AuthenticationException instead. Returning AuthenticatedUser.ANONYMOUS_USER is an option as well if authentication is not required.
      Specified by:
        `authenticate` in interface `IAuthenticator`
      Throws:
        `AuthenticationException` - if credentials don't match any known user.

    - #### create

          public void create(java.lang.String username,
                    java.util.Map<IAuthenticator.Option,java.lang.Object> options)
                      throws InvalidRequestException,
                             RequestExecutionException

      Description copied from interface: `IAuthenticator`
      Called during execution of CREATE USER query (also may be called on startup, see seedSuperuserOptions method). If authenticator is static then the body of the method should be left blank, but don't throw an exception. options are guaranteed to be a subset of supportedOptions().
      Specified by:
        `create` in interface `IAuthenticator`
      Parameters:
        `username` - Username of the user to create.
        `options` - Options the user will be created with.
      Throws:
        `RequestExecutionException`
        `InvalidRequestException`

    - #### alter

          public void alter(java.lang.String username,
                   java.util.Map<IAuthenticator.Option,java.lang.Object> options)
                     throws RequestExecutionException

      Description copied from interface: `IAuthenticator`
      Called during execution of ALTER USER query. options are always guaranteed to be a subset of supportedOptions(). Furthermore, if the user performing the query is not a superuser and is altering himself, then options are guaranteed to be a subset of alterableOptions(). Keep the body of the method blank if your implementation doesn't support any options.
      Specified by:
        `alter` in interface `IAuthenticator`
      Parameters:
        `username` - Username of the user that will be altered.
        `options` - Options to alter.
      Throws:
        `RequestExecutionException`

    - #### drop

          public void drop(java.lang.String username)
                    throws RequestExecutionException

      Description copied from interface: `IAuthenticator`
      Called during execution of DROP USER query.
      Specified by:
        `drop` in interface `IAuthenticator`
      Parameters:
        `username` - Username of the user that will be dropped.
      Throws:
        `RequestExecutionException`

    - #### protectedResources

          public java.util.Set<DataResource> protectedResources()

      Description copied from interface: `IAuthenticator`
      Set of resources that should be made inaccessible to users and only accessible internally.
      Specified by:
        `protectedResources` in interface `IAuthenticator`
      Returns:
        Keyspaces, column families that will be unmodifiable by users; other resources.

    - #### validateConfiguration

          public void validateConfiguration()
                                     throws ConfigurationException

      Description copied from interface: `IAuthenticator`
      Validates configuration of IAuthenticator implementation (if configurable).
      Specified by:
        `validateConfiguration` in interface `IAuthenticator`
      Throws:
        `ConfigurationException` - when there is a configuration error.

    - #### setup

          public void setup()

      Description copied from interface: `IAuthenticator`
      Setup is called once upon system startup to initialize the IAuthenticator. For example, use this method to create any required keyspaces/column families.
      Specified by:
        `setup` in interface `IAuthenticator`

    - #### newAuthenticator

          public ISaslAwareAuthenticator.SaslAuthenticator newAuthenticator()

      Description copied from interface: `ISaslAwareAuthenticator`
      Provide a SaslAuthenticator to be used by the CQL binary protocol server. If the configured IAuthenticator requires authentication but does not implement this interface we refuse to start the binary protocol server as it will have no way of authenticating clients.
      Specified by:
        `newAuthenticator` in interface `ISaslAwareAuthenticator`
      Returns:
        SaslAuthenticator implementation (see `PasswordAuthenticator.PlainTextSaslAuthenticator`)

Copyright © 2014 The Apache Software Foundation