@Test public void testNullSecurityToken() throws Exception { filter.setAuthenticationHandlers(ImmutableList.<AuthenticationHandler>of(nullStHandler)); filter.doFilter(request, recorder, chain); assertEquals( TEST_AUTH_HEADER, recorder.getHeader(AuthenticationServletFilter.WWW_AUTHENTICATE_HEADER)); }
/* * In normal operation, this is just a pass through to the wrapped and * "true" AuthenticationFilter. * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, * javax.servlet.ServletResponse, javax.servlet.FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (ready) { delayed.doFilter(request, response, chain); } else { log.warn("received web request prior to framework being " + "fully initialized!"); chain.doFilter(request, response); } }
/* * The wrapped object expects to get this message now, but we delay it until * we receive the right FrameworkEvent. * * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ public void init(FilterConfig filterConfig) throws ServletException { delayedConfig = filterConfig; if (hasBeenActivated) { // no point in delaying, everybody is already ready delayed.init(filterConfig); // we are also now in the ready state because no sense in waiting ready = true; } }
/* * Do the work that should have happened init time. This also "turns on" the * filter so future calls pass directly through this class to the wrapped * filter. */ public void frameworkEvent(FrameworkEvent event) { if (event.getType() != FrameworkEvent.STARTED) { return; } try { delayed.init(delayedConfig); ready = true; } catch (ServletException e) { log.error(e); } }
public void destroy() { delayed.destroy(); }
@Test(expected = ServletException.class) public void testDoFilter_BadArgs() throws Exception { filter.doFilter(null, null, null); }