org.n52.security.authentication.loginmodule
Class Options

java.lang.Object
  extended by org.n52.security.authentication.loginmodule.Options
All Implemented Interfaces:
java.io.Serializable

public class Options
extends java.lang.Object
implements java.io.Serializable

Class Options represents the configuration options of a login module.

This class is introduced to encapsulate the access to common options and therefor to minimize programming errors.
This class is created in the initialize method of AbstractLoginModule and provided via a getter method to sub classes.

Version:
$Revision: $
Author:
Marko Reiprecht Created on 15.09.2007
See Also:
Serialized Form

Field Summary
static java.lang.String OPTION_DISABLED
          Field OPTION_DISABLED (true|false).
static java.lang.String OPTION_MODULEBANNER
          Field OPTION_MODULEBANNER (true|false).
static java.lang.String OPTION_TRY_FIRST_PASS
          Field OPTION_TRY_FIRST_PASS (true|false).
static java.lang.String OPTION_TRY_MAPPED_PASS
          Field OPTION_TRY_MAPPED_PASS (true|false).
static java.lang.String OPTION_USE_FIRST_PASS
          Field OPTION_USE_FIRST_PASS (true|false).
static java.lang.String OPTION_USE_MAPPED_PASS
          Field OPTION_USE_MAPPED_PASS (true|false).
 
Constructor Summary
Options(java.util.Map state)
          Constructor Options creates a new Options instance.
 
Method Summary
 boolean contains(java.lang.String key)
          Method checks if the state information contains the key.
 java.lang.Object get(java.lang.String key)
          Method gets the state information for the key.
 java.lang.Object getAs(java.lang.String key, java.lang.Class expectedType)
          Method getAs gets the option value for the key as type of the given class.
 double getAsDouble(java.lang.String key, double defaultvalue)
          Method getAsDouble gets the option value for the key as Double.
 float getAsFloat(java.lang.String key, float defaultvalue)
          Method getAsFloat gets the option value for the key as Float.
 int getAsInt(java.lang.String key, int defaultvalue)
          Method getAsInt gets the option value for the key as Integer.
 long getAsLong(java.lang.String key, long defaultvalue)
          Method getAsLong gets the option value for the key as Long.
 java.lang.String getAsString(java.lang.String key, java.lang.String defaultvalue)
          Method getAsString gets the option value for the key as a String.
 java.lang.String[] getAsStringArray(java.lang.String key, java.lang.String[] defaultvalue, java.lang.String delemiter)
          Method getAsStringArray gets the option value for the key as String[].
 boolean is(java.lang.String key)
          Method gets the boolean value from the option stored under the given key.
 boolean is(java.lang.String key, boolean defaulvalue)
          Method is gets the option value for the key as boolean.
 boolean isDisabled()
          Method checks if the disabled option is set.
 boolean isEmpty()
          Methods checks for an empty shared state.
 boolean isModuleBanner()
          Method checks if the moduleBanner option is set.
 boolean isTryFirstPass()
          Method checks if the tryFirstPass option is set.
 boolean isTryMappedPass()
          Method checks if the tryMappedPass option is set.
 boolean isUseFirstPass()
          Method checks if the useFirstPass option is set.
 boolean isUseMappedPass()
          Method checks if the useMappedPass option is set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTION_TRY_FIRST_PASS

public static final java.lang.String OPTION_TRY_FIRST_PASS
Field OPTION_TRY_FIRST_PASS (true|false).

If true, the first LoginModule in the stack saves the password entered, and subsequent LoginModules also try to use it. If authentication fails, the LoginModules prompt for a new password and retry the authentication.

See Also:
Description of the initialize method in the LoginModule Developer's Guide , Constant Field Values

OPTION_USE_FIRST_PASS

public static final java.lang.String OPTION_USE_FIRST_PASS
Field OPTION_USE_FIRST_PASS (true|false).

If true, the first LoginModule in the stack saves the password entered, and subsequent LoginModules also try to use it. LoginModules do not prompt for a new password if authentication fails (authentication simply fails).

See Also:
Description of the initialize method in the LoginModule Developer's Guide , Constant Field Values

OPTION_TRY_MAPPED_PASS

public static final java.lang.String OPTION_TRY_MAPPED_PASS
Field OPTION_TRY_MAPPED_PASS (true|false).

If true, the first LoginModule in the stack saves the password entered, and subsequent LoginModules attempt to map it into their service-specific password. If authentication fails, the LoginModules prompt for a new password and retry the authentication.

See Also:
Description of the initialize method in the LoginModule Developer's Guide , Constant Field Values

OPTION_USE_MAPPED_PASS

public static final java.lang.String OPTION_USE_MAPPED_PASS
Field OPTION_USE_MAPPED_PASS (true|false).

If true, the first LoginModule in the stack saves the password entered, and subsequent LoginModules attempt to map it into their service-specific password. LoginModules do not prompt for a new password if authentication fails (authentication simply fails).

See Also:
Description of the initialize method in the LoginModule Developer's Guide , Constant Field Values

OPTION_MODULEBANNER

public static final java.lang.String OPTION_MODULEBANNER
Field OPTION_MODULEBANNER (true|false).

If true, then when invoking the CallbackHandler, the LoginModule provides a TextOutputCallback as the first Callback, which describes the LoginModule performing the authentication.

See Also:
Description of the initialize method in the LoginModule Developer's Guide , Constant Field Values

OPTION_DISABLED

public static final java.lang.String OPTION_DISABLED
Field OPTION_DISABLED (true|false).

If true, instructs a LoginModule to ignore every call to login.

See Also:
Constant Field Values
Constructor Detail

Options

public Options(java.util.Map state)
Constructor Options creates a new Options instance.

Parameters:
state - the ${FIELD_NAME}.
Method Detail

getAsDouble

public double getAsDouble(java.lang.String key,
                          double defaultvalue)
                   throws java.lang.NumberFormatException
Method getAsDouble gets the option value for the key as Double.

Parameters:
key - the key.
defaultvalue - the defaultvalue.
Returns:
double.
Throws:
java.lang.NumberFormatException - if error occurs.

getAsFloat

public float getAsFloat(java.lang.String key,
                        float defaultvalue)
                 throws java.lang.NumberFormatException
Method getAsFloat gets the option value for the key as Float.

Parameters:
key - the key.
defaultvalue - the defaultvalue.
Returns:
float.
Throws:
java.lang.NumberFormatException - if error occurs.

getAsInt

public int getAsInt(java.lang.String key,
                    int defaultvalue)
             throws java.lang.NumberFormatException
Method getAsInt gets the option value for the key as Integer.

Parameters:
key - the key.
defaultvalue - the defaultvalue.
Returns:
int.
Throws:
java.lang.NumberFormatException - if the set value is no Integer.

getAsLong

public long getAsLong(java.lang.String key,
                      long defaultvalue)
Method getAsLong gets the option value for the key as Long.

Parameters:
key - the key.
defaultvalue - the defaultvalue.
Returns:
long.
Throws:
java.lang.NumberFormatException - if the set value is no Long.

getAsString

public java.lang.String getAsString(java.lang.String key,
                                    java.lang.String defaultvalue)
Method getAsString gets the option value for the key as a String.

Parameters:
key - the key.
defaultvalue - defines the default value if the option is empty.
Returns:
String.

getAsStringArray

public java.lang.String[] getAsStringArray(java.lang.String key,
                                           java.lang.String[] defaultvalue,
                                           java.lang.String delemiter)
Method getAsStringArray gets the option value for the key as String[].

Parameters:
key - the key.
defaultvalue - the defaultvalue.
delemiter - the delemiter like in StringTokenizer.
Returns:
String[].
See Also:
StringTokenizer

is

public boolean is(java.lang.String key,
                  boolean defaulvalue)
Method is gets the option value for the key as boolean.

Parameters:
key - the key.
defaulvalue - the default value.
Returns:
boolean the default value.

contains

public boolean contains(java.lang.String key)
Method checks if the state information contains the key.

Parameters:
key - of type String identifying a state information.
Returns:
boolean true if key in state.

isDisabled

public boolean isDisabled()
Method checks if the disabled option is set.

Returns:
boolean.
See Also:
OPTION_DISABLED

is

public boolean is(java.lang.String key)
Method gets the boolean value from the option stored under the given key. If the option value is null it returns false, if it is a Boolean it returns its value, otherwise it tries to get a Boolean value from the String representation of the value.

Parameters:
key - the option key.
Returns:
boolean.

get

public java.lang.Object get(java.lang.String key)
Method gets the state information for the key.

Parameters:
key - of type String identifying a state information.
Returns:
Object or null if (!contains(key))

isEmpty

public boolean isEmpty()
Methods checks for an empty shared state.

Returns:
boolean true if no state information is available.

isModuleBanner

public boolean isModuleBanner()
Method checks if the moduleBanner option is set.

Returns:
boolean.
See Also:
OPTION_MODULEBANNER

isTryFirstPass

public boolean isTryFirstPass()
Method checks if the tryFirstPass option is set.

Returns:
boolean.
See Also:
OPTION_TRY_FIRST_PASS

isTryMappedPass

public boolean isTryMappedPass()
Method checks if the tryMappedPass option is set.

Returns:
boolean.
See Also:
OPTION_TRY_MAPPED_PASS

isUseFirstPass

public boolean isUseFirstPass()
Method checks if the useFirstPass option is set.

Returns:
boolean.
See Also:
OPTION_USE_FIRST_PASS

isUseMappedPass

public boolean isUseMappedPass()
Method checks if the useMappedPass option is set.

Returns:
boolean.
See Also:
OPTION_USE_MAPPED_PASS

getAs

public java.lang.Object getAs(java.lang.String key,
                              java.lang.Class expectedType)
                       throws java.lang.IllegalArgumentException
Method getAs gets the option value for the key as type of the given class.

Parameters:
key - the key.
expectedType - the expected class of the key.
Returns:
Object of type expectedType.
Throws:
java.lang.NumberFormatException - if error occurs.
java.lang.IllegalArgumentException


Copyright © 2004-2009 52north.org. All Rights Reserved.