Examples of FilterChain


Examples of javax.servlet.FilterChain

        // the response output stream if reset does not reset this
        response = new ErrorResponseWrapper(response);

        Filter[] filters = filterManager.getFilters(FilterChainType.ERROR);
        if (filters != null && filters.length > 0) {
            FilterChain processor = new AbstractSlingFilterChain(filters) {

                @Override
                protected void render(SlingHttpServletRequest request,
                        SlingHttpServletResponse response) throws IOException {
                    errorHandler.handleError(status, message, request, response);
                }
            };
            request.getRequestProgressTracker().log(
                "Applying " + FilterChainType.ERROR + " filters");

            try {
                processor.doFilter(request, response);
            } catch (ServletException se) {
                throw new SlingServletException(se);
            }
        } else {
            errorHandler.handleError(status, message, request, response);
View Full Code Here

Examples of javax.servlet.FilterChain

        // the response output stream if reset does not reset this
        response = new ErrorResponseWrapper(response);

        Filter[] filters = filterManager.getFilters(FilterChainType.ERROR);
        if (filters != null && filters.length > 0) {
            FilterChain processor = new AbstractSlingFilterChain(filters) {

                @Override
                protected void render(SlingHttpServletRequest request,
                        SlingHttpServletResponse response) throws IOException {
                    errorHandler.handleError(throwable, request, response);
                }
            };
            request.getRequestProgressTracker().log(
                "Applying " + FilterChainType.ERROR + " filters");

            try {
                processor.doFilter(request, response);
            } catch (ServletException se) {
                throw new SlingServletException(se);
            }
        } else {
            errorHandler.handleError(throwable, request, response);
View Full Code Here

Examples of javax.servlet.FilterChain

  }

  protected void applyFilter(MockHttpServletRequest request, MockHttpServletResponse response, String username, String password) throws IOException, ServletException {
    String credentials = username + ":" + password;
    request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(credentials.getBytes())));
    FilterChain filterChain = new MockFilterChain();

    authenticationFilter.doFilter(request, response, filterChain);
  }
View Full Code Here

Examples of javax.servlet.FilterChain

        // TODO: Thread safety!
        // Assume request handled if filter chain is NOT executed
        final boolean[] res = new boolean[] {true};
        try {
            filter.doFilter(request, response, new FilterChain() {
                public void doFilter(final ServletRequest request,
                        final ServletResponse response) throws IOException,
                        ServletException {
                    res[0] = handler.service((HttpServletRequest) request,
                            (HttpServletResponse) response);
View Full Code Here

Examples of javax.servlet.FilterChain

        // TODO: Thread safety!
        // Assume request handled if filter chain is NOT executed
        final boolean[] res = new boolean[] {true};
        try {
            filter.doFilter(globals.getHTTPServletRequest(), globals
                    .getHTTPServletResponse(), new FilterChain() {
                public void doFilter(final ServletRequest req,
                        final ServletResponse resp) throws IOException,
                        ServletException {
                    res[0] = handler.service(request, response);
                }
View Full Code Here

Examples of javax.servlet.FilterChain

        this.servletPipeline = servletPipeline;
    }

    public void dispatch(HttpServletRequest req, HttpServletResponse res, FilterChain proceedingChain) throws ServletException, IOException
    {
        FilterChain chain = new InvocationFilterChain(this.handlers, this.servletPipeline, proceedingChain);

        if (this.servletPipeline.hasServletsMapped())
        {
            req = new FilterRequestWrapper(req);
        }

        chain.doFilter(req, res);
    }
View Full Code Here

Examples of javax.servlet.FilterChain

    public void testHandleFound() throws Exception
    {
        FilterHandler h1 = createHandler("/a", 0);
        HttpServletRequest req = mock(HttpServletRequest.class);
        HttpServletResponse res = mock(HttpServletResponse.class);
        FilterChain chain = mock(FilterChain.class);
        when(this.context.handleSecurity(req, res)).thenReturn(true);

        when(req.getPathInfo()).thenReturn("/a");
        h1.handle(req, res, chain);
View Full Code Here

Examples of javax.servlet.FilterChain

    public void testHandleFoundContextRoot() throws Exception
    {
        FilterHandler h1 = createHandler("/", 0);
        HttpServletRequest req = mock(HttpServletRequest.class);
        HttpServletResponse res = mock(HttpServletResponse.class);
        FilterChain chain = mock(FilterChain.class);
        when(this.context.handleSecurity(req, res)).thenReturn(true);

        when(req.getPathInfo()).thenReturn(null);
        h1.handle(req, res, chain);
View Full Code Here

Examples of javax.servlet.FilterChain

    public void testHandleFoundForbidden() throws Exception
    {
        FilterHandler h1 = createHandler("/a", 0);
        HttpServletRequest req = mock(HttpServletRequest.class);
        HttpServletResponse res = mock(HttpServletResponse.class);
        FilterChain chain = mock(FilterChain.class);

        when(req.getPathInfo()).thenReturn("/a");
        // Default behaviour: uncomitted response and default status code...
        when(res.isCommitted()).thenReturn(false);
        when(res.getStatus()).thenReturn(SC_OK);
View Full Code Here

Examples of javax.servlet.FilterChain

    public void testHandleFoundForbiddenCommittedOwnResponse() throws Exception
    {
        FilterHandler h1 = createHandler("/a", 0);
        HttpServletRequest req = mock(HttpServletRequest.class);
        HttpServletResponse res = mock(HttpServletResponse.class);
        FilterChain chain = mock(FilterChain.class);

        when(req.getPathInfo()).thenReturn("/a");
        // Simulate an already committed response...
        when(res.isCommitted()).thenReturn(true);
        when(res.getStatus()).thenReturn(SC_OK);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.