Last active
June 17, 2017 18:57
-
-
Save prasann/5bd1757cadcca7e919e5e11dffcdcb0a to your computer and use it in GitHub Desktop.
Dynamically set session expiry based on the user type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DynamicSessionIdentifierStrategy implements HttpSessionStrategy { | |
private static CookieHttpSessionStrategy cookieHttpSessionStrategy = | |
new CookieHttpSessionStrategy(); | |
/* Code redacted */ | |
@Override | |
public void onNewSession(Session session, HttpServletRequest httpServletRequest, | |
HttpServletResponse httpServletResponse) { | |
if (!principalManager.isLoggedIn()) { | |
return; | |
} | |
int timeOut = principalManager.isInternalUser() ? 1000 : 100 | |
session.setMaxInactiveIntervalInSeconds(timeOut); | |
cookieHttpSessionStrategy.onNewSession(session, httpServletRequest, | |
httpServletResponse) | |
} | |
/* Code redacted */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment