Package javax.servlet

Examples of javax.servlet.Filter.doFilter()


        CurrentUser.authenticate("nouser");
        Assert.assertEquals(CurrentUser.getUser(), "nouser");

        CurrentUser.authenticate("testuser");
        Mockito.when(mockRequest.getRemoteUser()).thenReturn("testuser");
        filter.doFilter(mockRequest, mockResponse, mockChain);
        Assert.assertEquals(CurrentUser.getUser(), "testuser");
    }

    @Test
    public void testEmptyUser() throws Exception {
View Full Code Here


            Mockito.when(mockRequest.getMethod()).thenReturn("POST");
            Mockito.when(mockRequest.getQueryString()).thenReturn("");
            Mockito.when(mockRequest.getRemoteUser()).thenReturn(null);

            HttpServletResponse errorResponse = Mockito.mock(HttpServletResponse.class);
            filter.doFilter(mockRequest, errorResponse, mockChain);
        } finally {
            System.setProperty("user.name", userName);
        }
    }
View Full Code Here

            Mockito.when(mockRequest.getMethod()).thenReturn("POST");
            Mockito.when(mockRequest.getQueryString()).thenReturn("");
            Mockito.when(mockRequest.getRemoteUser()).thenReturn(null);
            Mockito.when(mockRequest.getHeader("Remote-User")).thenReturn("remote-user");

            filter.doFilter(mockRequest, mockResponse, mockChain);

            Assert.assertEquals(CurrentUser.getUser(), "remote-user");

        } finally {
            System.setProperty("user.name", userName);
View Full Code Here

                    SecurityUtil.doAsPrivilege
                        ("doFilter", filter, classType, args, principal);
                   
                    args = null;
                } else
                    filter.doFilter(request, response, this);
                }

                support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                                          filter, request, response);
            } catch (IOException e) {
View Full Code Here

  public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
    if (current < filters.length && !response.isCommitted()) {
      Filter filter = filters[current++];
      LOG.info("doFilter() on " + filter);
      filter.doFilter(request, response, this);
    }
  }
}
View Full Code Here

        Filter filter2b = ctrl.createMock(Filter.class);

        expect((Filter)injector.getInstance(key2a)).andReturn(filter2a);
        filter2a.doFilter(same(request), same(response), anyObject(FilterChain.class));
        expect((Filter)injector.getInstance(key2b)).andReturn(filter2b);
        filter2b.doFilter(same(request), same(response), anyObject(FilterChain.class));
        originalChain.doFilter(request, response);

        ctrl.replay();

        SimpleFilterChainResolver underTest = new SimpleFilterChainResolver(chainMap, injector, patternMatcher);
View Full Code Here

        if (!_filters.isEmpty()) {
            // remove the first element from the chain and pass itself to the filter.
            Filter filter = _filters.pop();
            FilterChain chain = this;
            //when reaching the last filter, pass the original chain.
            filter.doFilter(request, response, chain);
        }
    }

}
View Full Code Here

                    SecurityUtil.doAsPrivilege
                        ("doFilter", filter, classType, args, principal);
                   
                    args = null;
                } else
                    filter.doFilter(request, response, this);
                }

                support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
                                          filter, request, response);
            } catch (IOException e) {
View Full Code Here

            if (_filterHolder!=null)
            {
                if (Log.isDebugEnabled())
                    Log.debug("call filter " + _filterHolder);
                Filter filter= _filterHolder.getFilter();
                filter.doFilter(request, response, _next);
                return;
            }

            // Call servlet
            if (_servletHolder != null)
View Full Code Here

            if (_filter < LazyList.size(_chain))
            {
                FilterHolder holder= (FilterHolder)LazyList.get(_chain, _filter++);
                if (Log.isDebugEnabled()) Log.debug("call filter " + holder);
                Filter filter= holder.getFilter();
                filter.doFilter(request, response, this);
                return;
            }

            // Call servlet
            if (_servletHolder != null)
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.