Search in sources :

Example 6 with HashSessionManager

use of org.eclipse.jetty.server.session.HashSessionManager in project Activiti by Activiti.

the class BaseJPARestTestCase method getServletContextHandler.

private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
    ServletContextHandler contextHandler = new ServletContextHandler();
    JPAWebConfigurer configurer = new JPAWebConfigurer();
    configurer.setContext(context);
    contextHandler.addEventListener(configurer);
    // Create the SessionHandler (wrapper) to handle the sessions
    HashSessionManager manager = new HashSessionManager();
    SessionHandler sessions = new SessionHandler(manager);
    contextHandler.setHandler(sessions);
    return contextHandler;
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) JPAWebConfigurer(org.activiti.rest.JPAWebConfigurer) HashSessionManager(org.eclipse.jetty.server.session.HashSessionManager) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 7 with HashSessionManager

use of org.eclipse.jetty.server.session.HashSessionManager in project drill by apache.

the class WebServer method createSessionHandler.

/**
   * @return A {@link SessionHandler} which contains a {@link HashSessionManager}
   */
private SessionHandler createSessionHandler(final SecurityHandler securityHandler) {
    SessionManager sessionManager = new HashSessionManager();
    sessionManager.setMaxInactiveInterval(config.getInt(ExecConstants.HTTP_SESSION_MAX_IDLE_SECS));
    sessionManager.addEventListener(new HttpSessionListener() {

        @Override
        public void sessionCreated(HttpSessionEvent se) {
        }

        @Override
        public void sessionDestroyed(HttpSessionEvent se) {
            final HttpSession session = se.getSession();
            if (session == null) {
                return;
            }
            final Object authCreds = session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
            if (authCreds != null) {
                final SessionAuthentication sessionAuth = (SessionAuthentication) authCreds;
                securityHandler.logout(sessionAuth);
                session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
            }
            // Clear all the resources allocated for this session
            final WebSessionResources webSessionResources = (WebSessionResources) session.getAttribute(WebSessionResources.class.getSimpleName());
            if (webSessionResources != null) {
                webSessionResources.close();
                session.removeAttribute(WebSessionResources.class.getSimpleName());
            }
        }
    });
    return new SessionHandler(sessionManager);
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) HttpSessionListener(javax.servlet.http.HttpSessionListener) HashSessionManager(org.eclipse.jetty.server.session.HashSessionManager) HashSessionManager(org.eclipse.jetty.server.session.HashSessionManager) SessionManager(org.eclipse.jetty.server.SessionManager) HttpSession(javax.servlet.http.HttpSession) HttpSessionEvent(javax.servlet.http.HttpSessionEvent) SessionAuthentication(org.eclipse.jetty.security.authentication.SessionAuthentication)

Aggregations

HashSessionManager (org.eclipse.jetty.server.session.HashSessionManager)7 SessionHandler (org.eclipse.jetty.server.session.SessionHandler)6 SessionManager (org.eclipse.jetty.server.SessionManager)4 File (java.io.File)3 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URL (java.net.URL)2 Server (org.eclipse.jetty.server.Server)2 GitblitAuthority (com.gitblit.authority.GitblitAuthority)1 NewCertificateConfig (com.gitblit.authority.NewCertificateConfig)1 GitblitContext (com.gitblit.servlet.GitblitContext)1 X509Log (com.gitblit.utils.X509Utils.X509Log)1 X509Metadata (com.gitblit.utils.X509Utils.X509Metadata)1 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)1 InMemoryDirectoryServerConfig (com.unboundid.ldap.listener.InMemoryDirectoryServerConfig)1 LDIFReader (com.unboundid.ldif.LDIFReader)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1