mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 14:52:24 +00:00
Removed unused import in DelegatingAuthenticationEntryPoint and corrected test class name.
This commit is contained in:
parent
d30e31d816
commit
c1133d1ef3
@ -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.
|
||||
*
|
||||
*
|
||||
* <p>A configuration might look like this:</p>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <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>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* 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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user