本文整理匯總了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);
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
示例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/*");
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
示例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
}
示例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
}
示例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();
}
}
示例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);
}
}