|
|||||||||
| Home >> All >> com >> xpn >> xwiki >> [ test overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.xpn.xwiki.test
Class MyFormAuthentication

java.lang.Objectorg.apache.cactus.client.authentication.AbstractAuthentication
com.xpn.xwiki.test.MyFormAuthentication
- All Implemented Interfaces:
- org.apache.cactus.client.authentication.Authentication
- public class MyFormAuthentication
- extends org.apache.cactus.client.authentication.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: MyFormAuthentication.java 322 2004-06-29 17:58:57Z ldubost $
| Field Summary | |
private java.util.List |
cookies
We store all cookies |
private int |
expectedAuthResponse
The expected HTTP response status code when the authentication is succeeded. |
private org.apache.cactus.Cookie |
jsessionCookie
We store the session cookie. |
private static org.apache.commons.logging.Log |
LOGGER
The logger. |
private java.net.URL |
securityCheckURL
The URL to use when attempting to log in, if for whatever reason the default URL is incorrect. |
private org.apache.cactus.WebRequest |
securityRequest
org.apache.cactus.WebRequest object that will be used to connect to the security URL. |
private java.lang.String |
sessionCookieName
The cookie name of the session. |
| Fields inherited from class org.apache.cactus.client.authentication.AbstractAuthentication |
|
| Constructor Summary | |
MyFormAuthentication(java.lang.String theName,
java.lang.String thePassword)
|
|
| Method Summary | |
void |
authenticate(org.apache.cactus.WebRequest theRequest,
org.apache.cactus.internal.configuration.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,
org.apache.cactus.WebRequest theRequest,
org.apache.cactus.internal.configuration.Configuration theConfiguration)
Modifies the request so that it will carry authentication information. |
private java.util.List |
getAllCookies(java.net.HttpURLConnection theConnection)
|
private org.apache.cactus.Cookie |
getCookie(java.net.HttpURLConnection theConnection,
java.lang.String theTarget)
Get a cookie required to be set by set-cookie header field. |
protected int |
getExpectedAuthResponse()
Get the expected HTTP response status code for an authentication request which should be successful. |
private org.apache.cactus.Cookie |
getSecureSessionIdCookie(org.apache.cactus.WebRequest theRequest,
org.apache.cactus.internal.configuration.Configuration theConfiguration)
Get login session cookie. |
java.net.URL |
getSecurityCheckURL(org.apache.cactus.internal.configuration.Configuration theConfiguration)
This returns the URL to use when attempting to log in. |
org.apache.cactus.WebRequest |
getSecurityRequest()
|
private java.lang.String |
getSessionCookieName()
Get the cookie name of the session. |
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 |
| Field Detail |
LOGGER
private static final org.apache.commons.logging.Log LOGGER
- The logger.
expectedAuthResponse
private int expectedAuthResponse
- The expected HTTP response status code when the authentication
is succeeded.
securityCheckURL
private java.net.URL securityCheckURL
- The URL to use when attempting to log in, if for whatever reason
the default URL is incorrect.
sessionCookieName
private java.lang.String sessionCookieName
- The cookie name of the session.
jsessionCookie
private org.apache.cactus.Cookie jsessionCookie
- We store the session cookie.
cookies
private java.util.List cookies
- We store all cookies
securityRequest
private org.apache.cactus.WebRequest securityRequest
- org.apache.cactus.WebRequest object that will be used to connect to the
security URL.
| Constructor Detail |
MyFormAuthentication
public MyFormAuthentication(java.lang.String theName, java.lang.String thePassword)
| Method Detail |
configure
public void configure(org.apache.commons.httpclient.HttpState theState, org.apache.commons.httpclient.HttpMethod theMethod, org.apache.cactus.WebRequest theRequest, org.apache.cactus.internal.configuration.Configuration theConfiguration)
- Description copied from interface:
org.apache.cactus.client.authentication.Authentication - Modifies the request so that it will carry authentication information.
getSecurityRequest
public org.apache.cactus.WebRequest getSecurityRequest()
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.
getSecurityCheckURL
public java.net.URL getSecurityCheckURL(org.apache.cactus.internal.configuration.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.
getSessionCookieName
private java.lang.String getSessionCookieName()
- Get the cookie name of the session.
setSessionCookieName
public void setSessionCookieName(java.lang.String theName)
- Set the cookie name of the session to theName.
If theName is null, the change request will be ignored.
The default is "
JSESSIONID".
getExpectedAuthResponse
protected int getExpectedAuthResponse()
- Get the expected HTTP response status code for an authentication request
which should be successful.
setExpectedAuthResponse
public void setExpectedAuthResponse(int theExpectedCode)
- Set the expected HTTP response status code for an authentication request
which should be successful.
The default is HttpURLConnection.HTTP_MOVED_TEMP.
getCookie
private org.apache.cactus.Cookie getCookie(java.net.HttpURLConnection theConnection, java.lang.String theTarget)
- Get a cookie required to be set by set-cookie header field.
getAllCookies
private java.util.List getAllCookies(java.net.HttpURLConnection theConnection)
checkPreAuthResponse
protected void checkPreAuthResponse(java.net.HttpURLConnection theConnection) throws java.lang.Exception
- Check if the pre-auth step can be considered as succeeded or not.
As default, the step considered as succeeded
if the response status code of
theConnectionis less than 400.
getSecureSessionIdCookie
private org.apache.cactus.Cookie getSecureSessionIdCookie(org.apache.cactus.WebRequest theRequest, org.apache.cactus.internal.configuration.Configuration theConfiguration)
- Get login session cookie.
This is the first step to start login session:
- C->S:
- try to connect to a restricted resource
- S->C:
- redirect or forward to the login page with set-cookie header
checkAuthResponse
protected void checkAuthResponse(java.net.HttpURLConnection theConnection) throws java.lang.Exception
- Check if the auth step can be considered as succeeded or not.
As default, the step considered as succeeded
if the response status code of
theConnectionequalsgetExpectedAuthResponse().
authenticate
public void authenticate(org.apache.cactus.WebRequest theRequest, org.apache.cactus.internal.configuration.Configuration theConfiguration)
- Authenticate the principal by calling the security URL.
Overview Package Class Use Deprecated Index Home >> All >> com >> xpn >> xwiki >> [ test overview ] PREV CLASS NEXT CLASS SUMMARY:
JAVADOC |
SOURCE |
DOWNLOAD | NESTED | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD
