Class MemorySessions
- All Implemented Interfaces:
SessionManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontinueSession(String authId) Continues an already active session.longCounts the number of active sessions.voidRemoves all available sessions.booleaneraseSession(String authId) Removes all traces of an authentication session.booleaneraseUserSessions(long userId) Removes all traces of all authentication sessions for a particular user.booleanObtains the restriction policy of the authentication ID in regard to the user's auth data.getSession(String authId) longObtains the maximum time that a user can stay inactive before an active session becomes invalid.intObtains the frequency at which the purging will happen in relationship to the scale.intObtains the scale at which the purging will happen in relationship to the frequency.longgetSessionUserId(String authId) Retrieves the id of a user that has access to a particular session.booleanisSessionValid(String authId, String authData) Verifies if a session is valid and still active.booleanlistSessions(ListSessions processor) Lists the active sessions.voidRemoves all sessions that are inactive.voidsetRestrictAuthData(boolean flags) Sets the restriction policy of the authentication ID in regard to the user's auth data.voidsetSessionDuration(long milliseconds) Sets the maximum time that a user can stay inactive before an active session becomes invalid.voidsetSessionPurgeFrequency(int frequency) Set the frequency at which the purging will happen in relationship to the scale.voidsetSessionPurgeScale(int scale) Set the scale at which the purging will happen in relationship to the frequency.startSession(long userId, String authData, boolean remembered) Starts a new session.booleanwasRemembered(String authId) Checks if a session was previously automatically created from remembered data.
-
Constructor Details
-
MemorySessions
public MemorySessions()
-
-
Method Details
-
getSessionDuration
public long getSessionDuration()Description copied from interface:SessionManagerObtains the maximum time that a user can stay inactive before an active session becomes invalid.- Specified by:
getSessionDurationin interfaceSessionManager- Returns:
- The maximum time of inactivity in milliseconds.
-
setSessionDuration
public void setSessionDuration(long milliseconds) Description copied from interface:SessionManagerSets the maximum time that a user can stay inactive before an active session becomes invalid.- Specified by:
setSessionDurationin interfaceSessionManager- Parameters:
milliseconds- The maximum time of inactivity in milliseconds.
-
getRestrictAuthData
public boolean getRestrictAuthData()Description copied from interface:SessionManagerObtains the restriction policy of the authentication ID in regard to the user's auth data.The default is
false, or no restriction.- Specified by:
getRestrictAuthDatain interfaceSessionManager- Returns:
trueif the authentication is restricted to one auth data; orfalseif the authentication ID can be used with any auth data
-
setRestrictAuthData
public void setRestrictAuthData(boolean flags) Description copied from interface:SessionManagerSets the restriction policy of the authentication ID in regard to the user's auth data.The default is
false, or no restriction.- Specified by:
setRestrictAuthDatain interfaceSessionManager- Parameters:
flags-trueto activate the auth data restriction; orfalseotherwise
-
getSessionPurgeFrequency
public int getSessionPurgeFrequency()Description copied from interface:SessionManagerObtains the frequency at which the purging will happen in relationship to the scale.This defaults to
RifeConfig.AuthenticationConfig.getSessionPurgeFrequency().- Specified by:
getSessionPurgeFrequencyin interfaceSessionManager- Returns:
- the purge frequency
- See Also:
-
setSessionPurgeFrequency
public void setSessionPurgeFrequency(int frequency) Description copied from interface:SessionManagerSet the frequency at which the purging will happen in relationship to the scale.By default, the frequency and scale respectively are 20 and 1000, which means that the purging will have once every fifty times the authentication sessions are accessed.
- Specified by:
setSessionPurgeFrequencyin interfaceSessionManager- Parameters:
frequency- the purge frequency- See Also:
-
getSessionPurgeScale
public int getSessionPurgeScale()Description copied from interface:SessionManagerObtains the scale at which the purging will happen in relationship to the frequency.This defaults to
RifeConfig.AuthenticationConfig.getSessionPurgeScale().- Specified by:
getSessionPurgeScalein interfaceSessionManager- Returns:
- the purge scale
- See Also:
-
setSessionPurgeScale
public void setSessionPurgeScale(int scale) Description copied from interface:SessionManagerSet the scale at which the purging will happen in relationship to the frequency.By default, the frequency and scale respectively are 20 and 1000, which means that the purging will have once every fifty times the authentication sessions are accessed.
- Specified by:
setSessionPurgeScalein interfaceSessionManager- Parameters:
scale- the purge scale- See Also:
-
purgeSessions
public void purgeSessions()Description copied from interface:SessionManagerRemoves all sessions that are inactive. This means that all sessions where the inactivity time has been exceeded, will be removed.- Specified by:
purgeSessionsin interfaceSessionManager
-
startSession
public String startSession(long userId, String authData, boolean remembered) throws SessionManagerException Description copied from interface:SessionManagerStarts a new session.- Specified by:
startSessionin interfaceSessionManager- Parameters:
userId- The id that uniquely identifies the user that is allowed to use this session.authData- The authentication data that is associated with the session.remembered- Indicates whether the session is started through remember me or from scratch.- Returns:
- A
Stringthat uniquely identifies the authentication session that was just started. - Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is started. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
isSessionValid
Description copied from interface:SessionManagerVerifies if a session is valid and still active.- Specified by:
isSessionValidin interfaceSessionManager- Parameters:
authId- The unique id of the authentication session that needs to be verified.authData- The authentication data that is associated with the session.- Returns:
trueif a valid active session was found; orfalseif this was not possible.- Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is verified. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
getSessionUserId
Description copied from interface:SessionManagerRetrieves the id of a user that has access to a particular session.- Specified by:
getSessionUserIdin interfaceSessionManager- Parameters:
authId- The unique id of the authentication session for which the user needs to be looked up.- Returns:
- A long
>= 0that corresponds to the user id that has access to the session; or-1if the session couldn't be found. - Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when user id of a session is retrieved. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
continueSession
Description copied from interface:SessionManagerContinues an already active session. This means that the inactivity time-out is reset to the maximal value. This is typically called each time a user accesses an application.- Specified by:
continueSessionin interfaceSessionManager- Parameters:
authId- The unique id of the authentication session that needs to be continued.- Returns:
trueif the session was successfully continued; orfalseif this was not possible (i.e. the session couldn't be found).- Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is continued. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
eraseSession
Description copied from interface:SessionManagerRemoves all traces of an authentication session. This makes the session instantly inactive and invalid.- Specified by:
eraseSessionin interfaceSessionManager- Parameters:
authId- The unique id of the authentication session that needs to be erased.- Returns:
trueif the session was successfully erased; orfalseif this was not possible (i.e. the session couldn't be found).- Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is erased. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
wasRemembered
Description copied from interface:SessionManagerChecks if a session was previously automatically created from remembered data.- Specified by:
wasRememberedin interfaceSessionManager- Parameters:
authId- The unique id of the authentication session that needs to be erased.- Returns:
trueif the session was created automatically from remembered data; orfalseif it was created from full credentials or if the session couldn't be found.- Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is erased. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
eraseUserSessions
Description copied from interface:SessionManagerRemoves all traces of all authentication sessions for a particular user. This makes all sessions of this user instantly inactive and invalid.- Specified by:
eraseUserSessionsin interfaceSessionManager- Parameters:
userId- The id that uniquely identifies the user whose sessions are to be erased.- Returns:
trueif the sessions were successfully erased; orfalseif this was not possible (i.e. no sessions couldn't be found).- Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is erased. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
eraseAllSessions
Description copied from interface:SessionManagerRemoves all available sessions. This makes all sessions instantly invalid and inactive for all users.- Specified by:
eraseAllSessionsin interfaceSessionManager- Throws:
SessionManagerException- An undefined number of exceptional cases or error situations can occur when a session is erased. They are all indicated by throwing an instance ofSessionManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.
-
getSession
-
countSessions
public long countSessions()Description copied from interface:SessionManagerCounts the number of active sessions.- Specified by:
countSessionsin interfaceSessionManager- Returns:
- The number of active sessions.
-
listSessions
Description copied from interface:SessionManagerLists the active sessions.- Specified by:
listSessionsin interfaceSessionManager- Parameters:
processor- The row processor that will be used to list the active sessions.- Returns:
trueif active sessions were found; orfalseif no session was active.
-