當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。