@Override protected Pipeline getPipeline() { return getTheContext().getPipeline(); }
@Override protected Pipeline getPipeline() { return getTheContext().getPipeline(); }
authenticator.setNonceValidity(10 * 1000L); // Shorten from 5 minutes to 10 seconds authenticator.setNonceCacheSize(20000); // Increase from 1000 to 20000 context.getPipeline().addValve(authenticator);
context.getPipeline().addValve(valve);
context.getParent().getPipeline().addValve(_trackingHostValve); _trackingContextValve = createRequestTrackingContextValve(sessionCookieName); context.getPipeline().addValve( _trackingContextValve );
public void shutdown() { _log.info( "Stopping services." ); _manager.getContext().getParent().getPipeline().removeValve(_trackingHostValve); _manager.getContext().getPipeline().removeValve(_trackingContextValve); _backupSessionService.shutdown(); if ( _lockingStrategy != null ) { _lockingStrategy.shutdown(); } if ( _storage != null ) { _storage.shutdown(); _storage = null; } _transcoderFactory = null; _invalidSessionsCache.clear(); }
@Override public void addRequestListener(final ServletRequestListener listener) { // Add a valve rather than using Context.setApplicationEventListeners(...), since these will be overwritten at the end of Context.start() if (this.valveFactory != null) { this.context.getPipeline().addValve(this.valveFactory.createValve(listener)); } }
/** * {@inheritDoc} * @see org.jboss.modcluster.Context#addRequestListener(javax.servlet.ServletRequestListener) */ public void addRequestListener(final ServletRequestListener listener) { // Add a valve rather than using Context.setApplicationEventListeners(...), since these will be overwritten at the end of Context.start() this.context.getPipeline().addValve(new RequestListenerValve(listener)); }
@Override public void removeRequestListener(ServletRequestListener listener) { if (this.valveFactory != null) { Valve listenerValve = this.valveFactory.createValve(listener); Pipeline pipeline = this.context.getPipeline(); for (Valve valve : pipeline.getValves()) { if (listenerValve.equals(valve)) { pipeline.removeValve(valve); break; } } } }
/** * {@inheritDoc} * @see org.jboss.modcluster.Context#removeRequestListener(javax.servlet.ServletRequestListener) */ public void removeRequestListener(ServletRequestListener listener) { Valve listenerValve = new RequestListenerValve(listener); Pipeline pipeline = this.context.getPipeline(); for (Valve valve: pipeline.getValves()) { if (listenerValve.equals(valve)) { pipeline.removeValve(valve); return; } } }
/** {@inheritDoc} */ @Override public void customize(Context context) { LogbackAccessValve valve = new LogbackAccessValve(); valve.setProperties(properties); valve.setConfigurator(configurator); context.getPipeline().addValve(valve); log.debug("Added the Tomcat valve: valve=[{}] to context=[{}]", valve, context); }
/** * Tomcat style invocation. */ @Override public void invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response) throws IOException, ServletException { Context context = preInvoke(request, response); if (context == null) { return; } // Ask this Context to process this request if (context.getPipeline().hasNonBasicValves() || context.hasCustomPipeline()) { context.getPipeline().invoke(request, response); } else { context.getPipeline().getBasic().invoke(request, response); } postInvoke(request, response); }
@Test public void requestListener() throws IOException, ServletException { // Test addRequestListener() ServletRequestListener listener = mock(ServletRequestListener.class); Pipeline pipeline = mock(Pipeline.class); Valve valve = mock(Valve.class); when(this.context.getPipeline()).thenReturn(pipeline); when(this.valveFactory.createValve(same(listener))).thenReturn(valve); this.catalinaContext.addRequestListener(listener); verify(pipeline).addValve(same(valve)); // Test removeRequestListener() when(this.context.getPipeline()).thenReturn(pipeline); when(pipeline.getValves()).thenReturn(new Valve[] { valve }); when(this.valveFactory.createValve(same(listener))).thenReturn(valve); this.catalinaContext.removeRequestListener(listener); verify(pipeline).removeValve(same(valve)); }
@Override public void lifecycleEvent(LifecycleEvent event) { try { Context context = (Context) event.getLifecycle(); if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { context.setConfigured(true); } // LoginConfig is required to process @ServletSecurity // annotations if (context.getLoginConfig() == null) { context.setLoginConfig( new LoginConfig("NONE", null, null, null)); context.getPipeline().addValve(new NonLoginAuthenticator()); } } catch (ClassCastException e) { return; } }
@Override public void lifecycleEvent(LifecycleEvent event) { try { Context context = (Context) event.getLifecycle(); if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { context.setConfigured(true); } // LoginConfig is required to process @ServletSecurity // annotations if (context.getLoginConfig() == null) { context.setLoginConfig( new LoginConfig("NONE", null, null, null)); context.getPipeline().addValve(new NonLoginAuthenticator()); } } catch (ClassCastException e) { return; } }
@Override public void lifecycleEvent(LifecycleEvent event) { try { Context context = (Context) event.getLifecycle(); if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { context.setConfigured(true); } // LoginConfig is required to process @ServletSecurity // annotations if (context.getLoginConfig() == null) { context.setLoginConfig( new LoginConfig("NONE", null, null, null)); context.getPipeline().addValve(new NonLoginAuthenticator()); } } catch (ClassCastException e) { return; } }
@Override public void lifecycleEvent(LifecycleEvent event) { try { Context context = (Context) event.getLifecycle(); if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { context.setConfigured(true); // Process annotations WebAnnotationSet.loadApplicationAnnotations(context); // LoginConfig is required to process @ServletSecurity // annotations if (context.getLoginConfig() == null) { context.setLoginConfig(new LoginConfig("NONE", null, null, null)); context.getPipeline().addValve(new NonLoginAuthenticator()); } } } catch (ClassCastException e) { } } }
@Deprecated private static WebConstraint findLegacyConstraints(final Context context, final String[] roles, final String transportGuarantee) { final LoginConfig loginConfig = context.getLoginConfig(); if (loginConfig != null || roles != null || transportGuarantee != null) { final WebConstraint constraint = new WebConstraint() .withAuthMethod(loginConfig != null && !"NONE".equalsIgnoreCase(loginConfig.getAuthMethod()) ? loginConfig.getAuthMethod() : null) .withTransportGuarantee(transportGuarantee) .withRealm(loginConfig != null ? loginConfig.getRealmName() : null) .withRole(roles); for (final Valve valve : context.getPipeline().getValves()) { if (SignatureAuthenticator.class.isInstance(valve) && "SIGNATURE".equals(constraint.getAuthMethod())) { constraint.withMandatoryHeader(SignatureAuthenticator.class.cast(valve).getHeaders().split(" ")); } else if (info(valve).startsWith("com.tomitribe.tribestream.proxy.auth.TokenValve/")) { constraint.withMandatoryHeader(SystemInstance.get().getProperty("tribe.oauth2.auth.header", "Authorization")); if (constraint.getAuthMethod() == null) { constraint.withAuthMethod("JWT"); // virtual auth method but useful information } else { constraint.withAuthMethod(constraint.getAuthMethod() + "+JWT"); } } } return constraint; } return null; }
@Override public void lifecycleEvent(LifecycleEvent event) { try { Context context = (Context) event.getLifecycle(); if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { context.setConfigured(true); // Process annotations WebAnnotationSet.loadApplicationAnnotations(context); // LoginConfig is required to process @ServletSecurity // annotations if (context.getLoginConfig() == null) { context.setLoginConfig(new LoginConfig("NONE", null, null, null)); context.getPipeline().addValve(new NonLoginAuthenticator()); } } } catch (ClassCastException e) { } } }
public void shutdown() { _log.info( "Stopping services." ); _manager.getContext().getParent().getPipeline().removeValve(_trackingHostValve); _manager.getContext().getPipeline().removeValve(_trackingContextValve); _backupSessionService.shutdown(); if ( _lockingStrategy != null ) { _lockingStrategy.shutdown(); } if ( _storage != null ) { _storage.shutdown(); _storage = null; } _transcoderFactory = null; _invalidSessionsCache.clear(); }