|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cactus.client.authentication.AbstractAuthentication
org.apache.cactus.client.authentication.FormAuthentication
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.
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. |
protected void |
checkAuthResponse(java.net.HttpURLConnection theConnection)
Check if the auth step can be considered as succeeded or not. |
protected void |
checkPreAuthResponse(java.net.HttpURLConnection theConnection)
Check if the pre-auth step can be considered as succeeded or not. |
void |
configure(org.apache.commons.httpclient.HttpState theState,
org.apache.commons.httpclient.HttpMethod theMethod,
WebRequest theRequest,
Configuration theConfiguration)
Modifies the request so that it will carry authentication information. |
protected int |
getExpectedAuthResponse()
Get the expected HTTP response status code for an authentication request which should be successful. |
java.net.URL |
getSecurityCheckURL(Configuration theConfiguration)
This returns the URL to use when attempting to log in. |
WebRequest |
getSecurityRequest()
|
void |
setExpectedAuthResponse(int theExpectedCode)
Set the expected HTTP response status code for an authentication request which should be successful. |
void |
setSecurityCheckURL(java.net.URL theUrl)
This sets the URL to use when attempting to log in. |
void |
setSessionCookieName(java.lang.String theName)
Set the cookie name of the session to theName. |
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 |
public FormAuthentication(java.lang.String theName, java.lang.String thePassword)
theName
- user name of the CredentialthePassword
- user password of the CredentialMethod Detail |
public void configure(org.apache.commons.httpclient.HttpState theState, org.apache.commons.httpclient.HttpMethod theMethod, WebRequest theRequest, Configuration theConfiguration)
Authentication
theState
- The HttpClient state object that can be used to ask
HttpClient to set up authenticationtheMethod
- the HttpClient HTTP method that will be used to connect
to the server sidetheRequest
- The request object that will be sent to the Cactus
Redirector over HTTPtheConfiguration
- The Cactus configuration so that
authentication methods can get access to Cactus configuration
propertiesAuthentication.configure(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpMethod, org.apache.cactus.WebRequest, org.apache.cactus.internal.configuration.Configuration)
public WebRequest getSecurityRequest()
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.public void setSecurityCheckURL(java.net.URL theUrl)
theUrl
- A URL to use to attempt to login.public java.net.URL getSecurityCheckURL(Configuration theConfiguration)
theConfiguration
- the Cactus configuration
public void setSessionCookieName(java.lang.String theName)
JSESSIONID
".
theName
- the cookie name of the sessionprotected int getExpectedAuthResponse()
public void setExpectedAuthResponse(int theExpectedCode)
theExpectedCode
- the expected HTTP response status code valueprotected void checkPreAuthResponse(java.net.HttpURLConnection theConnection) throws java.lang.Exception
theConnection
is less than 400.
theConnection
- a HttpURLConnection
value
java.lang.Exception
- if the pre-auth step should be considered as failedprotected void checkAuthResponse(java.net.HttpURLConnection theConnection) throws java.lang.Exception
theConnection
equals getExpectedAuthResponse()
.
theConnection
- a HttpURLConnection
value
java.lang.Exception
- if the auth step should be considered as failedpublic void authenticate(WebRequest theRequest, Configuration theConfiguration)
theRequest
- the web request used to connect to the RedirectortheConfiguration
- the Cactus configuration
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |