public abstract class BaseFormAuthenticator extends java.lang.Object implements HttpAuthenticator
BasicAuthenticator
. This class is abstract and all abstract methods
should be implemented by subclasses: getInitialPath()
- returns value of app context or base
pathisValidLoginRedirect(org.apache.commons.httpclient.HttpMethod)
- return true if the HttpMethod
response is a valid redirect after login form is submittedisLoginError(org.apache.commons.httpclient.HttpMethod)
- return true if the HttpMethod response indicates an error occurredisFollowLoginRedirect()
-
return true if authenticator should follow any redirect returned after login form is submittedModifier and Type | Field and Description |
---|---|
static java.lang.String |
HTTP_SECURE_PROTOCOL
Secure protocol: "https"
|
static java.lang.String |
J_SECURITY_CHECK |
static java.lang.String |
JAVA_AUTH_PATH
path for java auth form submit: "/j_security_check"
|
static java.lang.String |
JAVA_PASS_PARAM
password param for java auth form submit: "j_password"
|
static java.lang.String |
JAVA_SESSION_COOKIE_NAME
Cookie name for java auth session: "JSESSIONID"
|
static java.util.regex.Pattern |
JAVA_SESSION_COOKIE_PATTERN |
static java.lang.String |
JAVA_USER_PARAM
username param for java auth form submit: "j_username"
|
static org.apache.log4j.Logger |
logger
logger
|
static java.lang.String |
LOGIN_PAGE
Text to check Location of redirects to indicate login is required.
|
Constructor and Description |
---|
BaseFormAuthenticator(java.lang.String basePath,
java.lang.String username,
java.lang.String password)
Constructor with base URL path, username and password for authentication.
|
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(java.net.URL baseURL,
org.apache.commons.httpclient.HttpClient client)
Authenticate the client http state so that the colony requests can be made.
|
java.lang.String |
getBasePath() |
java.lang.String |
getCookieId() |
java.lang.String |
getUsername()
Gets the user login name used when instantiating the authenticator
|
static boolean |
hasSessionCookie(java.net.URL reqUrl,
org.apache.commons.httpclient.HttpState state,
java.lang.String basePath)
Check the http state cookies to see if we have the proper session id cookie
|
boolean |
needsReAuthentication(int resultCode,
org.apache.commons.httpclient.HttpMethod method)
Return true if the result from the get method indicates re-authentication is needed
|
void |
setCookieId(java.lang.String cookieId) |
public static final org.apache.log4j.Logger logger
public static final java.lang.String J_SECURITY_CHECK
public static final java.lang.String JAVA_AUTH_PATH
public static final java.lang.String JAVA_USER_PARAM
public static final java.lang.String JAVA_PASS_PARAM
public static final java.lang.String JAVA_SESSION_COOKIE_NAME
public static final java.util.regex.Pattern JAVA_SESSION_COOKIE_PATTERN
public static final java.lang.String HTTP_SECURE_PROTOCOL
public static final java.lang.String LOGIN_PAGE
public BaseFormAuthenticator(java.lang.String basePath, java.lang.String username, java.lang.String password)
basePath
- base URL path to use with the serverusername
- username to usepassword
- password to usepublic boolean authenticate(java.net.URL baseURL, org.apache.commons.httpclient.HttpClient client) throws HttpClientException
authenticate
in interface HttpAuthenticator
baseURL
- URL requested for colonyclient
- HttpClient instanceHttpClientException
- on errorpublic static boolean hasSessionCookie(java.net.URL reqUrl, org.apache.commons.httpclient.HttpState state, java.lang.String basePath)
reqUrl
- URL being requestedstate
- HTTP state objectbasePath
- base path of requestspublic boolean needsReAuthentication(int resultCode, org.apache.commons.httpclient.HttpMethod method)
needsReAuthentication
in interface HttpAuthenticator
resultCode
- result codemethod
- requestpublic java.lang.String getUsername()
HttpAuthenticator
getUsername
in interface HttpAuthenticator
public java.lang.String getBasePath()
public java.lang.String getCookieId()
public void setCookieId(java.lang.String cookieId)