org.apache.cactus.client.authentication
Class FormAuthentication

java.lang.Object
  extended byorg.apache.cactus.client.authentication.AbstractAuthentication
      extended byorg.apache.cactus.client.authentication.FormAuthentication
All Implemented Interfaces:
Authentication

public class FormAuthentication
extends AbstractAuthentication

Form-based authentication implementation. An instance of this class can be reused across several tests as it caches the session cookie. Thus the first time it is used to authenticate the user, it calls the security URL (which is by default the context URL prepended by "j_security_check"), caches the returned session cookie and adds the cookie for the next request. The second time it is called, it simply addes the session cookie for the next request.

Since:
1.5
Version:
$Id: $
Author:
Jason Robertson, Vincent Massol

Field Summary
 
Fields inherited from class org.apache.cactus.client.authentication.AbstractAuthentication
name, password
 
Constructor Summary
FormAuthentication(java.lang.String theName, java.lang.String thePassword)
           
 
Method Summary
 void authenticate(WebRequest theRequest, Configuration theConfiguration)
          Authenticate the principal by calling the security URL.
 void configure(WebRequest theRequest, Configuration theConfiguration)
          Modifies the request so that it will carry authentication information.
 java.net.URL getSecurityCheckURL(Configuration theConfiguration)
          This returns the URL to use when attempting to log in.
 WebRequest getSecurityRequest()
           
 void setSecurityCheckURL(java.net.URL theUrl)
          This sets the URL to use when attempting to log in.
protected  void validateName(java.lang.String theName)
          Verify that the user name passed as parameter is a valid user name for the current authentication scheme.
protected  void validatePassword(java.lang.String thePassword)
          Verify that the user password passed as parameter is a valid user password for the current authentication scheme.
 
Methods inherited from class org.apache.cactus.client.authentication.AbstractAuthentication
getName, getPassword, setName, setPassword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormAuthentication

public FormAuthentication(java.lang.String theName,
                          java.lang.String thePassword)
Parameters:
theName - user name of the Credential
thePassword - user password of the Credential
Method Detail

validateName

protected void validateName(java.lang.String theName)
Description copied from class: AbstractAuthentication
Verify that the user name passed as parameter is a valid user name for the current authentication scheme.

Specified by:
validateName in class AbstractAuthentication
Parameters:
theName - the user name to validate
See Also:
AbstractAuthentication.validateName(String)

validatePassword

protected void validatePassword(java.lang.String thePassword)
Description copied from class: AbstractAuthentication
Verify that the user password passed as parameter is a valid user password for the current authentication scheme.

Specified by:
validatePassword in class AbstractAuthentication
Parameters:
thePassword - the user password to validate
See Also:
AbstractAuthentication.validatePassword(String)

configure

public void configure(WebRequest theRequest,
                      Configuration theConfiguration)
Description copied from interface: Authentication
Modifies the request so that it will carry authentication information.

Parameters:
theRequest - The request object that will be sent to the Cactus Redirector over HTTP
theConfiguration - The Cactus configuration so that authentication methods can get access to Cactus configuration properties
See Also:
Authentication.configure(WebRequest, Configuration)

getSecurityRequest

public WebRequest getSecurityRequest()
Returns:
the WebRequest that will be used to connect to the security URL. It can be used to add additional HTTP parameters such as proprietary ones required by some containers.

setSecurityCheckURL

public void setSecurityCheckURL(java.net.URL theUrl)
This sets the URL to use when attempting to log in. This method is used if for whatever reason the default URL is incorrect.

Parameters:
theUrl - A URL to use to attempt to login.

getSecurityCheckURL

public java.net.URL getSecurityCheckURL(Configuration theConfiguration)
This returns the URL to use when attempting to log in. By default, it's the context URL defined in the Cactus configuration with "/j_security_check" appended.

Parameters:
theConfiguration - the Cactus configuration
Returns:
the URL that is being used to attempt to login.

authenticate

public void authenticate(WebRequest theRequest,
                         Configuration theConfiguration)
Authenticate the principal by calling the security URL.

Parameters:
theRequest - the web request used to connect to the Redirector * @param theConfiguration the Cactus configuration


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.