SEC-2339: Added Logical (Or, And, Negated) RequestMatchers

This commit is contained in:
Rob Winch
2013-09-23 20:55:49 -05:00
parent 28fb6ba14b
commit ddc0ef7ab3
7 changed files with 488 additions and 25 deletions

View File

@@ -65,6 +65,7 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn
import org.springframework.security.web.session.HttpSessionEventPublisher;
import org.springframework.security.web.util.AntPathRequestMatcher;
import org.springframework.security.web.util.AnyRequestMatcher;
import org.springframework.security.web.util.OrRequestMatcher;
import org.springframework.security.web.util.RegexRequestMatcher;
import org.springframework.security.web.util.RequestMatcher;
import org.springframework.util.Assert;
@@ -1346,29 +1347,4 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
}
return apply(configurer);
}
/**
* Internal {@link RequestMatcher} instance used by {@link RequestMatcher}
* that will match if any of the passed in {@link RequestMatcher} instances
* match.
*
* @author Rob Winch
* @since 3.2
*/
private static final class OrRequestMatcher implements RequestMatcher {
private final List<RequestMatcher> requestMatchers;
private OrRequestMatcher(List<RequestMatcher> requestMatchers) {
this.requestMatchers = requestMatchers;
}
public boolean matches(HttpServletRequest request) {
for(RequestMatcher matcher : requestMatchers) {
if(matcher.matches(request)) {
return true;
}
}
return false;
}
}
}