org.esupportail.cas.server.util
Class BasicHandler

java.lang.Object
  extended by org.esupportail.cas.server.util.log.Debug
      extended by org.esupportail.cas.server.util.BasicHandler
Direct Known Subclasses:
EmptyPasswordHandler, ExampleHandler, FileHandler, PasswordEqualsUsernameHandler, RedundantHandler, RejectHandler

public abstract class BasicHandler
extends Debug

This class implements a basic handler, without any property. This abstract class is inherited by any handler.

Author:
Pascal Aubry

Field Summary
private  org.dom4j.Element configElement
          The XML element that represents the configuration of the handler in the configuration file.
protected static int FAILED_CONTINUE
          The value return by authenticate() when the authentication failed but the next handler should be tried.
static int FAILED_STOP
          The value return by authenticate() when the authentication failed and the authentication process should stop.
static int SUCCEEDED
          The value return by authenticate() when the authentication was successfull.
 
Constructor Summary
protected BasicHandler(org.dom4j.Element handlerElement, java.lang.Boolean configDebug)
          Constructor.
 
Method Summary
abstract  int authenticate(java.lang.String username, java.lang.String password)
          Tries to Authenticate a user by accessing all the servers..
protected  void checkConfigElement(boolean configElementNeeded)
          Check the "config" XML element if needed.
protected  org.dom4j.Element getConfigElement()
          Retrieve the XML element the represents the configuration of the handler in the configuration file.
protected  java.lang.String getConfigSubElementContent(java.lang.String elementName, boolean needed)
          Retrieve the content of a config sub-element.
protected  boolean hasConfigSubElement(java.lang.String elementName)
          Tell if a config sub-element is present.
 
Methods inherited from class org.esupportail.cas.server.util.log.Debug
checkClass, elementDebugValue, isDebug, setDebug, trace, trace, traceBegin, traceEnd, traceEnd, traceEnd, traceThrow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configElement

private org.dom4j.Element configElement
The XML element that represents the configuration of the handler in the configuration file.


FAILED_CONTINUE

protected static final int FAILED_CONTINUE
The value return by authenticate() when the authentication failed but the next handler should be tried.

See Also:
Constant Field Values

FAILED_STOP

public static final int FAILED_STOP
The value return by authenticate() when the authentication failed and the authentication process should stop.

See Also:
Constant Field Values

SUCCEEDED

public static final int SUCCEEDED
The value return by authenticate() when the authentication was successfull.

See Also:
Constant Field Values
Constructor Detail

BasicHandler

protected BasicHandler(org.dom4j.Element handlerElement,
                       java.lang.Boolean configDebug)
Constructor.

Parameters:
handlerElement - the XML element that declares the handler in the configuration file
configDebug - debugging mode of the global configuration
Method Detail

authenticate

public abstract int authenticate(java.lang.String username,
                                 java.lang.String password)
Tries to Authenticate a user by accessing all the servers..

Parameters:
username - the username to authenticate
password - the corresponding password
Returns:
SUCCEDED on success, FAILED_CONTINUE or FAILED_STOP otherwise.

checkConfigElement

protected final void checkConfigElement(boolean configElementNeeded)
                                 throws java.lang.Exception
Check the "config" XML element if needed.

Parameters:
configElementNeeded - true if a config element is needed
Throws:
java.lang.Exception - Exception

getConfigElement

protected final org.dom4j.Element getConfigElement()
Retrieve the XML element the represents the configuration of the handler in the configuration file.

Returns:
an XML element.

getConfigSubElementContent

protected final java.lang.String getConfigSubElementContent(java.lang.String elementName,
                                                            boolean needed)
                                                     throws java.lang.Exception
Retrieve the content of a config sub-element.

Parameters:
elementName - the name of the XML element to look for
needed - false if the element can be absent or empty, true otherwise
Returns:
a String
Throws:
java.lang.Exception - Exception

hasConfigSubElement

protected final boolean hasConfigSubElement(java.lang.String elementName)
                                     throws java.lang.Exception
Tell if a config sub-element is present.

Parameters:
elementName - the name of the XML element to look for
Returns:
true if the element is present, false otherwise
Throws:
java.lang.Exception - Exception