Skip to content

Commit

Permalink
SEC-1259: Improve consistency of authentication filter names.
Browse files Browse the repository at this point in the history
  • Loading branch information
tekul committed Oct 7, 2009
1 parent f213cc5 commit 1286741
Show file tree
Hide file tree
Showing 38 changed files with 268 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.CasProcessingFilter;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.SpringSecurityMessageSource;
Expand All @@ -41,7 +41,7 @@
* <p>
* This <code>AuthenticationProvider</code> is capable of validating {@link UsernamePasswordAuthenticationToken}
* requests which contain a <code>principal</code> name equal to either
* {@link CasProcessingFilter#CAS_STATEFUL_IDENTIFIER} or {@link CasProcessingFilter#CAS_STATELESS_IDENTIFIER}.
* {@link CasAuthenticationFilter#CAS_STATEFUL_IDENTIFIER} or {@link CasAuthenticationFilter#CAS_STATELESS_IDENTIFIER}.
* It can also validate a previously created {@link CasAuthenticationToken}.
*
* @author Ben Alex
Expand Down Expand Up @@ -78,8 +78,8 @@ public Authentication authenticate(Authentication authentication) throws Authent
}

if (authentication instanceof UsernamePasswordAuthenticationToken
&& (!CasProcessingFilter.CAS_STATEFUL_IDENTIFIER.equals(authentication.getPrincipal().toString())
&& !CasProcessingFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal().toString()))) {
&& (!CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER.equals(authentication.getPrincipal().toString())
&& !CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal().toString()))) {
// UsernamePasswordAuthenticationToken not CAS related
return null;
}
Expand All @@ -103,7 +103,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
boolean stateless = false;

if (authentication instanceof UsernamePasswordAuthenticationToken
&& CasProcessingFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal())) {
&& CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal())) {
stateless = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
* The user's browser will be redirected to the JA-SIG CAS enterprise-wide login page.
* This page is specified by the <code>loginUrl</code> property. Once login is complete, the CAS login page will
* redirect to the page indicated by the <code>service</code> property. The <code>service</code> is a HTTP URL
* belonging to the current application. The <code>service</code> URL is monitored by the {@link CasProcessingFilter},
* belonging to the current application. The <code>service</code> URL is monitored by the {@link CasAuthenticationFilter},
* which will validate the CAS login was successful.
*
* @author Ben Alex
* @author Scott Battaglia
* @version $Id$
*/
public class CasProcessingFilterEntryPoint implements AuthenticationEntryPoint, InitializingBean {
public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean {
//~ Instance fields ================================================================================================
private ServiceProperties serviceProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
* them accordingly by validation with the CAS server.
* <p>
* By configuring a shared {@link ProxyGrantingTicketStorage} between the {@link TicketValidator} and the
* CasProcessingFilter one can have the CasProcessingFilter handle the proxying requirements for CAS. In addition, the
* CasAuthenticationFilter one can have the CasAuthenticationFilter handle the proxying requirements for CAS. In addition, the
* URI endpoint for the proxying would also need to be configured (i.e. the part after protocol, hostname, and port).
* <p>
* By default this filter processes the URL <tt>/j_spring_cas_security_check</tt>.
*
* @author Ben Alex
* @version $Id$
*/
public class CasProcessingFilter extends AbstractAuthenticationProcessingFilter {
public class CasAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
//~ Static fields/initializers =====================================================================================

/** Used to identify a CAS request for a stateful user agent, such as a web browser. */
Expand All @@ -83,7 +83,7 @@ public class CasProcessingFilter extends AbstractAuthenticationProcessingFilter

//~ Constructors ===================================================================================================

public CasProcessingFilter() {
public CasAuthenticationFilter() {
super("/j_spring_cas_security_check");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.springframework.security.authentication.TestingAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.CasProcessingFilter;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
Expand Down Expand Up @@ -83,7 +83,7 @@ public void statefulAuthenticationIsSuccessful() throws Exception {
cap.afterPropertiesSet();

UsernamePasswordAuthenticationToken token =
new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATEFUL_IDENTIFIER, "ST-123");
new UsernamePasswordAuthenticationToken(CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, "ST-123");
token.setDetails("details");

Authentication result = cap.authenticate(token);
Expand Down Expand Up @@ -124,7 +124,7 @@ public void statelessAuthenticationIsSuccessful() throws Exception {
cap.afterPropertiesSet();

UsernamePasswordAuthenticationToken token =
new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATELESS_IDENTIFIER, "ST-456");
new UsernamePasswordAuthenticationToken(CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER, "ST-456");
token.setDetails("details");

Authentication result = cap.authenticate(token);
Expand Down Expand Up @@ -163,7 +163,7 @@ public void missingTicketIdIsDetected() throws Exception {
cap.afterPropertiesSet();

UsernamePasswordAuthenticationToken token =
new UsernamePasswordAuthenticationToken(CasProcessingFilter.CAS_STATEFUL_IDENTIFIER, "");
new UsernamePasswordAuthenticationToken(CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER, "");

cap.authenticate(token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.CasProcessingFilterEntryPoint;
import org.springframework.security.cas.web.CasAuthenticationEntryPoint;

import java.net.URLEncoder;


/**
* Tests {@link CasProcessingFilterEntryPoint}.
* Tests {@link CasAuthenticationEntryPoint}.
*
* @author Ben Alex
* @version $Id$
*/
public class CasProcessingFilterEntryPointTests extends TestCase {
public class CasAuthenticationEntryPointTests extends TestCase {
//~ Methods ========================================================================================================

public void testDetectsMissingLoginFormUrl() throws Exception {
CasProcessingFilterEntryPoint ep = new CasProcessingFilterEntryPoint();
CasAuthenticationEntryPoint ep = new CasAuthenticationEntryPoint();
ep.setServiceProperties(new ServiceProperties());

try {
Expand All @@ -47,7 +47,7 @@ public void testDetectsMissingLoginFormUrl() throws Exception {
}

public void testDetectsMissingServiceProperties() throws Exception {
CasProcessingFilterEntryPoint ep = new CasProcessingFilterEntryPoint();
CasAuthenticationEntryPoint ep = new CasAuthenticationEntryPoint();
ep.setLoginUrl("https://cas/login");

try {
Expand All @@ -59,7 +59,7 @@ public void testDetectsMissingServiceProperties() throws Exception {
}

public void testGettersSetters() {
CasProcessingFilterEntryPoint ep = new CasProcessingFilterEntryPoint();
CasAuthenticationEntryPoint ep = new CasAuthenticationEntryPoint();
ep.setLoginUrl("https://cas/login");
assertEquals("https://cas/login", ep.getLoginUrl());

Expand All @@ -72,7 +72,7 @@ public void testNormalOperationWithRenewFalse() throws Exception {
sp.setSendRenew(false);
sp.setService("https://mycompany.com/bigWebApp/j_spring_cas_security_check");

CasProcessingFilterEntryPoint ep = new CasProcessingFilterEntryPoint();
CasAuthenticationEntryPoint ep = new CasAuthenticationEntryPoint();
ep.setLoginUrl("https://cas/login");
ep.setServiceProperties(sp);

Expand All @@ -94,7 +94,7 @@ public void testNormalOperationWithRenewTrue() throws Exception {
sp.setSendRenew(true);
sp.setService("https://mycompany.com/bigWebApp/j_spring_cas_security_check");

CasProcessingFilterEntryPoint ep = new CasProcessingFilterEntryPoint();
CasAuthenticationEntryPoint ep = new CasAuthenticationEntryPoint();
ep.setLoginUrl("https://cas/login");
ep.setServiceProperties(sp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import junit.framework.TestCase;

import org.springframework.security.MockAuthenticationManager;
import org.springframework.security.cas.web.CasProcessingFilter;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;

Expand All @@ -27,16 +27,16 @@


/**
* Tests {@link CasProcessingFilter}.
* Tests {@link CasAuthenticationFilter}.
*
* @author Ben Alex
* @version $Id$
*/
public class CasProcessingFilterTests extends TestCase {
public class CasAuthenticationFilterTests extends TestCase {
//~ Methods ========================================================================================================

public void testGetters() {
CasProcessingFilter filter = new CasProcessingFilter();
CasAuthenticationFilter filter = new CasAuthenticationFilter();
assertEquals("/j_spring_cas_security_check", filter.getFilterProcessesUrl());
}

Expand All @@ -46,7 +46,7 @@ public void testNormalOperation() throws Exception {

MockAuthenticationManager authMgr = new MockAuthenticationManager(true);

CasProcessingFilter filter = new CasProcessingFilter();
CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setAuthenticationManager(authMgr);

Authentication result = filter.attemptAuthentication(request, new MockHttpServletResponse());
Expand All @@ -59,7 +59,7 @@ public void testNullServiceTicketHandledGracefully()

MockAuthenticationManager authMgr = new MockAuthenticationManager(false);

CasProcessingFilter filter = new CasProcessingFilter();
CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setAuthenticationManager(authMgr);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
import org.springframework.security.web.PortResolverImpl;
import org.springframework.security.web.access.AccessDeniedHandlerImpl;
import org.springframework.security.web.access.ExceptionTranslationFilter;
import org.springframework.security.web.authentication.AnonymousProcessingFilter;
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
import org.springframework.security.web.authentication.Http403ForbiddenEntryPoint;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider;
import org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor;
import org.springframework.security.web.authentication.preauth.x509.X509PreAuthenticatedProcessingFilter;
import org.springframework.security.web.authentication.preauth.x509.X509AuthenticationFilter;
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
import org.springframework.security.web.authentication.www.BasicProcessingFilter;
import org.springframework.security.web.authentication.www.BasicProcessingFilterEntryPoint;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
Expand Down Expand Up @@ -263,8 +263,8 @@ void createBasicFilter(BeanReference authManager) {
RootBeanDefinition entryPoint = null;

if (basicAuthElt != null || autoConfig) {
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(BasicProcessingFilter.class);
entryPoint = new RootBeanDefinition(BasicProcessingFilterEntryPoint.class);
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(BasicAuthenticationFilter.class);
entryPoint = new RootBeanDefinition(BasicAuthenticationEntryPoint.class);
entryPoint.setSource(pc.extractSource(httpElt));

entryPoint.getPropertyValues().addPropertyValue("realmName", realm);
Expand All @@ -287,7 +287,7 @@ void createX509Filter(BeanReference authManager) {
RootBeanDefinition entryPoint = null;

if (x509Elt != null) {
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(X509PreAuthenticatedProcessingFilter.class);
BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.rootBeanDefinition(X509AuthenticationFilter.class);
filterBuilder.getRawBeanDefinition().setSource(pc.extractSource(x509Elt));
filterBuilder.addPropertyValue("authenticationManager", authManager);

Expand Down Expand Up @@ -395,7 +395,7 @@ void createAnonymousFilter() {
key = Long.toString(random.nextLong());
}

anonymousFilter = new RootBeanDefinition(AnonymousProcessingFilter.class);
anonymousFilter = new RootBeanDefinition(AnonymousAuthenticationFilter.class);

PropertyValue keyPV = new PropertyValue("key", key);
anonymousFilter.setSource(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import org.springframework.security.web.access.ExceptionTranslationFilter;
import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.AnonymousProcessingFilter;
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
import org.springframework.security.web.authentication.www.BasicProcessingFilter;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter;
import org.springframework.security.web.session.SessionManagementFilter;
Expand Down Expand Up @@ -53,7 +53,7 @@ private void checkFilterStack(List<Filter> filters) {
checkForDuplicates(SecurityContextPersistenceFilter.class, filters);
checkForDuplicates(UsernamePasswordAuthenticationFilter.class, filters);
checkForDuplicates(SessionManagementFilter.class, filters);
checkForDuplicates(BasicProcessingFilter.class, filters);
checkForDuplicates(BasicAuthenticationFilter.class, filters);
checkForDuplicates(SecurityContextHolderAwareRequestFilter.class, filters);
checkForDuplicates(ExceptionTranslationFilter.class, filters);
checkForDuplicates(FilterSecurityInterceptor.class, filters);
Expand Down Expand Up @@ -110,7 +110,7 @@ private void checkLoginPageIsntProtected(FilterChainProxy fcp, List<Filter> defa
return;
}

AnonymousProcessingFilter anonPF = (AnonymousProcessingFilter) getFilter(AnonymousProcessingFilter.class, filters);
AnonymousAuthenticationFilter anonPF = (AnonymousAuthenticationFilter) getFilter(AnonymousAuthenticationFilter.class, filters);
if (anonPF == null) {
logger.warn("The login page is being protected by the filter chain, but you don't appear to have" +
" anonymous authentication enabled. This is almost certainly an error.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl;
import org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices;
import org.springframework.security.web.authentication.rememberme.RememberMeProcessingFilter;
import org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter;
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
Expand Down Expand Up @@ -126,7 +126,7 @@ public BeanDefinition parse(Element element, ParserContext pc) {
}

private BeanDefinition createFilter(ParserContext pc, Object source) {
BeanDefinitionBuilder filter = BeanDefinitionBuilder.rootBeanDefinition(RememberMeProcessingFilter.class);
BeanDefinitionBuilder filter = BeanDefinitionBuilder.rootBeanDefinition(RememberMeAuthenticationFilter.class);
filter.getRawBeanDefinition().setSource(source);
filter.addPropertyReference("rememberMeServices", servicesName);

Expand Down
Loading

0 comments on commit 1286741

Please sign in to comment.