Package javax.servlet

Examples of javax.servlet.FilterChain


        ServletRequestEvent request_event=null;
       
        try
        {
            ServletHolder servlet_holder=null;
            FilterChain chain=null;
           
            // find the servlet
            if (target.startsWith("/"))
            {
                // Look for the servlet by path
                PathMap.Entry entry=getHolderEntry(target);
                if (entry!=null)
                {
                    servlet_holder=(ServletHolder)entry.getValue();
                    base_request.setServletName(servlet_holder.getName());
                    base_request.setRoleMap(servlet_holder.getRoleMap());
                    if(Log.isDebugEnabled())Log.debug("servlet="+servlet_holder);
                   
                    String servlet_path_spec=(String)entry.getKey();
                    String servlet_path=entry.getMapped()!=null?entry.getMapped():PathMap.pathMatch(servlet_path_spec,target);
                    String path_info=PathMap.pathInfo(servlet_path_spec,target);
                   
                    if (type==INCLUDE)
                    {
                        base_request.setAttribute(Dispatcher.__INCLUDE_SERVLET_PATH,servlet_path);
                        base_request.setAttribute(Dispatcher.__INCLUDE_PATH_INFO, path_info);
                    }
                    else
                    {
                        base_request.setServletPath(servlet_path);
                        base_request.setPathInfo(path_info);
                    }
                   
                    if (servlet_holder!=null && _filterMappings!=null && _filterMappings.length>0)
                        chain=getFilterChain(type, target, servlet_holder);
                }     
            }
            else
            {
                // look for a servlet by name!
                servlet_holder=(ServletHolder)_servletNameMap.get(target);
                if (servlet_holder!=null && _filterMappings!=null && _filterMappings.length>0)
                {
                    base_request.setServletName(servlet_holder.getName());
                    chain=getFilterChain(type, null,servlet_holder);
                }
            }

            if (Log.isDebugEnabled())
            {
                Log.debug("chain="+chain);
                Log.debug("servlet holder="+servlet_holder);
            }

            // Handle context listeners
            request_listeners = base_request.takeRequestListeners();
            if (request_listeners!=null)
            {
                request_event = new ServletRequestEvent(getServletContext(),request);
                final int s=LazyList.size(request_listeners);
                for(int i=0;i<s;i++)
                {
                    final ServletRequestListener listener = (ServletRequestListener)LazyList.get(request_listeners,i);
                    listener.requestInitialized(request_event);
                }
            }
           
            // Do the filter/handling thang
            if (servlet_holder!=null)
            {
                base_request.setHandled(true);
                if (chain!=null)
                    chain.doFilter(request, response);
                else
                    servlet_holder.handle(request,response);
            }
            else
                notFound(request, response);
View Full Code Here


        }
       
        if (filters==null)
            return null;
       
        FilterChain chain = null;
        if (_filterChainsCached)
        {
            if (LazyList.size(filters) > 0)
                chain= new CachedChain(filters, servletHolder);
            synchronized(this)
View Full Code Here

            LIST.remove(filter);
      }
    }

    public void doFilter(ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException {
        new FilterChain() {
            private int position=0;
            // capture the array for thread-safety
            private final Filter[] filters = LIST.toArray(new Filter[LIST.size()]);

            public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
View Full Code Here

        serviceProperties.setAuthenticateAllArtifacts(true);
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setParameter("ticket", "ST-1-123");
        request.setRequestURI("/authenticate");
        MockHttpServletResponse response = new MockHttpServletResponse();
        FilterChain chain = mock(FilterChain.class);

        CasAuthenticationFilter filter = new CasAuthenticationFilter();
        filter.setServiceProperties(serviceProperties);
        filter.setAuthenticationSuccessHandler(successHandler);
        filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
View Full Code Here

    @Test
    public void testChainNotInvokedForProxyReceptor() throws Exception {
        CasAuthenticationFilter filter = new CasAuthenticationFilter();
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        FilterChain chain = mock(FilterChain.class);

        request.setRequestURI("/pgtCallback");
        filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
        filter.setProxyReceptorUrl(request.getRequestURI());
View Full Code Here

    /**
     * Allows the {@code EvaluationContext} to be customized for variable lookup etc.
     */
    protected EvaluationContext createExpressionEvaluationContext(SecurityExpressionHandler<FilterInvocation> handler) {
        FilterInvocation f = new FilterInvocation(getRequest(), getResponse(), new FilterChain() {
            public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
                throw new UnsupportedOperationException();
            }
        });

View Full Code Here

                assertEquals("http://localhost:8080/", realm);
                return REDIRECT_URL;
            }
        });

        FilterChain fc = mock(FilterChain.class);
        filter.doFilter(req, response, fc);
        assertEquals(REDIRECT_URL, response.getRedirectedUrl());
        // Filter chain shouldn't proceed
        verify(fc, never()).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

    public void afterInvocationIsNotInvokedIfExceptionThrown() throws Exception {
        Authentication token = new TestingAuthenticationToken("Test", "Password", "NOT_USED");
        SecurityContextHolder.getContext().setAuthentication(token);

        FilterInvocation fi = createinvocation();
        FilterChain chain = fi.getChain();

        doThrow(new RuntimeException()).when(chain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));
        when(ods.getAttributes(fi)).thenReturn(SecurityConfig.createList("MOCK_OK"));

        AfterInvocationManager aim = mock(AfterInvocationManager.class);
View Full Code Here

    private void doNormalOperation(FilterChainProxy filterChainProxy) throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setServletPath("/foo/secure/super/somefile.html");

        MockHttpServletResponse response = new MockHttpServletResponse();
        FilterChain chain = mock(FilterChain.class);

        filterChainProxy.doFilter(request, response, chain);
        verify(chain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));

        request.setServletPath("/a/path/which/doesnt/match/any/filter.html");
View Full Code Here

        request.setServerPort(80);
        request.setContextPath("/mycontext");
        request.setRequestURI("/mycontext/HelloWorld/some/more/segments.html");

        MockHttpServletResponse response = new MockHttpServletResponse();
        FilterChain chain = mock(FilterChain.class);
        FilterInvocation fi = new FilterInvocation(request, response, chain);
        assertEquals(request, fi.getRequest());
        assertEquals(request, fi.getHttpRequest());
        assertEquals(response, fi.getResponse());
        assertEquals(response, fi.getHttpResponse());
View Full Code Here

TOP

Related Classes of javax.servlet.FilterChain

Copyright © 2018 www.massapicom. 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.