Skip to content

Instantly share code, notes, and snippets.

@prasann
Last active June 17, 2017 18:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save prasann/5bd1757cadcca7e919e5e11dffcdcb0a to your computer and use it in GitHub Desktop.
Dynamically set session expiry based on the user type
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