Class SessionManager
java.lang.Object
com.predic8.membrane.core.interceptor.session.SessionManager
- Direct Known Subclasses:
InMemorySessionManager,JwtSessionManager,MemcachedSessionManager,RedisSessionManager
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancookieRenewalNeeded(String originalCookie) Gets called when session was not modified.cookieValueToAttributes(String cookie) Transforms a cookie value into its attributes.protected String[]getAllCookieKeys(Exchange exc) protected StringgetCookieHeader(Exchange exc) static List<HeaderField>getCookies(Exchange exc) getCookieValues(Session... session) Get the String identifier of the sessions to be used as cookie value.longgetInvalidCookies(Exchange exc, String validCookie) Get all cookies String representations from the request that are not valid anymore, e.g.@NotNull SessiongetSession(Exchange exc) protected Sessionabstract voidbooleanbooleanisSecure()booleanbooleanprotected abstract booleanGets called for every cookie value.voidpostProcess(Exchange exc) voidremoveSession(Exchange exc) voidvoidsetExpiresAfterSeconds(long expiresAfterSeconds) voidsetHttpOnly(boolean httpOnly) voidvoidsetSameSite(String sameSite) setSecure(boolean secure) setSessionCookie(boolean sessionCookie) voidsetTtlExpiryRefreshOnAccess(boolean ttlExpiryRefreshOnAccess)
-
Field Details
-
SESSION_VALUE_SEPARATOR
- See Also:
-
VALUE_TO_EXPIRE_SESSION_IN_BROWSER
- See Also:
-
SESSION
- See Also:
-
SESSION_COOKIE_ORIGINAL
- See Also:
-
usernameKeyName
-
ttlExpiryRefreshOnAccess
protected boolean ttlExpiryRefreshOnAccess -
secure
protected boolean secure -
sessionCookie
protected boolean sessionCookie
-
-
Constructor Details
-
SessionManager
public SessionManager()
-
-
Method Details
-
init
- Throws:
Exception
-
cookieValueToAttributes
Transforms a cookie value into its attributes. The cookie should be assumed valid as @isValidCookieForThisSessionManager was called beforehand -
getCookieValues
Get the String identifier of the sessions to be used as cookie value. -
getInvalidCookies
Get all cookies String representations from the request that are not valid anymore, e.g. because the cookie is a self contained value and has changed or expired (e.g. jwt). Should return cookie values in the form of key=value.- Parameters:
validCookie- is the cookie value representation of the currently active session. Is key=value
-
getCookieHeaderFields
-
isValidCookieForThisSessionManager
Gets called for every cookie value. Returns if the cookie value is valid and managed by this manager instance, e.g. jwt session manager checks if the cookie is a jwt, if it has the correct issuer, if it is not expired and if the signature is valid. Cookie is in format key=value -
cookieRenewalNeeded
Gets called when session was not modified. Should check, if session needs to be renewed (e.g. jwt expiration).- Parameters:
originalCookie- the original cookie from which the session was created (can be different from current session)- Returns:
-
postProcess
-
getSessionInternal
-
getSession
-
createCookieAttributes
-
createInvalidationAttributes
-
getCookies
-
removeSession
-
getExpiresAfterSeconds
public long getExpiresAfterSeconds() -
setExpiresAfterSeconds
public void setExpiresAfterSeconds(long expiresAfterSeconds) -
getDomain
-
setDomain
-
getCookieHeader
-
isHttpOnly
public boolean isHttpOnly() -
setHttpOnly
public void setHttpOnly(boolean httpOnly) -
getSameSite
-
setSameSite
-
getAllCookieKeys
-
getIssuer
-
setIssuer
-
isTtlExpiryRefreshOnAccess
public boolean isTtlExpiryRefreshOnAccess() -
setTtlExpiryRefreshOnAccess
public void setTtlExpiryRefreshOnAccess(boolean ttlExpiryRefreshOnAccess) - Default
- true
- Description
- controls if the expiry refreshes to expiresAfterSeconds on access (true) or if it should not refresh (false)
-
isSecure
public boolean isSecure() -
setSecure
- Default
- false
- Description
- forces secure cookie attribute even when no ssl context is present (e.g. TLS termination in front of membrane)
-
isSessionCookie
public boolean isSessionCookie() -
setSessionCookie
- Default
- false
- Description
- if true removes the expire part of a set cookie header and thus makes it a session cookie
-