当前位置: 首页>>代码示例>>Java>>正文


Java SessionTrackingMode类代码示例

本文整理汇总了Java中javax.servlet.SessionTrackingMode的典型用法代码示例。如果您正苦于以下问题:Java SessionTrackingMode类的具体用法?Java SessionTrackingMode怎么用?Java SessionTrackingMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SessionTrackingMode类属于javax.servlet包,在下文中一共展示了SessionTrackingMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeSessionId

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
/**
 * Change the ID of the session that this request is associated with. There
 * are several things that may trigger an ID change. These include moving
 * between nodes in a cluster and session fixation prevention during the
 * authentication process.
 *
 * @param newSessionId   The session to change the session ID for
 */
public void changeSessionId(String newSessionId) {
    // This should only ever be called if there was an old session ID but
    // double check to be sure
    if (requestedSessionId != null && requestedSessionId.length() > 0) {
        requestedSessionId = newSessionId;
    }

    if (context != null && !context.getServletContext()
            .getEffectiveSessionTrackingModes().contains(
                    SessionTrackingMode.COOKIE)) {
        return;
    }

    if (response != null) {
        Cookie newCookie =
            ApplicationSessionCookieConfig.createSessionCookie(context,
                    newSessionId, secure);
        response.addSessionCookieInternal(newCookie);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:Request.java

示例2: populateSessionTrackingModes

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
private void populateSessionTrackingModes() {
    // URL re-writing is always enabled by default
    defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);

    if (context.getCookies()) {
        defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
        supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
    }

    // SSL not enabled by default as it can only used on its own
    // Context > Host > Engine > Service
    Service s = ((Engine) context.getParent().getParent()).getService();
    Connector[] connectors = s.findConnectors();
    // Need at least one SSL enabled connector to use the SSL session ID.
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
            supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
            break;
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:ApplicationContext.java

示例3: initDone

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
public void initDone() {
    initialized = true;
    Set<SessionTrackingMode> trackingMethods = sessionTrackingModes;
    SessionConfig sessionConfig = sessionCookieConfig;
    if (trackingMethods != null && !trackingMethods.isEmpty()) {
        if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
            sessionConfig = new SslSessionConfig(deployment.getSessionManager());
        } else {
            if (sessionTrackingModes.contains(SessionTrackingMode.COOKIE) && sessionTrackingModes.contains(SessionTrackingMode.URL)) {
                sessionCookieConfig.setFallback(new PathParameterSessionConfig(sessionCookieConfig.getName().toLowerCase(Locale.ENGLISH)));
            } else if (sessionTrackingModes.contains(SessionTrackingMode.URL)) {
                sessionConfig = new PathParameterSessionConfig(sessionCookieConfig.getName().toLowerCase(Locale.ENGLISH));
            }
        }
    }
    SessionConfigWrapper wrapper = deploymentInfo.getSessionConfigWrapper();
    if (wrapper != null) {
        sessionConfig = wrapper.wrap(sessionConfig, deployment);
    }
    this.sessionConfig = sessionConfig;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:ServletContextImpl.java

示例4: changeSessionId

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
/**
 * Change the ID of the session that this request is associated with. There
 * are several things that may trigger an ID change. These include moving
 * between nodes in a cluster and session fixation prevention during the
 * authentication process.
 *
 * @param newSessionId
 *            The session to change the session ID for
 */
public void changeSessionId(String newSessionId) {
	// This should only ever be called if there was an old session ID but
	// double check to be sure
	if (requestedSessionId != null && requestedSessionId.length() > 0) {
		requestedSessionId = newSessionId;
	}

	if (context != null && !context.getServletContext().getEffectiveSessionTrackingModes()
			.contains(SessionTrackingMode.COOKIE)) {
		return;
	}

	if (response != null) {
		Cookie newCookie = ApplicationSessionCookieConfig.createSessionCookie(context, newSessionId, secure);
		response.addSessionCookieInternal(newCookie);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:Request.java

示例5: populateSessionTrackingModes

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
private void populateSessionTrackingModes() {
	// URL re-writing is always enabled by default
	defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
	supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);

	if (context.getCookies()) {
		defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
		supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
	}

	// SSL not enabled by default as it can only used on its own
	// Context > Host > Engine > Service
	Service s = ((Engine) context.getParent().getParent()).getService();
	Connector[] connectors = s.findConnectors();
	// Need at least one SSL enabled connector to use the SSL session ID.
	for (Connector connector : connectors) {
		if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
			supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
			break;
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:ApplicationContext.java

示例6: onStartup

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
  this.servletContext = servletContext;
  servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
  servletContext.addListener(new WelcomeContainerBootstrap());
  servletContext.addListener(new CockpitContainerBootstrap());
  servletContext.addListener(new AdminContainerBootstrap());
  servletContext.addListener(new TasklistContainerBootstrap());

  registerFilter("Authentication Filter", AuthenticationFilter.class, "/*");

  registerFilter("Security Filter", LazySecurityFilter.class, singletonMap("configFile", properties.getWebapp().getSecurityConfigFile()), "/*");

  registerFilter("Engines Filter", LazyProcessEnginesFilter.class, "/app/*");
  registerFilter("CacheControlFilter", CacheControlFilter.class, "/api/*");

  registerServlet("Cockpit Api", CockpitApplication.class, "/api/cockpit/*");
  registerServlet("Admin Api", AdminApplication.class, "/api/admin/*");
  registerServlet("Tasklist Api", TasklistApplication.class, "/api/tasklist/*");
  registerServlet("Engine Api", EngineRestApplication.class, "/api/engine/*");
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:22,代码来源:CamundaBpmWebappInitializer.java

示例7: initialize

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
public static void initialize(ServletContext servletContext, boolean dev) throws ServletException {
	FacesInitializer facesInitializer = new FacesInitializer();

	servletContext.setInitParameter("primefaces.FONT_AWESOME", "true");
	servletContext.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
	if (dev) {
		servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "0");
		servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
	} else {
		servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "-1");
		servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Production");
	}
	servletContext.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));

	Set<Class<?>> clazz = new HashSet<Class<?>>();
	clazz.add(WebXmlSpringBoot.class);
	facesInitializer.onStartup(clazz, servletContext);

	Dynamic startBrowserServlet = servletContext.addServlet("StartBrowserServlet", StartBrowserServlet.class);
	startBrowserServlet.setLoadOnStartup(2);
}
 
开发者ID:jirkapinkas,项目名称:sitemonitoring-production,代码行数:22,代码来源:WebXmlCommon.java

示例8: shouldSetSessionTrackingModeToCookieOnly

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
@Test
public void shouldSetSessionTrackingModeToCookieOnly() throws Exception {
    Server server = new Server(1234);
    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setWar(webapp.getAbsolutePath());
    webAppContext.setContextPath("/");
    server.setHandler(webAppContext);
    try {
        server.start();
        Set<SessionTrackingMode> effectiveSessionTrackingModes = ((WebAppContext) server.getHandlers()[0]).getServletContext().getEffectiveSessionTrackingModes();
        assertThat(effectiveSessionTrackingModes.size(), is(1));
        assertThat(effectiveSessionTrackingModes.contains(SessionTrackingMode.COOKIE), is(true));
    } finally {
        server.stop();
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:WebappSessionConfigIntegrationTest.java

示例9: changeSessionId

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
/**
 * Change the ID of the session that this request is associated with. There
 * are several things that may trigger an ID change. These include moving
 * between nodes in a cluster and session fixation prevention during the
 * authentication process.
 * 
 * @param newSessionId   The session to change the session ID for
 */
public void changeSessionId(String newSessionId) {
    // This should only ever be called if there was an old session ID but
    // double check to be sure
    if (requestedSessionId != null && requestedSessionId.length() > 0) {
        requestedSessionId = newSessionId;
    }
    
    if (context != null && !context.getServletContext()
            .getEffectiveSessionTrackingModes().contains(
                    SessionTrackingMode.COOKIE))
        return;
    
    if (response != null) {
        Cookie newCookie =
            ApplicationSessionCookieConfig.createSessionCookie(context,
                    newSessionId, secure);
        response.addSessionCookieInternal(newCookie);
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:28,代码来源:Request.java

示例10: populateSessionTrackingModes

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
private void populateSessionTrackingModes() {
    // URL re-writing is always enabled by default
    defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL); 
    supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    
    if (context.getCookies()) {
        defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
        supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
    }

    // SSL not enabled by default as it can only used on its own 
    // Context > Host > Engine > Service
    Service s = ((Engine) context.getParent().getParent()).getService();
    Connector[] connectors = s.findConnectors();
    // Need at least one SSL enabled connector to use the SSL session ID.
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
            supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
            break;
        }
    } 
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:23,代码来源:ApplicationContext.java

示例11: build

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
public SessionManager build() throws IOException {
	HashSessionManager manager = new HashSessionManager();
	manager.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));
	manager.setHttpOnly(true);
	manager.getSessionCookieConfig().setHttpOnly(true);
	manager.setDeleteUnrestorableSessions(true);

	manager.setStoreDirectory(new File(getPath()));
	manager.getSessionCookieConfig().setMaxAge((int) cookieMaxAge.toSeconds());
	manager.setRefreshCookieAge((int) cookieRefreshAge.toSeconds());
	manager.setMaxInactiveInterval((int) maxInactiveInterval.toSeconds());
	manager.setIdleSavePeriod((int) idleSavePeriod.toSeconds());
	manager.setSavePeriod((int) savePeriod.toSeconds());
	manager.setScavengePeriod((int) scavengePeriod.toSeconds());
	return manager;
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:17,代码来源:SessionManagerFactory.java

示例12: addRootContext

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
private void addRootContext(ServletContext container) {
  // Create the application context
  AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
  rootContext.register(SpringContextConfig.class); 
	 
  // Register application context with ContextLoaderListener
  container.addListener(new ContextLoaderListener(rootContext));
  container.addListener(new AppSessionListener());
  container.setInitParameter("contextConfigLocation", "org.packt.secured.mvc.core");
  container.setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE)); // if URL, enable sessionManagement URL rewriting   
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:12,代码来源:SpringWebInitializer.java

示例13: addRootContext

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
private void addRootContext(ServletContext container) {
  // Create the application context
  AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
  rootContext.register(SpringContextConfig.class); 
	 
  // Register application context with ContextLoaderListener
  container.addListener(new ContextLoaderListener(rootContext));
 container.setInitParameter("contextConfigLocation", "org.packt.web.reactor.security.config");
 container.setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE)); // if URL, enable sessionManagement URL rewriting   
	 
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:12,代码来源:SpringWebinitializer.java

示例14: doPrivileged

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") // doPrivileged() returns the correct type
public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (Set<SessionTrackingMode>)
            doPrivileged("getDefaultSessionTrackingModes", null);
    } else {
        return context.getDefaultSessionTrackingModes();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:11,代码来源:ApplicationContextFacade.java

示例15: setSessionTrackingModes

import javax.servlet.SessionTrackingMode; //导入依赖的package包/类
@Override
public void setSessionTrackingModes(
        Set<SessionTrackingMode> sessionTrackingModes) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        doPrivileged("setSessionTrackingModes",
                new Object[]{sessionTrackingModes});
    } else {
        context.setSessionTrackingModes(sessionTrackingModes);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:11,代码来源:ApplicationContextFacade.java


注:本文中的javax.servlet.SessionTrackingMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。