Removed unused import in DelegatingAuthenticationEntryPoint and corrected test class name.

This commit is contained in:
Luke Taylor 2010-02-14 23:31:31 +00:00
parent d30e31d816
commit c1133d1ef3
2 changed files with 13 additions and 17 deletions

View File

@ -17,7 +17,6 @@ package org.springframework.security.web.authentication;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -34,27 +33,25 @@ import org.springframework.util.Assert;
/** /**
* An AuthenticationEntryPoint which selects a concrete EntryPoint based on a * An AuthenticationEntryPoint which selects a concrete EntryPoint based on a
* RequestMatcher evaluation. * RequestMatcher evaluation.
* *
* <p>A configuration might look like this:</p> * <p>A configuration might look like this:</p>
* *
* <pre> * <pre>
* &lt;bean id=&quot;daep&quot; class=&quot;org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint&quot;&gt; * &lt;bean id=&quot;daep&quot; class=&quot;org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint&quot;&gt;
* &lt;constructor-arg&gt; * &lt;constructor-arg&gt;
* &lt;map&gt; * &lt;map&gt;
* &lt;entry key=&quot;hasIpAddress('192.168.1.0/24') and hasHeader('User-Agent','Mozilla')&quot; value-ref=&quot;firstAEP&quot; /&gt; * &lt;entry key=&quot;hasIpAddress('192.168.1.0/24') and hasHeader('User-Agent','Mozilla')&quot; value-ref=&quot;firstAEP&quot; /&gt;
* &lt;entry key=&quot;hasHeader('User-Agent','MSIE')&quot; value-ref=&quot;secondAEP&quot; /&gt; * &lt;entry key=&quot;hasHeader('User-Agent','MSIE')&quot; value-ref=&quot;secondAEP&quot; /&gt;
* &lt;/map&gt; * &lt;/map&gt;
* &lt;/constructor-arg&gt; * &lt;/constructor-arg&gt;
* &lt;property name=&quot;defaultEntryPoint&quot; ref=&quot;defaultAEP&quot;/&gt; * &lt;property name=&quot;defaultEntryPoint&quot; ref=&quot;defaultAEP&quot;/&gt;
* &lt;/bean&gt; * &lt;/bean&gt;
* </pre> * </pre>
* *
* This example uses the {@link RequestMatcherEditor} which creates {@link ELRequestMatcher} instances for the map keys. * This example uses the {@link RequestMatcherEditor} which creates {@link ELRequestMatcher} instances for the map keys.
* *
*
* @author Mike Wiesner * @author Mike Wiesner
* @since 3.0.2 * @since 3.0.2
* @version $Id:$
*/ */
public class DelegatingAuthenticationEntryPoint implements public class DelegatingAuthenticationEntryPoint implements
AuthenticationEntryPoint, InitializingBean { AuthenticationEntryPoint, InitializingBean {
@ -84,17 +81,17 @@ public class DelegatingAuthenticationEntryPoint implements
{ {
entryPoints.get(requestMatcher).commence(request, response, authException); entryPoints.get(requestMatcher).commence(request, response, authException);
return; return;
} }
} }
// No EntryPoint matched, use defaultEntryPoint // No EntryPoint matched, use defaultEntryPoint
defaultEntryPoint.commence(request, response, authException); defaultEntryPoint.commence(request, response, authException);
} }
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
Assert.notEmpty(entryPoints, "entryPoints must be specified"); Assert.notEmpty(entryPoints, "entryPoints must be specified");
Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified"); Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified");
} }
} }

View File

@ -1,6 +1,5 @@
package org.springframework.security.web.authentication; package org.springframework.security.web.authentication;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -19,7 +18,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:org/springframework/security/web/authentication/DelegatingAuthenticationEntryPointTest-context.xml") @ContextConfiguration(locations = "classpath:org/springframework/security/web/authentication/DelegatingAuthenticationEntryPointTest-context.xml")
public class DelegatinAuthenticationEntryPointContextTest { public class DelegatingAuthenticationEntryPointContextTest {
@Autowired @Autowired
private DelegatingAuthenticationEntryPoint daep; private DelegatingAuthenticationEntryPoint daep;
@ -40,7 +39,7 @@ public class DelegatinAuthenticationEntryPointContextTest {
request.addHeader("User-Agent", "Mozilla/5.0"); request.addHeader("User-Agent", "Mozilla/5.0");
daep.commence(request, null, null); daep.commence(request, null, null);
verify(firstAEP).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(HttpServletResponse.class),
any(AuthenticationException.class)); any(AuthenticationException.class));
@ -53,7 +52,7 @@ public class DelegatinAuthenticationEntryPointContextTest {
request.setRemoteAddr("192.168.1.10"); request.setRemoteAddr("192.168.1.10");
daep.commence(request, null, null); daep.commence(request, null, null);
verify(defaultAEP).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(HttpServletResponse.class),
any(AuthenticationException.class)); any(AuthenticationException.class));