Java Code Examples for org.eclipse.jetty.server.session.SessionHandler#setMaxInactiveInterval()

The following examples show how to use org.eclipse.jetty.server.session.SessionHandler#setMaxInactiveInterval() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionHandlerFactory.java    From commafeed with Apache License 2.0 6 votes vote down vote up
public SessionHandler build() {
	SessionHandler sessionHandler = new SessionHandler() {
		{
			// no setter available for maxCookieAge
			_maxCookieAge = (int) cookieMaxAge.toSeconds();
		}
	};
	SessionCache sessionCache = new DefaultSessionCache(sessionHandler);
	sessionHandler.setSessionCache(sessionCache);
	FileSessionDataStore dataStore = new FileSessionDataStore();
	sessionCache.setSessionDataStore(dataStore);

	sessionHandler.setHttpOnly(true);
	sessionHandler.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));
	sessionHandler.setMaxInactiveInterval((int) maxInactiveInterval.toSeconds());
	sessionHandler.setRefreshCookieAge((int) cookieRefreshAge.toSeconds());

	dataStore.setDeleteUnrestorableFiles(true);
	dataStore.setStoreDir(new File(path));
	dataStore.setSavePeriodSec((int) savePeriod.toSeconds());

	return sessionHandler;
}
 
Example 2
Source File: Jetty9Server.java    From gocd with Apache License 2.0 5 votes vote down vote up
@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());
}