コード例 #1
0
 @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));
 }
コード例 #2
0
 /*
  * 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);
   }
 }
コード例 #3
0
 /*
  * 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;
   }
 }
コード例 #4
0
 /*
  * 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);
   }
 }
コード例 #5
0
 public void destroy() {
   delayed.destroy();
 }
コード例 #6
0
 @Test(expected = ServletException.class)
 public void testDoFilter_BadArgs() throws Exception {
   filter.doFilter(null, null, null);
 }