|
@@ -31,8 +31,8 @@ import org.springframework.security.web.util.RequestMatcherEditor;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * An AuthenticationEntryPoint which selects a concrete EntryPoint based on a
|
|
|
|
- * RequestMatcher evaluation.
|
|
|
|
|
|
+ * An {@code AuthenticationEntryPoint} which selects a concrete {@code AuthenticationEntryPoint} based on a
|
|
|
|
+ * {@link RequestMatcher} evaluation.
|
|
*
|
|
*
|
|
* <p>A configuration might look like this:</p>
|
|
* <p>A configuration might look like this:</p>
|
|
*
|
|
*
|
|
@@ -48,37 +48,27 @@ import org.springframework.util.Assert;
|
|
* </bean>
|
|
* </bean>
|
|
* </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 a {@link ELRequestMatcher} instances for the map
|
|
|
|
+ * keys.
|
|
*
|
|
*
|
|
* @author Mike Wiesner
|
|
* @author Mike Wiesner
|
|
* @since 3.0.2
|
|
* @since 3.0.2
|
|
*/
|
|
*/
|
|
-public class DelegatingAuthenticationEntryPoint implements
|
|
|
|
- AuthenticationEntryPoint, InitializingBean {
|
|
|
|
|
|
+public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPoint, InitializingBean {
|
|
|
|
|
|
private LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints;
|
|
private LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints;
|
|
private AuthenticationEntryPoint defaultEntryPoint;
|
|
private AuthenticationEntryPoint defaultEntryPoint;
|
|
|
|
|
|
- public DelegatingAuthenticationEntryPoint(
|
|
|
|
- LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints) {
|
|
|
|
|
|
+ public DelegatingAuthenticationEntryPoint(LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints) {
|
|
this.entryPoints = entryPoints;
|
|
this.entryPoints = entryPoints;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * EntryPoint which is used when no RequestMatcher returned true
|
|
|
|
- */
|
|
|
|
- public void setDefaultEntryPoint(AuthenticationEntryPoint defaultEntryPoint) {
|
|
|
|
- this.defaultEntryPoint = defaultEntryPoint;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public void commence(HttpServletRequest request,
|
|
public void commence(HttpServletRequest request,
|
|
HttpServletResponse response, AuthenticationException authException)
|
|
HttpServletResponse response, AuthenticationException authException)
|
|
throws IOException, ServletException {
|
|
throws IOException, ServletException {
|
|
|
|
|
|
for (RequestMatcher requestMatcher : entryPoints.keySet()) {
|
|
for (RequestMatcher requestMatcher : entryPoints.keySet()) {
|
|
- if (requestMatcher.matches(request))
|
|
|
|
- {
|
|
|
|
|
|
+ if (requestMatcher.matches(request)) {
|
|
entryPoints.get(requestMatcher).commence(request, response, authException);
|
|
entryPoints.get(requestMatcher).commence(request, response, authException);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -88,10 +78,16 @@ public class DelegatingAuthenticationEntryPoint implements
|
|
defaultEntryPoint.commence(request, response, authException);
|
|
defaultEntryPoint.commence(request, response, authException);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * EntryPoint which is used when no RequestMatcher returned true
|
|
|
|
+ */
|
|
|
|
+ public void setDefaultEntryPoint(AuthenticationEntryPoint defaultEntryPoint) {
|
|
|
|
+ this.defaultEntryPoint = defaultEntryPoint;
|
|
|
|
+ }
|
|
|
|
+
|
|
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");
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|