diff --git a/core/src/main/java/org/acegisecurity/ui/webapp/SiteminderAuthenticationProcessingFilter.java b/core/src/main/java/org/acegisecurity/ui/webapp/SiteminderAuthenticationProcessingFilter.java index bd95cc48d2..2f3ce4573f 100644 --- a/core/src/main/java/org/acegisecurity/ui/webapp/SiteminderAuthenticationProcessingFilter.java +++ b/core/src/main/java/org/acegisecurity/ui/webapp/SiteminderAuthenticationProcessingFilter.java @@ -15,40 +15,36 @@ package org.acegisecurity.ui.webapp; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.acegisecurity.Authentication; import org.acegisecurity.AuthenticationException; + import org.acegisecurity.context.HttpSessionContextIntegrationFilter; import org.acegisecurity.context.SecurityContext; + import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + /** - * Extends Acegi's AuthenticationProcessingFilter to pick up CA/Netegrity Siteminder headers. - * - *
Also provides a backup form-based authentication and the ability set source key names.
- * - *Siteminder must present two headers to this filter, a username and password. You must set the + * Extends Acegi's AuthenticationProcessingFilter to pick up CA/Netegrity Siteminder headers.
Also provides a + * backup form-based authentication and the ability set source key names.
+ *Siteminder must present two headers to this filter, a username and password. You must set the * header keys before this filter is used for authentication, otherwise Siteminder checks will be skipped. If the * Siteminder check is unsuccessful (i.e. if the headers are not found), then the form parameters will be checked (see * next paragraph). This allows applications to optionally function even when their Siteminder infrastructure is * unavailable, as is often the case during development.
- * - *Login forms must present two parameters to this filter: a username and password. If not + *
Login forms must present two parameters to this filter: a username and password. If not * specified, the parameter names to use are contained in the static fields {@link #ACEGI_SECURITY_FORM_USERNAME_KEY} * and {@link #ACEGI_SECURITY_FORM_PASSWORD_KEY}.
- * - *Do not use this class directly. Instead, configure web.xml
to use the {@link
+ *
Do not use this class directly. Instead, configure web.xml
to use the {@link
* org.acegisecurity.util.FilterToBeanProxy}.
Authentication
request token to the
- * AuthenticationManager
(null).
+ * AuthenticationManager
*/
- protected String obtainPassword(final HttpServletRequest request) {
- return null;
+ protected String obtainPassword(HttpServletRequest request) {
+ if ((formPasswordParameterKey != null) && (formPasswordParameterKey.length() > 0)) {
+ return request.getParameter(formPasswordParameterKey);
+ } else {
+ return request.getParameter(ACEGI_SECURITY_FORM_PASSWORD_KEY);
+ }
}
/**
@@ -160,7 +197,6 @@ public class SiteminderAuthenticationProcessingFilter extends AuthenticationProc
* javax.servlet.http.HttpServletResponse)
*/
protected boolean requiresAuthentication(final HttpServletRequest request, final HttpServletResponse response) {
-
String uri = request.getRequestURI();
int pathParamIndex = uri.indexOf(';');
@@ -172,8 +208,8 @@ public class SiteminderAuthenticationProcessingFilter extends AuthenticationProc
//attempt authentication if j_secuity_check is present or if the getDefaultTargetUrl()
//is present and user is not already authenticated.
boolean bAuthenticated = false;
- SecurityContext context = (SecurityContext) request.getSession().getAttribute(
- HttpSessionContextIntegrationFilter.ACEGI_SECURITY_CONTEXT_KEY);
+ SecurityContext context = (SecurityContext) request.getSession()
+ .getAttribute(HttpSessionContextIntegrationFilter.ACEGI_SECURITY_CONTEXT_KEY);
if (context != null) {
Authentication auth = context.getAuthentication();
@@ -186,7 +222,7 @@ public class SiteminderAuthenticationProcessingFilter extends AuthenticationProc
// if true is returned then authentication will be attempted.
boolean bAttemptAuthentication = (uri.endsWith(request.getContextPath() + getFilterProcessesUrl()))
- || ((getDefaultTargetUrl() != null) && uri.endsWith(getDefaultTargetUrl()) && !bAuthenticated);
+ || ((getDefaultTargetUrl() != null) && uri.endsWith(getDefaultTargetUrl()) && !bAuthenticated);
if (logger.isDebugEnabled()) {
logger.debug("Authentication attempted for the following URI ==> " + uri + " is " + bAttemptAuthentication);
@@ -195,6 +231,15 @@ public class SiteminderAuthenticationProcessingFilter extends AuthenticationProc
return bAttemptAuthentication;
}
+ /**
+ * Sets the form password parameter key.
+ *
+ * @param key The form password parameter key.
+ */
+ public void setFormPasswordParameterKey(final String key) {
+ this.formPasswordParameterKey = key;
+ }
+
/**
* Sets the form username parameter key.
*
@@ -204,6 +249,15 @@ public class SiteminderAuthenticationProcessingFilter extends AuthenticationProc
this.formUsernameParameterKey = key;
}
+ /**
+ * Sets the Siteminder password header key.
+ *
+ * @param key The Siteminder password header key.
+ */
+ public void setSiteminderPasswordHeaderKey(final String key) {
+ this.siteminderPasswordHeaderKey = key;
+ }
+
/**
* Sets the Siteminder username header key.
*