org.apache.cassandra.auth
Class LegacyAuthenticator

java.lang.Object
  extended by org.apache.cassandra.auth.LegacyAuthenticator
All Implemented Interfaces:
IAuthenticator

public abstract class LegacyAuthenticator
extends java.lang.Object
implements IAuthenticator

Provides a transitional IAuthenticator implementation for old-style (pre-1.2) authenticators. Comes with default implementation for the all of the new methods. Subclass LegacyAuthenticator instead of implementing the old IAuthenticator and your old IAuthenticator implementation should continue to work.


Nested Class Summary
 
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
LegacyAuthenticator()
           
 
Method Summary
 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].
abstract  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).
abstract  AuthenticatedUser defaultUser()
           
 void drop(java.lang.String username)
          Called during execution of DROP USER query.
 java.util.Set<IResource> 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.
abstract  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

LegacyAuthenticator

public LegacyAuthenticator()
Method Detail

defaultUser

public abstract AuthenticatedUser defaultUser()
Returns:
The user that a connection is initialized with, or 'null' if a user must call login().

authenticate

public abstract 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
Parameters:
credentials - An implementation specific collection of identifying information.
Returns:
A successfully authenticated user: should throw AuthenticationException rather than ever returning null.
Throws:
AuthenticationException - if credentials don't match any known user.

validateConfiguration

public abstract 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.

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

create

public void create(java.lang.String username,
                   java.util.Map<IAuthenticator.Option,java.lang.Object> options)
            throws RequestValidationException,
                   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:
RequestValidationException
RequestExecutionException

alter

public void alter(java.lang.String username,
                  java.util.Map<IAuthenticator.Option,java.lang.Object> options)
           throws RequestValidationException,
                  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:
RequestValidationException
RequestExecutionException

drop

public void drop(java.lang.String username)
          throws RequestValidationException,
                 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:
RequestValidationException
RequestExecutionException

protectedResources

public java.util.Set<IResource> 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.

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


Copyright © 2013 The Apache Software Foundation