package com.moral.security.auth.jwt;
|
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.OrRequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.util.Assert;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* SkipPathRequestMatcher
|
*
|
* @author vladimir.stankovic
|
*
|
* Aug 19, 2016
|
*/
|
public class SkipPathRequestMatcher implements RequestMatcher {
|
private OrRequestMatcher matchers;
|
private RequestMatcher processingMatcher;
|
|
public SkipPathRequestMatcher(List<String> pathsToSkip, String processingPath) {
|
Assert.notNull(pathsToSkip);
|
List<RequestMatcher> m = pathsToSkip.stream().map(path -> new AntPathRequestMatcher(path)).collect(Collectors.toList());
|
matchers = new OrRequestMatcher(m);
|
processingMatcher = new AntPathRequestMatcher(processingPath);
|
}
|
|
@Override
|
public boolean matches(HttpServletRequest request) {
|
if (matchers.matches(request)) {
|
return false;
|
}
|
return processingMatcher.matches(request) ? true : false;
|
}
|
}
|