當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionCookieConfig.setHttpOnly方法代碼示例

本文整理匯總了Java中javax.servlet.SessionCookieConfig.setHttpOnly方法的典型用法代碼示例。如果您正苦於以下問題:Java SessionCookieConfig.setHttpOnly方法的具體用法?Java SessionCookieConfig.setHttpOnly怎麽用?Java SessionCookieConfig.setHttpOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.SessionCookieConfig的用法示例。


在下文中一共展示了SessionCookieConfig.setHttpOnly方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureSessionCookie

import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
private void configureSessionCookie(SessionCookieConfig config) {
	Cookie cookie = this.session.getCookie();
	if (cookie.getName() != null) {
		config.setName(cookie.getName());
	}
	if (cookie.getDomain() != null) {
		config.setDomain(cookie.getDomain());
	}
	if (cookie.getPath() != null) {
		config.setPath(cookie.getPath());
	}
	if (cookie.getComment() != null) {
		config.setComment(cookie.getComment());
	}
	if (cookie.getHttpOnly() != null) {
		config.setHttpOnly(cookie.getHttpOnly());
	}
	if (cookie.getSecure() != null) {
		config.setSecure(cookie.getSecure());
	}
	if (cookie.getMaxAge() != null) {
		config.setMaxAge(cookie.getMaxAge());
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:25,代碼來源:ServerProperties.java

示例2: servletContextInitializer

import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Bean
public ServletContextInitializer servletContextInitializer() {
	return new ServletContextInitializer() {
		@Override
		public void onStartup(ServletContext servletContext) throws ServletException {
			servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
			SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
			sessionCookieConfig.setHttpOnly(true);
		}
	};

}
 
開發者ID:rafaelrpinto,項目名稱:VulnerableJavaWebApplication,代碼行數:14,代碼來源:AppLauncher.java

示例3: contextInitialized

import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent e) {
    System.setProperty(ApplicationConstants.CLIENT_DEFAULT_IMPL, ExtendedLinkedInApiClient.class.getName());

    DateTimeZone.setDefault(DateTimeZone.UTC);
    Locale.setDefault(Locale.ENGLISH);
    SessionCookieConfig sessionCookieConfig = e.getServletContext().getSessionCookieConfig();
    sessionCookieConfig.setHttpOnly(true);
    try {
        LogManager.getLogManager().readConfiguration(e.getServletContext().getResourceAsStream("/WEB-INF/classes/logging.properties"));
    } catch (IOException ex) {
        throw new IllegalStateException("Failed to initialize java.util.logging", ex);
    }
    ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(e.getServletContext());
    Map<String, VideoExtractor> videoExtractors = ctx.getBeansOfType(VideoExtractor.class);
    WebUtils.videoExtractors.addAll(videoExtractors.values());

    Map<String, PictureProvider> pictureProviders = ctx.getBeansOfType(PictureProvider.class);
    WebUtils.pictureProviders.addAll(pictureProviders.values());

    Map<String, UrlShorteningService> urlShorteners = ctx.getBeansOfType(UrlShorteningService.class);
    WebUtils.urlShorteners.addAll(urlShorteners.values());

    initializeSocialNetworks(e.getServletContext());

    logger.info("Welshare startup successful");
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:28,代碼來源:StartupListener.java

示例4: configureSessionCookie

import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
private void configureSessionCookie(ServletContext servletContext) {
    SessionCookieConfig config = servletContext.getSessionCookieConfig();

    config.setHttpOnly(true);
    
    Validate.notNull(environment, "environment cannot be null!");
    // set secure cookie only if current environment doesn't strictly need HTTP
    config.setSecure(!environment.acceptsProfiles(PROFILE_HTTP));
    //
    

    // FIXME and CHECKME what a mess, ouch: https://issues.jboss.org/browse/WFLY-3448 ?
    config.setPath(servletContext.getContextPath() + "/");
    //
}
 
開發者ID:alfio-event,項目名稱:alf.io,代碼行數:16,代碼來源:Initializer.java

示例5: setSessionConfig

import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
@Override
public void setSessionConfig() {
    SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
    SessionCookieConfig sessionCookieConfig = sessionManager.getSessionCookieConfig();
    sessionCookieConfig.setHttpOnly(true);
    sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
    sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
    sessionManager.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}
 
開發者ID:gocd,項目名稱:gocd,代碼行數:10,代碼來源:Jetty9Server.java


注:本文中的javax.servlet.SessionCookieConfig.setHttpOnly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。