Search in sources :

Example 1 with RequestSecurityProcessorChainImpl

use of org.craftercms.security.processors.impl.RequestSecurityProcessorChainImpl in project profile by craftercms.

the class RequestSecurityFilter method doFilterInternal.

/**
 * Passes the request through the chain of {@link RequestSecurityProcessor}s.
 *
 * @param request
 * @param response
 * @param chain
 * @throws IOException
 * @throws ServletException
 */
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
    RequestContext context = RequestContext.getCurrent();
    if (context == null) {
        context = createRequestContext(request, response);
    }
    List<RequestSecurityProcessor> finalSecurityProcessors = new ArrayList<>(securityProcessors);
    finalSecurityProcessors.add(getLastProcessorInChain(chain));
    Iterator<RequestSecurityProcessor> processorIter = finalSecurityProcessors.iterator();
    RequestSecurityProcessorChain processorChain = new RequestSecurityProcessorChainImpl(processorIter);
    try {
        processorChain.processRequest(context);
    } catch (IOException | ServletException | RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new ServletException(e.getMessage(), e);
    }
}
Also used : ServletException(javax.servlet.ServletException) RequestSecurityProcessorChain(org.craftercms.security.processors.RequestSecurityProcessorChain) RequestSecurityProcessor(org.craftercms.security.processors.RequestSecurityProcessor) ArrayList(java.util.ArrayList) RequestContext(org.craftercms.commons.http.RequestContext) IOException(java.io.IOException) RequestSecurityProcessorChainImpl(org.craftercms.security.processors.impl.RequestSecurityProcessorChainImpl) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ServletException (javax.servlet.ServletException)1 RequestContext (org.craftercms.commons.http.RequestContext)1 RequestSecurityProcessor (org.craftercms.security.processors.RequestSecurityProcessor)1 RequestSecurityProcessorChain (org.craftercms.security.processors.RequestSecurityProcessorChain)1 RequestSecurityProcessorChainImpl (org.craftercms.security.processors.impl.RequestSecurityProcessorChainImpl)1