diff --git a/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java b/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java index 070f9da35e..d8ab2e1783 100644 --- a/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java +++ b/web/src/main/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPoint.java @@ -17,7 +17,6 @@ package org.springframework.security.web.authentication; import java.io.IOException; import java.util.LinkedHashMap; -import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -34,27 +33,25 @@ import org.springframework.util.Assert; /** * An AuthenticationEntryPoint which selects a concrete EntryPoint based on a * RequestMatcher evaluation. - * + * *
A configuration might look like this:
- * + * ** <bean id="daep" class="org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint"> * <constructor-arg> * <map> * <entry key="hasIpAddress('192.168.1.0/24') and hasHeader('User-Agent','Mozilla')" value-ref="firstAEP" /> - * <entry key="hasHeader('User-Agent','MSIE')" value-ref="secondAEP" /> + * <entry key="hasHeader('User-Agent','MSIE')" value-ref="secondAEP" /> * </map> * </constructor-arg> * <property name="defaultEntryPoint" ref="defaultAEP"/> * </bean> *- * + * * This example uses the {@link RequestMatcherEditor} which creates {@link ELRequestMatcher} instances for the map keys. - * - * + * * @author Mike Wiesner * @since 3.0.2 - * @version $Id:$ */ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean { @@ -84,17 +81,17 @@ public class DelegatingAuthenticationEntryPoint implements { entryPoints.get(requestMatcher).commence(request, response, authException); return; - } + } } - + // No EntryPoint matched, use defaultEntryPoint defaultEntryPoint.commence(request, response, authException); } public void afterPropertiesSet() throws Exception { Assert.notEmpty(entryPoints, "entryPoints must be specified"); - Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified"); + Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified"); } - - + + } diff --git a/web/src/test/java/org/springframework/security/web/authentication/DelegatinAuthenticationEntryPointContextTest.java b/web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPointContextTest.java similarity index 94% rename from web/src/test/java/org/springframework/security/web/authentication/DelegatinAuthenticationEntryPointContextTest.java rename to web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPointContextTest.java index 4d7cd7f144..f8302167de 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/DelegatinAuthenticationEntryPointContextTest.java +++ b/web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationEntryPointContextTest.java @@ -1,6 +1,5 @@ package org.springframework.security.web.authentication; -import static org.junit.Assert.*; import static org.mockito.Mockito.*; import javax.servlet.http.HttpServletRequest; @@ -19,7 +18,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:org/springframework/security/web/authentication/DelegatingAuthenticationEntryPointTest-context.xml") -public class DelegatinAuthenticationEntryPointContextTest { +public class DelegatingAuthenticationEntryPointContextTest { @Autowired private DelegatingAuthenticationEntryPoint daep; @@ -40,7 +39,7 @@ public class DelegatinAuthenticationEntryPointContextTest { request.addHeader("User-Agent", "Mozilla/5.0"); daep.commence(request, null, null); verify(firstAEP).commence(request, null, null); - verify(defaultAEP, never()).commence(any(HttpServletRequest.class), + verify(defaultAEP, never()).commence(any(HttpServletRequest.class), any(HttpServletResponse.class), any(AuthenticationException.class)); @@ -53,7 +52,7 @@ public class DelegatinAuthenticationEntryPointContextTest { request.setRemoteAddr("192.168.1.10"); daep.commence(request, null, null); verify(defaultAEP).commence(request, null, null); - verify(firstAEP, never()).commence(any(HttpServletRequest.class), + verify(firstAEP, never()).commence(any(HttpServletRequest.class), any(HttpServletResponse.class), any(AuthenticationException.class));