org.eclipse.jetty.webapp.WebAppContext.getSessionHandler()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.getSessionHandler()方法的一些代码示例,展示了WebAppContext.getSessionHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.getSessionHandler()方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:getSessionHandler

WebAppContext.getSessionHandler介绍

暂无

代码示例

代码示例来源:origin: Dreampie/Resty

webAppContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
sessionManager.setSessionIdPathParameterName(null);

代码示例来源:origin: gocd/gocd

@Override
public void setSessionConfig() {
  SessionHandler sessionHandler = webAppContext.getSessionHandler();
  SessionCookieConfig sessionCookieConfig = sessionHandler.getSessionCookieConfig();
  sessionCookieConfig.setHttpOnly(true);
  sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
  sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
  sessionHandler.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldSetSessionMaxInactiveInterval() throws Exception {
  jetty9Server.configure();
  jetty9Server.setSessionConfig();
  jetty9Server.startHandlers();
  WebAppContext webAppContext = (WebAppContext) getLoadedHandlers().get(WebAppContext.class);
  assertThat(webAppContext.getSessionHandler().getMaxInactiveInterval(), is(1234));
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldSetSessionCookieConfig() throws Exception {
  when(systemEnvironment.isSessionCookieSecure()).thenReturn(true);
  jetty9Server.configure();
  jetty9Server.setSessionConfig();
  jetty9Server.startHandlers();
  WebAppContext webAppContext = (WebAppContext) getLoadedHandlers().get(WebAppContext.class);
  SessionCookieConfig sessionCookieConfig = webAppContext.getSessionHandler().getSessionCookieConfig();
  assertThat(sessionCookieConfig.isHttpOnly(), is(true));
  assertThat(sessionCookieConfig.isSecure(), is(true));
  assertThat(sessionCookieConfig.getMaxAge(), is(5678));
  when(systemEnvironment.isSessionCookieSecure()).thenReturn(false);
  jetty9Server.setSessionConfig();
  assertThat(sessionCookieConfig.isSecure(), is(false));
}

代码示例来源:origin: org.springframework.boot/spring-boot

private void configureSession(WebAppContext context) {
  SessionHandler handler = context.getSessionHandler();
  Duration sessionTimeout = getSession().getTimeout();
  handler.setMaxInactiveInterval(
      isNegative(sessionTimeout) ? -1 : (int) sessionTimeout.getSeconds());
  if (getSession().isPersistent()) {
    DefaultSessionCache cache = new DefaultSessionCache(handler);
    FileSessionDataStore store = new FileSessionDataStore();
    store.setStoreDir(getValidSessionStoreDir());
    cache.setSessionDataStore(store);
    handler.setSessionCache(cache);
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

if (context.getSessionHandler() == null)
  return; //no session handler, ignore session setup
  context.getSessionHandler().setMaxInactiveInterval(asDecimal.intValueExact() * 60);
        modes = new HashSet<SessionTrackingMode>();
      else
        modes = new HashSet<SessionTrackingMode>(context.getSessionHandler().getEffectiveSessionTrackingModes());
      context.getMetaData().setOrigin("session.tracking-mode", descriptor);
      break;
  context.getSessionHandler().setSessionTrackingModes(modes);   
        context.getSessionHandler().getSessionCookieConfig().setName(name);
        context.getMetaData().setOrigin("cookie-config.name", descriptor);
        break;
          context.getSessionHandler().getSessionCookieConfig().setName(name);
          context.getMetaData().setOrigin("cookie-config.name", descriptor);
        if (!context.getSessionHandler().getSessionCookieConfig().getName().equals(name))
          throw new IllegalStateException("Conflicting cookie-config name "+name+" in "+descriptor.getResource());
        break;
        context.getSessionHandler().getSessionCookieConfig().setDomain(domain);
        context.getMetaData().setOrigin("cookie-config.domain", descriptor);
        break;
          context.getSessionHandler().getSessionCookieConfig().setDomain(domain);

代码示例来源:origin: org.apache.hadoop/hadoop-common

SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
 AbstractSessionManager asm = (AbstractSessionManager)sm;

代码示例来源:origin: apache/cloudstack

private HandlerCollection createHandlers() {
  final WebAppContext webApp = new WebAppContext();
  webApp.setContextPath(contextPath);
  webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
  webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60);
  // GZIP handler
  final GzipHandler gzipHandler = new GzipHandler();
  gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
  gzipHandler.setIncludedMethods("GET", "POST");
  gzipHandler.setCompressionLevel(9);
  gzipHandler.setHandler(webApp);
  if (Strings.isNullOrEmpty(webAppLocation)) {
    webApp.setWar(getShadedWarUrl());
  } else {
    webApp.setWar(webAppLocation);
  }
  // Request log handler
  final RequestLogHandler log = new RequestLogHandler();
  log.setRequestLog(createRequestLog());
  // Redirect root context handler
  MovedContextHandler rootRedirect = new MovedContextHandler();
  rootRedirect.setContextPath("/");
  rootRedirect.setNewContextURL(contextPath);
  rootRedirect.setPermanent(true);
  // Put rootRedirect at the end!
  return new HandlerCollection(log, gzipHandler, rootRedirect);
}

代码示例来源:origin: com.carecon.fabric3/fabric3-container-web-jetty

public void contextDestroyed(ServletContextEvent sce) {
    context.getSessionHandler().clearEventListeners();
  }
});

代码示例来源:origin: org.fabric3/fabric3-container-web-jetty

public void contextDestroyed(ServletContextEvent sce) {
    context.getSessionHandler().clearEventListeners();
  }
});

代码示例来源:origin: org.avaje.glue/jetty-runner

/**
 * Set the secure cookies setting on the jetty session manager.
 */
void setSecureCookies() {
 webapp.getSessionHandler().setHttpOnly(true);
 webapp.getSessionHandler().getSessionCookieConfig().setSecure(true);
}

代码示例来源:origin: com.carecon.fabric3/fabric3-container-web-jetty

public void contextInitialized(ServletContextEvent sce) {
  // Setup the session listener to inject reference proxies in newly created sessions
  // Note the listener must be added after the context is started as Jetty web xml configurer clears event listeners
  List<Injector<HttpSession>> sessionInjectors = List.class.cast(injectors.get(SESSION_CONTEXT_SITE));
  InjectingSessionListener listener = new InjectingSessionListener(sessionInjectors);
  context.getSessionHandler().addEventListener(listener);
  ServletContext servletContext = context.getServletContext();
  try {
    injectServletContext(servletContext, injectors);
  } catch (Fabric3Exception e) {
    monitor.error("Error initializing web component: " + uri, e);
  }
}

代码示例来源:origin: org.fabric3/fabric3-container-web-jetty

public void contextInitialized(ServletContextEvent sce) {
  // Setup the session listener to inject reference proxies in newly created sessions
  // Note the listener must be added after the context is started as Jetty web xml configurer clears event listeners
  List<Injector<HttpSession>> sessionInjectors = List.class.cast(injectors.get(SESSION_CONTEXT_SITE));
  InjectingSessionListener listener = new InjectingSessionListener(sessionInjectors);
  context.getSessionHandler().addEventListener(listener);
  ServletContext servletContext = context.getServletContext();
  try {
    injectServletContext(servletContext, injectors);
  } catch (Fabric3Exception e) {
    monitor.error("Error initializing web component: " + uri, e);
  }
}

代码示例来源:origin: cd.connect.common/connect-runnable-war

SessionHandler sessionHandler = context.getSessionHandler();
sessionHandler.setSecureRequestOnly(allowCookiesToOnlyBePassedSecurely);
sessionHandler.setHttpOnly(true);

代码示例来源:origin: zenvisage/zenvisage

public void start() throws Exception {	
    server = new Server(port);	
    
    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/");
    webAppContext.setWar("zenvisage.war");
    webAppContext.setParentLoaderPriority(true);
    webAppContext.setServer(server);
    webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
    webAppContext.getSessionHandler().getSessionManager()
        .setMaxInactiveInterval(10);
    server.setHandler(webAppContext);    
    server.start();
//        ZvMain zvMain = (ZvMain) SpringApplicationContext.getBean("zvMain");
//        zvMain.loadData();
    
    DatabaseAutoLoader databaseAutoLoader = new DatabaseAutoLoader(this);
    databaseAutoLoader.run();
  
  }

代码示例来源:origin: jenkinsci/winstone

wac.setThrowUnavailableOnStartupException(true);    // if boot fails, abort the process instead of letting empty Jetty run
wac.setMimeTypes(mimeTypes);
wac.getSessionHandler().setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
wac.getSessionHandler().setSessionCookie(WinstoneSession.SESSION_COOKIE_NAME);
this.webapps.put(wac.getContextPath(),wac);
return wac;

代码示例来源:origin: com.github.sogyf/goja-jfinal

private void persistSession(WebAppContext webApp) {
  String storeDir = getStoreDir();
  
  SessionManager sm = webApp.getSessionHandler().getSessionManager();
  if (sm instanceof HashSessionManager) {
    ((HashSessionManager)sm).setStoreDirectory(new File(storeDir));
    return ;
  }
  
  HashSessionManager hsm = new HashSessionManager();
  hsm.setStoreDirectory(new File(storeDir));
  SessionHandler sh = new SessionHandler();
  sh.setSessionManager(hsm);
  webApp.setSessionHandler(sh);
}

代码示例来源:origin: works.lmz.common/common-runnable-war

context.setSecurityHandler(new RemoteUserSecurityHandler());
SessionManager sessionManager = context.getSessionHandler().getSessionManager();

代码示例来源:origin: stackoverflow.com

// To be passed to all scanned webapps. Ensures SSO between contexts
SessionManager sessManager = new HashSessionManager();
SessionCookieConfig config = sessManager.getSessionCookieConfig();
config.setPath("/webapps/"); // Ensures all webapps share the same cookie

// Create the Handler (a.k.a the WebAppContext).
App app = new App(deployer, provider, module.getFile().getAbsolutePath());
WebAppContext handler = (WebAppContext)app.getContextHandler(); // getContextHandler does the extraction
// Consolidating all scanned webapps under a single context path allows SSO
handler.setContextPath("/webapps" + handler.getContextPath());
// Cookies need to be shared between webapps for SSO
SessionHandler sessHandler = handler.getSessionHandler();
sessHandler.setSessionManager(sessManager);

代码示例来源:origin: apache/maven-wagon

webappContext.setHandler( securityHandler );
SessionHandler sessionHandler = webappContext.getSessionHandler();
( (AbstractSessionManager) sessionHandler.getSessionManager() ).setUsingCookies( false );

相关文章

微信公众号

最新文章

更多

WebAppContext类方法