Package org.spincast.plugins.session
Class SpincastSessionManagerDefault
java.lang.Object
org.spincast.plugins.session.SpincastSessionManagerDefault
- All Implemented Interfaces:
SpincastSessionManager
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
static final String
The name of the request context variable used to save the user session. -
Constructor Summary
ConstructorDescriptionSpincastSessionManagerDefault
(SpincastSessionFactory spincastSessionFactory, com.google.inject.Provider<RequestContext<?>> requestContextProvider, JsonManager jsonManager, SpincastSessionConfig spincastSessionConfig, SpincastSessionRepository spincastSessionRepository, CookieFactory cookieFactory, SpincastConfig spincastConfig) -
Method Summary
Modifier and TypeMethodDescriptionCreates a new session.createSession
(String sessionId, Instant creationDate, Instant modificationDate, JsonObject attributes) Creates a session from infos, with existing attributes if any (null
otherwise)void
Deletes the current session in the request context, if any.void
deleteOldInactiveSession
(int sessionMaxInactiveMinutes) Deletes the deletes that were inactive for too long.void
deleteSession
(String sessionId) Deletes a saved session.void
Deletes the session id on the user.Generates a new session id.protected CookieFactory
Gets the session of the current user, from the request context.protected JsonManager
protected com.google.inject.Provider<RequestContext<?>>
getSavedSession
(String sessionId) Gets a session from the database/data source.protected SpincastConfig
protected SpincastSessionConfig
protected SpincastSessionFactory
protected SpincastSessionRepository
void
saveSession
(SpincastSession session) Save session.void
saveSessionIdOnUser
(String sessionId, boolean permanent) Will save the session id to the user (by default using a cookie).protected void
saveSessionIdOnUser
(RequestContext<?> context, String sessionId, boolean permanent) final void
Saves a session, but update its modification date first.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
REQUEST_CONTEXT_VARIABLE_SESSION
The name of the request context variable used to save the user session.
-
-
Constructor Details
-
SpincastSessionManagerDefault
@Inject public SpincastSessionManagerDefault(SpincastSessionFactory spincastSessionFactory, com.google.inject.Provider<RequestContext<?>> requestContextProvider, JsonManager jsonManager, SpincastSessionConfig spincastSessionConfig, SpincastSessionRepository spincastSessionRepository, CookieFactory cookieFactory, SpincastConfig spincastConfig)
-
-
Method Details
-
getSpincastSessionFactory
-
getRequestContextProvider
-
getJsonManager
-
getSpincastSessionConfig
-
getSpincastSessionRepository
-
getCookieFactory
-
getSpincastConfig
-
createNewSession
Description copied from interface:SpincastSessionManager
Creates a new session.- Specified by:
createNewSession
in interfaceSpincastSessionManager
-
createSession
public SpincastSession createSession(String sessionId, Instant creationDate, Instant modificationDate, JsonObject attributes) Description copied from interface:SpincastSessionManager
Creates a session from infos, with existing attributes if any (null
otherwise)- Specified by:
createSession
in interfaceSpincastSessionManager
-
getCurrentSession
Description copied from interface:SpincastSessionManager
Gets the session of the current user, from the request context. If not in a request context, returnsnull
.- Specified by:
getCurrentSession
in interfaceSpincastSessionManager
-
generateNewSessionId
Description copied from interface:SpincastSessionManager
Generates a new session id.- Specified by:
generateNewSessionId
in interfaceSpincastSessionManager
-
deleteSessionIdOnUser
public void deleteSessionIdOnUser()Description copied from interface:SpincastSessionManager
Deletes the session id on the user. By default, will delete the session id cookie.- Specified by:
deleteSessionIdOnUser
in interfaceSpincastSessionManager
-
saveSessionIdOnUser
Description copied from interface:SpincastSessionManager
Will save the session id to the user (by default using a cookie).- Specified by:
saveSessionIdOnUser
in interfaceSpincastSessionManager
permanent
- iftrue
, the session id will be kept when the browser session expires.
-
saveSessionIdOnUser
-
updateModificationDateAndSaveSession
Description copied from interface:SpincastSessionManager
Saves a session, but update its modification date first.The session to save must have a session id.
- Specified by:
updateModificationDateAndSaveSession
in interfaceSpincastSessionManager
-
deleteCurrentSession
public void deleteCurrentSession()Description copied from interface:SpincastSessionManager
Deletes the current session in the request context, if any.- Specified by:
deleteCurrentSession
in interfaceSpincastSessionManager
-
getSavedSession
Description copied from interface:SpincastSessionManager
Gets a session from the database/data source.- Specified by:
getSavedSession
in interfaceSpincastSessionManager
- Returns:
- the session or
null
if not found.
-
saveSession
Description copied from interface:SpincastSessionManager
Save session.- Specified by:
saveSession
in interfaceSpincastSessionManager
-
deleteSession
Description copied from interface:SpincastSessionManager
Deletes a saved session.- Specified by:
deleteSession
in interfaceSpincastSessionManager
-
deleteOldInactiveSession
public void deleteOldInactiveSession(int sessionMaxInactiveMinutes) Description copied from interface:SpincastSessionManager
Deletes the deletes that were inactive for too long. This means their last "modification date" must be older than the specified number of mminutes.- Specified by:
deleteOldInactiveSession
in interfaceSpincastSessionManager
-