From 07d7c0ddaee016e91b059ad9c70a5ff8a88dea13 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Mon, 5 Oct 2009 17:33:34 +0000 Subject: [PATCH] Renamed form and openID filters to shorten names --- .../http/AuthenticationConfigBuilder.java | 4 +-- .../http/DefaultFilterChainValidator.java | 4 +-- .../config/FilterChainProxyConfigTests.java | 4 +-- ...HttpSecurityBeanDefinitionParserTests.java | 22 ++++++------ .../security/util/filtertest-valid.xml | 2 +- ...ncurrent-sessions.xml => session-mgmt.xml} | 0 .../filter-chain-performance-app-context.xml | 2 +- ...r.java => OpenIDAuthenticationFilter.java} | 8 ++--- ...IDAuthenticationProcessingFilterTests.java | 6 ++-- .../AuthenticationProcessingFilter.java | 6 ++-- .../LoginUrlAuthenticationEntryPoint.java | 4 +-- ...UsernamePasswordAuthenticationFilter.java} | 4 +-- .../ConcurrentSessionControlStrategy.java | 4 +-- .../ui/DefaultLoginPageGeneratingFilter.java | 12 +++---- ...DefaultLoginPageGeneratingFilterTests.java | 4 +-- ...amePasswordAuthenticationFilterTests.java} | 36 +++++++++---------- 16 files changed, 61 insertions(+), 61 deletions(-) rename docs/manual/src/docbook/{concurrent-sessions.xml => session-mgmt.xml} (100%) rename openid/src/main/java/org/springframework/security/openid/{OpenIDAuthenticationProcessingFilter.java => OpenIDAuthenticationFilter.java} (97%) rename web/src/main/java/org/springframework/security/web/authentication/{UsernamePasswordAuthenticationProcessingFilter.java => UsernamePasswordAuthenticationFilter.java} (97%) rename web/src/test/java/org/springframework/security/web/authentication/{AuthenticationProcessingFilterTests.java => UsernamePasswordAuthenticationFilterTests.java} (73%) diff --git a/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java b/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java index 683e1b7578..c81241bda8 100644 --- a/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java +++ b/config/src/main/java/org/springframework/security/config/http/AuthenticationConfigBuilder.java @@ -53,11 +53,11 @@ final class AuthenticationConfigBuilder { private static final String ATT_REALM = "realm"; private static final String DEF_REALM = "Spring Security Application"; - static final String OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS = "org.springframework.security.openid.OpenIDAuthenticationProcessingFilter"; + static final String OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS = "org.springframework.security.openid.OpenIDAuthenticationFilter"; static final String OPEN_ID_AUTHENTICATION_PROVIDER_CLASS = "org.springframework.security.openid.OpenIDAuthenticationProvider"; static final String OPEN_ID_CONSUMER_CLASS = "org.springframework.security.openid.OpenID4JavaConsumer"; static final String OPEN_ID_ATTRIBUTE_CLASS = "org.springframework.security.openid.OpenIDAttribute"; - static final String AUTHENTICATION_PROCESSING_FILTER_CLASS = "org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter"; + static final String AUTHENTICATION_PROCESSING_FILTER_CLASS = "org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"; private static final String ATT_AUTO_CONFIG = "auto-config"; diff --git a/config/src/main/java/org/springframework/security/config/http/DefaultFilterChainValidator.java b/config/src/main/java/org/springframework/security/config/http/DefaultFilterChainValidator.java index a55a59a835..3feb11d900 100644 --- a/config/src/main/java/org/springframework/security/config/http/DefaultFilterChainValidator.java +++ b/config/src/main/java/org/springframework/security/config/http/DefaultFilterChainValidator.java @@ -15,7 +15,7 @@ import org.springframework.security.web.access.intercept.DefaultFilterInvocation import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; import org.springframework.security.web.authentication.AnonymousProcessingFilter; import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter; +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.context.SecurityContextPersistenceFilter; @@ -51,7 +51,7 @@ public class DefaultFilterChainValidator implements FilterChainProxy.FilterChain */ private void checkFilterStack(List filters) { checkForDuplicates(SecurityContextPersistenceFilter.class, filters); - checkForDuplicates(UsernamePasswordAuthenticationProcessingFilter.class, filters); + checkForDuplicates(UsernamePasswordAuthenticationFilter.class, filters); checkForDuplicates(SessionManagementFilter.class, filters); checkForDuplicates(BasicProcessingFilter.class, filters); checkForDuplicates(SecurityContextHolderAwareRequestFilter.class, filters); diff --git a/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java b/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java index 94142c05cb..72adc8f0f4 100644 --- a/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/FilterChainProxyConfigTests.java @@ -34,7 +34,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.security.web.FilterChainProxy; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.context.SecurityContextPersistenceFilter; import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter; @@ -143,7 +143,7 @@ public class FilterChainProxyConfigTests { filters = filterChainProxy.getFilters("/another/nonspecificmatch"); assertEquals(3, filters.size()); assertTrue(filters.get(0) instanceof SecurityContextPersistenceFilter); - assertTrue(filters.get(1) instanceof UsernamePasswordAuthenticationProcessingFilter); + assertTrue(filters.get(1) instanceof UsernamePasswordAuthenticationFilter); assertTrue(filters.get(2) instanceof SecurityContextHolderAwareRequestFilter); } diff --git a/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java index 916303b9df..f6f4aa9825 100644 --- a/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java @@ -34,7 +34,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.session.SessionRegistryImpl; import org.springframework.security.openid.OpenID4JavaConsumer; import org.springframework.security.openid.OpenIDAttribute; -import org.springframework.security.openid.OpenIDAuthenticationProcessingFilter; +import org.springframework.security.openid.OpenIDAuthenticationFilter; import org.springframework.security.openid.OpenIDAuthenticationProvider; import org.springframework.security.util.FieldUtils; import org.springframework.security.web.FilterChainProxy; @@ -54,7 +54,7 @@ import org.springframework.security.web.authentication.LoginUrlAuthenticationEnt import org.springframework.security.web.authentication.RememberMeServices; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.security.web.authentication.logout.LogoutHandler; import org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor; @@ -100,8 +100,8 @@ public class HttpSecurityBeanDefinitionParserTests { public void beanClassNamesAreCorrect() throws Exception { assertEquals(DefaultWebSecurityExpressionHandler.class.getName(), HttpSecurityBeanDefinitionParser.EXPRESSION_HANDLER_CLASS); assertEquals(ExpressionBasedFilterInvocationSecurityMetadataSource.class.getName(), HttpSecurityBeanDefinitionParser.EXPRESSION_FIMDS_CLASS); - assertEquals(UsernamePasswordAuthenticationProcessingFilter.class.getName(), AUTHENTICATION_PROCESSING_FILTER_CLASS); - assertEquals(OpenIDAuthenticationProcessingFilter.class.getName(), OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS); + assertEquals(UsernamePasswordAuthenticationFilter.class.getName(), AUTHENTICATION_PROCESSING_FILTER_CLASS); + assertEquals(OpenIDAuthenticationFilter.class.getName(), OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS); assertEquals(OpenIDAuthenticationProvider.class.getName(), OPEN_ID_AUTHENTICATION_PROVIDER_CLASS); } @@ -130,7 +130,7 @@ public class HttpSecurityBeanDefinitionParserTests { assertTrue(filters.next() instanceof SecurityContextPersistenceFilter); assertTrue(filters.next() instanceof LogoutFilter); Object authProcFilter = filters.next(); - assertTrue(authProcFilter instanceof UsernamePasswordAuthenticationProcessingFilter); + assertTrue(authProcFilter instanceof UsernamePasswordAuthenticationFilter); assertTrue(filters.next() instanceof DefaultLoginPageGeneratingFilter); assertTrue(filters.next() instanceof BasicProcessingFilter); assertTrue(filters.next() instanceof RequestCacheAwareFilter); @@ -215,7 +215,7 @@ public class HttpSecurityBeanDefinitionParserTests { " " + "" + AUTH_PROVIDER_XML); // These will be matched by the default pattern "/**" - UsernamePasswordAuthenticationProcessingFilter filter = (UsernamePasswordAuthenticationProcessingFilter) getFilters("/anything").get(1); + UsernamePasswordAuthenticationFilter filter = (UsernamePasswordAuthenticationFilter) getFilters("/anything").get(1); assertEquals("/default", FieldUtils.getFieldValue(filter, "successHandler.defaultTargetUrl")); assertEquals(Boolean.TRUE, FieldUtils.getFieldValue(filter, "successHandler.alwaysUseDefaultTargetUrl")); } @@ -320,8 +320,8 @@ public class HttpSecurityBeanDefinitionParserTests { assertEquals("ROLE_A",attrs.get(0).getAttribute()); // Check the form login properties are set - UsernamePasswordAuthenticationProcessingFilter apf = (UsernamePasswordAuthenticationProcessingFilter) - getFilter(UsernamePasswordAuthenticationProcessingFilter.class); + UsernamePasswordAuthenticationFilter apf = (UsernamePasswordAuthenticationFilter) + getFilter(UsernamePasswordAuthenticationFilter.class); assertEquals("/defaultTarget", FieldUtils.getFieldValue(apf, "successHandler.defaultTargetUrl")); assertEquals("/authFailure", FieldUtils.getFieldValue(apf, "failureHandler.defaultFailureUrl")); @@ -690,7 +690,7 @@ public class HttpSecurityBeanDefinitionParserTests { Object sessionRegistryFromConcurrencyFilter = FieldUtils.getFieldValue( getFilter(ConcurrentSessionFilter.class), "sessionRegistry"); Object sessionRegistryFromFormLoginFilter = FieldUtils.getFieldValue( - getFilter(UsernamePasswordAuthenticationProcessingFilter.class),"sessionStrategy.sessionRegistry"); + getFilter(UsernamePasswordAuthenticationFilter.class),"sessionStrategy.sessionRegistry"); // Object sessionRegistryFromController = FieldUtils.getFieldValue(getConcurrentSessionController(),"sessionRegistry"); Object sessionRegistryFromMgmtFilter = FieldUtils.getFieldValue( getFilter(SessionManagementFilter.class),"sessionStrategy.sessionRegistry"); @@ -968,7 +968,7 @@ public class HttpSecurityBeanDefinitionParserTests { "" + "" + AUTH_PROVIDER_XML); - UsernamePasswordAuthenticationProcessingFilter apf = (UsernamePasswordAuthenticationProcessingFilter) getFilter(UsernamePasswordAuthenticationProcessingFilter.class); + UsernamePasswordAuthenticationFilter apf = (UsernamePasswordAuthenticationFilter) getFilter(UsernamePasswordAuthenticationFilter.class); AuthenticationSuccessHandler sh = (AuthenticationSuccessHandler) appContext.getBean("sh"); AuthenticationFailureHandler fh = (AuthenticationFailureHandler) appContext.getBean("fh"); assertSame(sh, FieldUtils.getFieldValue(apf, "successHandler")); @@ -1005,7 +1005,7 @@ public class HttpSecurityBeanDefinitionParserTests { " " + "" + AUTH_PROVIDER_XML); - OpenIDAuthenticationProcessingFilter apf = (OpenIDAuthenticationProcessingFilter) getFilter(OpenIDAuthenticationProcessingFilter.class); + OpenIDAuthenticationFilter apf = (OpenIDAuthenticationFilter) getFilter(OpenIDAuthenticationFilter.class); OpenID4JavaConsumer consumer = (OpenID4JavaConsumer) FieldUtils.getFieldValue(apf, "consumer"); List attributes = (List) FieldUtils.getFieldValue(consumer, "attributesToFetch"); diff --git a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml index 7e2a7823c3..7ba7248df8 100644 --- a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml +++ b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml @@ -31,7 +31,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc - + diff --git a/docs/manual/src/docbook/concurrent-sessions.xml b/docs/manual/src/docbook/session-mgmt.xml similarity index 100% rename from docs/manual/src/docbook/concurrent-sessions.xml rename to docs/manual/src/docbook/session-mgmt.xml diff --git a/itest/context/src/test/resources/filter-chain-performance-app-context.xml b/itest/context/src/test/resources/filter-chain-performance-app-context.xml index d37b985bf0..2e2c831a9a 100644 --- a/itest/context/src/test/resources/filter-chain-performance-app-context.xml +++ b/itest/context/src/test/resources/filter-chain-performance-app-context.xml @@ -39,7 +39,7 @@ - + diff --git a/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilter.java b/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationFilter.java similarity index 97% rename from openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilter.java rename to openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationFilter.java index 94f5f5d17e..5a875bc90f 100644 --- a/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilter.java +++ b/openid/src/main/java/org/springframework/security/openid/OpenIDAuthenticationFilter.java @@ -30,7 +30,7 @@ import org.springframework.security.authentication.AuthenticationServiceExceptio import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.util.StringUtils; @@ -63,7 +63,7 @@ import org.springframework.util.StringUtils; * @since 2.0 * @see OpenIDAuthenticationProvider */ -public class OpenIDAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { +public class OpenIDAuthenticationFilter extends AbstractAuthenticationProcessingFilter { //~ Static fields/initializers ===================================================================================== public static final String DEFAULT_CLAIMED_IDENTITY_FIELD = "j_username"; @@ -76,7 +76,7 @@ public class OpenIDAuthenticationProcessingFilter extends AbstractAuthentication //~ Constructors =================================================================================================== - public OpenIDAuthenticationProcessingFilter() { + public OpenIDAuthenticationFilter() { super("/j_spring_openid_security_check"); } @@ -158,7 +158,7 @@ public class OpenIDAuthenticationProcessingFilter extends AbstractAuthentication HttpSession session = request.getSession(false); if (session != null || getAllowSessionCreation()) { - request.getSession().setAttribute(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY, username); + request.getSession().setAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY, username); } } diff --git a/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilterTests.java b/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilterTests.java index 0c6c65c968..d90e181c1a 100644 --- a/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilterTests.java +++ b/openid/src/test/java/org/springframework/security/openid/OpenIDAuthenticationProcessingFilterTests.java @@ -13,13 +13,13 @@ import org.junit.Test; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.security.MockAuthenticationManager; -import org.springframework.security.openid.OpenIDAuthenticationProcessingFilter; +import org.springframework.security.openid.OpenIDAuthenticationFilter; import org.springframework.security.openid.OpenIDConsumerException; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; public class OpenIDAuthenticationProcessingFilterTests { - OpenIDAuthenticationProcessingFilter filter; + OpenIDAuthenticationFilter filter; private static final String REDIRECT_URL = "http://www.example.com/redirect"; private static final String CLAIMED_IDENTITY_URL = "http://www.example.com/identity"; private static final String REQUEST_PATH = "/j_spring_openid_security_check"; @@ -28,7 +28,7 @@ public class OpenIDAuthenticationProcessingFilterTests { @Before public void setUp() throws Exception { - filter = new OpenIDAuthenticationProcessingFilter(); + filter = new OpenIDAuthenticationFilter(); filter.setConsumer(new MockOpenIDConsumer(REDIRECT_URL)); SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); filter.setAuthenticationSuccessHandler(new SavedRequestAwareAuthenticationSuccessHandler()); diff --git a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java index 9caf795668..78e2341f68 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/AuthenticationProcessingFilter.java @@ -3,13 +3,13 @@ package org.springframework.security.web.authentication; /** * Renamed class, retained for backwards compatibility. *

- * See {@link UsernamePasswordAuthenticationProcessingFilter}. + * See {@link UsernamePasswordAuthenticationFilter}. * * @author Luke Taylor * @version $Id$ - * @deprecated Use UsernamePasswordAuthenticationProcessingFilter instead. + * @deprecated Use UsernamePasswordAuthenticationFilter instead. */ -public class AuthenticationProcessingFilter extends UsernamePasswordAuthenticationProcessingFilter { +public class AuthenticationProcessingFilter extends UsernamePasswordAuthenticationFilter { } diff --git a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java index c6a7fcf1ce..29a037de8f 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/LoginUrlAuthenticationEntryPoint.java @@ -43,7 +43,7 @@ import org.springframework.util.StringUtils; /** * Used by the {@link ExceptionTranslationFilter} to commence a form login - * authentication via the {@link UsernamePasswordAuthenticationProcessingFilter}. This object + * authentication via the {@link UsernamePasswordAuthenticationFilter}. This object * holds the location of the login form, relative to the web app context path, * and is used to commence a redirect to that form. *

@@ -220,7 +220,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin } /** - * The URL where the UsernamePasswordAuthenticationProcessingFilter login + * The URL where the UsernamePasswordAuthenticationFilter login * page can be found. Should be relative to the web-app context path, and * include a leading / */ diff --git a/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationProcessingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java similarity index 97% rename from web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationProcessingFilter.java rename to web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java index 34e0216eab..7639a64739 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationProcessingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilter.java @@ -46,7 +46,7 @@ import org.springframework.util.Assert; * @version $Id$ * @since 3.0 */ -public class UsernamePasswordAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { +public class UsernamePasswordAuthenticationFilter extends AbstractAuthenticationProcessingFilter { //~ Static fields/initializers ===================================================================================== public static final String SPRING_SECURITY_FORM_USERNAME_KEY = "j_username"; @@ -59,7 +59,7 @@ public class UsernamePasswordAuthenticationProcessingFilter extends AbstractAuth //~ Constructors =================================================================================================== - public UsernamePasswordAuthenticationProcessingFilter() { + public UsernamePasswordAuthenticationFilter() { super("/j_spring_security_check"); } diff --git a/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java b/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java index f348ffbd0c..fbddf9c58a 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java +++ b/web/src/main/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategy.java @@ -15,7 +15,7 @@ import org.springframework.security.core.SpringSecurityMessageSource; import org.springframework.security.core.session.SessionInformation; import org.springframework.security.core.session.SessionRegistry; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.session.ConcurrentSessionFilter; import org.springframework.security.web.session.SessionManagementFilter; import org.springframework.util.Assert; @@ -33,7 +33,7 @@ import org.springframework.util.Assert; * set to true, however, the user will be prevented from starting a new authenticated session. *

* This strategy can be injected into both the {@link SessionManagementFilter} and instances of - * {@link AbstractAuthenticationProcessingFilter} (typically {@link UsernamePasswordAuthenticationProcessingFilter}). + * {@link AbstractAuthenticationProcessingFilter} (typically {@link UsernamePasswordAuthenticationFilter}). * * @author Luke Taylor * @version $Id$ diff --git a/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java b/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java index 836637b9d8..1f7ca09cc9 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java +++ b/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java @@ -13,7 +13,7 @@ import javax.servlet.http.HttpSession; import org.springframework.beans.BeanWrapperImpl; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationProcessingFilter; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices; import org.springframework.web.filter.GenericFilterBean; @@ -41,18 +41,18 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean { private String openIDrememberMeParameter; public DefaultLoginPageGeneratingFilter(AbstractAuthenticationProcessingFilter filter) { - if (filter instanceof UsernamePasswordAuthenticationProcessingFilter) { - init((UsernamePasswordAuthenticationProcessingFilter)filter, null); + if (filter instanceof UsernamePasswordAuthenticationFilter) { + init((UsernamePasswordAuthenticationFilter)filter, null); } else { init(null, filter); } } - public DefaultLoginPageGeneratingFilter(UsernamePasswordAuthenticationProcessingFilter authFilter, AbstractAuthenticationProcessingFilter openIDFilter) { + public DefaultLoginPageGeneratingFilter(UsernamePasswordAuthenticationFilter authFilter, AbstractAuthenticationProcessingFilter openIDFilter) { init(authFilter, openIDFilter); } - private void init(UsernamePasswordAuthenticationProcessingFilter authFilter, AbstractAuthenticationProcessingFilter openIDFilter) { + private void init(UsernamePasswordAuthenticationFilter authFilter, AbstractAuthenticationProcessingFilter openIDFilter) { if (authFilter != null) { formLoginEnabled = true; authenticationUrl = authFilter.getFilterProcessesUrl(); @@ -101,7 +101,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean { HttpSession session = request.getSession(false); if(session != null) { - lastUser = (String) session.getAttribute(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY); + lastUser = (String) session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY); AuthenticationException ex = (AuthenticationException) session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY); errorMsg = ex != null ? ex.getMessage() : "none"; if (lastUser == null) { diff --git a/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java index 4db9b03eae..9b58de106c 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/DefaultLoginPageGeneratingFilterTests.java @@ -29,7 +29,7 @@ public class DefaultLoginPageGeneratingFilterTests { @Test public void generatingPageWithAuthenticationProcessingFilterOnlyIsSuccessFul() throws Exception { - DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(new UsernamePasswordAuthenticationProcessingFilter()); + DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(new UsernamePasswordAuthenticationFilter()); filter.doFilter(new MockHttpServletRequest("GET", "/spring_security_login"), new MockHttpServletResponse(), chain); filter.doFilter(new MockHttpServletRequest("GET", "/spring_security_login;pathparam=unused"), new MockHttpServletResponse(), chain); } @@ -60,7 +60,7 @@ public class DefaultLoginPageGeneratingFilterTests { /* SEC-1111 */ @Test public void handlesNonIso8859CharsInErrorMessage() throws Exception { - DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(new UsernamePasswordAuthenticationProcessingFilter()); + DefaultLoginPageGeneratingFilter filter = new DefaultLoginPageGeneratingFilter(new UsernamePasswordAuthenticationFilter()); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/spring_security_login"); request.addParameter("login_error", "true"); MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor(); diff --git a/web/src/test/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java similarity index 73% rename from web/src/test/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterTests.java rename to web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java index 30a5ac50d5..b05497819e 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AuthenticationProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/UsernamePasswordAuthenticationFilterTests.java @@ -35,21 +35,21 @@ import org.springframework.security.core.AuthenticationException; /** - * Tests {@link UsernamePasswordAuthenticationProcessingFilter}. + * Tests {@link UsernamePasswordAuthenticationFilter}. * * @author Ben Alex * @version $Id$ */ -public class AuthenticationProcessingFilterTests extends TestCase { +public class UsernamePasswordAuthenticationFilterTests extends TestCase { //~ Methods ======================================================================================================== @Test public void testNormalOperation() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod"); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod"); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); assertEquals("/j_spring_security_check", filter.getFilterProcessesUrl()); filter.setAuthenticationManager(createAuthenticationManager()); // filter.init(null); @@ -57,16 +57,16 @@ public class AuthenticationProcessingFilterTests extends TestCase { Authentication result = filter.attemptAuthentication(request, new MockHttpServletResponse()); assertTrue(result != null); assertEquals("rod", request.getSession().getAttribute( - UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY)); + UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY)); assertEquals("127.0.0.1", ((WebAuthenticationDetails) result.getDetails()).getRemoteAddress()); } @Test public void testNullPasswordHandledGracefully() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod"); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod"); - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); filter.setAuthenticationManager(createAuthenticationManager()); assertNotNull(filter.attemptAuthentication(request, new MockHttpServletResponse())); } @@ -74,16 +74,16 @@ public class AuthenticationProcessingFilterTests extends TestCase { @Test public void testNullUsernameHandledGracefully() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); filter.setAuthenticationManager(createAuthenticationManager()); assertNotNull(filter.attemptAuthentication(request, new MockHttpServletResponse())); } @Test public void testUsingDifferentParameterNamesWorksAsExpected() throws ServletException { - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); filter.setAuthenticationManager(createAuthenticationManager()); filter.setUsernameParameter("x"); filter.setPasswordParameter("y"); @@ -100,10 +100,10 @@ public class AuthenticationProcessingFilterTests extends TestCase { @Test public void testSpacesAreTrimmedCorrectlyFromUsername() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, " rod "); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, " rod "); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, "koala"); - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); filter.setAuthenticationManager(createAuthenticationManager()); Authentication result = filter.attemptAuthentication(request, new MockHttpServletResponse()); @@ -113,8 +113,8 @@ public class AuthenticationProcessingFilterTests extends TestCase { @Test public void testFailedAuthenticationThrowsException() { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); - request.addParameter(UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod"); - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + request.addParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, "rod"); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); AuthenticationManager am = mock(AuthenticationManager.class); when(am.authenticate(any(Authentication.class))).thenThrow(new BadCredentialsException("")); filter.setAuthenticationManager(am); @@ -127,7 +127,7 @@ public class AuthenticationProcessingFilterTests extends TestCase { // Check username has still been set assertEquals("rod", request.getSession().getAttribute( - UsernamePasswordAuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY)); + UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY)); } /** @@ -137,7 +137,7 @@ public class AuthenticationProcessingFilterTests extends TestCase { public void noSessionIsCreatedIfAllowSessionCreationIsFalse() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); - UsernamePasswordAuthenticationProcessingFilter filter = new UsernamePasswordAuthenticationProcessingFilter(); + UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter(); filter.setAllowSessionCreation(false); filter.setAuthenticationManager(createAuthenticationManager());