if(ObjectsFilter.class.isInstance(filter)) { // go find the ObjectHandler
HttpServletRequest httpRequest = (HttpServletRequest)request;
filter = this.m_objectsRESTFilterMatcher.getObjectsHandler(httpRequest);
if (filter == null) {
logger.error("No FeSL REST objects handler found for \"{}\"", httpRequest.getPathInfo());
throw new ServletException(new PEPException("No FeSL REST objects handler found for " + servletPath));
}
}
try {
// handle the request if we have a filter
if (filter != null) {
// substitute our own request object that manages parameters
try {
req = new ParameterRequestWrapper((HttpServletRequest) request);
} catch (Exception e) {
throw new PEPException(e);
}
logger.debug("Filtering URI: [{}] with: [{}]" , req.getRequestURI(), filter.getClass().getName());
if(ResponseHandlingRESTFilter.class.isInstance(filter)) {
// substitute our own response object that captures the data
res = new DataResponseWrapper(((HttpServletResponse) response));
// get a handle for the original OutputStream
out = response.getOutputStream();
logger.debug("Filtering will include post-processing the response");
}
reqCtx = filter.handleRequest(req, res);
if (reqCtx != null) {
resCtx = m_ctxHandler.evaluate(reqCtx);
enforce(resCtx);
}
// pass the request along to the next chain...
chain.doFilter(req, res);
} else {
// there must always be a filter, even if it is a NOOP
logger.error("No FeSL REST filter found for \"{}\"", servletPath);
throw new PEPException("No FeSL REST filter found for " + servletPath);
}
if(ResponseHandlingRESTFilter.class.isInstance(filter)) {
// handle the response if we have a non-null response handling filter
reqCtx = ((ResponseHandlingRESTFilter)filter).handleResponse(req, res);