}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
if (request instanceof SlingHttpServletRequest && response instanceof SlingHttpServletResponse) {
SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;
RequestPathInfo pathInfo = slingRequest.getRequestPathInfo();
Resource definitionResource = findUrlFilterDefinitionResource(slingRequest.getResource(),
slingRequest.getResourceResolver());
if (definitionResource != null) {
logger.debug("found url filter definition resource at {}", definitionResource.getPath());
ValueMap properties = definitionResource.adaptTo(ValueMap.class);
if (properties != null) {
if (checkSelector(pathInfo, properties) && checkSuffix(pathInfo, properties)
&& checkExtension(pathInfo, properties)) {
logger.debug("url filter definition resource at {} passed for request {}.",
definitionResource.getPath(), slingRequest.getRequestPathInfo());
} else {
logger.info("url filter definition resource at {} FAILED for request {}.",
definitionResource.getPath(), slingRequest.getRequestPathInfo());
slingResponse.sendError(403);
return;
}
}
}