Interface RememberManager
- All Known Implementing Classes:
DatabaseRemember
RememberManager
functionalities have to implement.
A RememberManager
is responsible for coupling a user ID to
an expiring remember ID. The remember ID is typically stored in a cookie in
the browser and expires after a certain duration. An authentication element
that uses a RememberManager
, should erase the remember ID
after using it once, create a new one immediately and send it to the
client. This ensures that each remember ID can only be used once.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncreateRememberId
(long userId) Create a new remember ID.void
Removes all available remember IDs.boolean
eraseRememberId
(String rememberId) Removes one particular remember ID.boolean
eraseUserRememberIds
(long userId) Removes all remember IDs for a particular user.long
Obtains the maximum time that a remember ID can be used before it becomes invalid.long
getRememberedUserId
(String rememberId) Retrieves the user ID that corresponds to a certain remember ID.int
Obtains the frequency at which the purging will happen in relationship to the scale.int
Obtains the scale at which the purging will happen in relationship to the frequency.void
Removes all remember IDs that are expired.void
setRememberDuration
(long milliseconds) Sets the maximum time that a remember ID can be used before it becomes invalid.void
setRememberPurgeFrequency
(int frequency) Set the frequency at which the purging will happen in relationship to the scale.void
setRememberPurgeScale
(int scale) Set the scale at which the purging will happen in relationship to the frequency.
-
Method Details
-
getRememberDuration
long getRememberDuration()Obtains the maximum time that a remember ID can be used before it becomes invalid.- Returns:
- The maximum lifetime in milliseconds.
- Since:
- 1.0
-
setRememberDuration
void setRememberDuration(long milliseconds) Sets the maximum time that a remember ID can be used before it becomes invalid.- Parameters:
milliseconds
- The lifetime in milliseconds.- Since:
- 1.0
-
getRememberPurgeFrequency
int getRememberPurgeFrequency()Obtains the frequency at which the purging will happen in relationship to the scale.This defaults to
RifeConfig.AuthenticationConfig.getRememberPurgeFrequency()
.- Returns:
- the purge frequency
- Since:
- 1.0
- See Also:
-
setRememberPurgeFrequency
void setRememberPurgeFrequency(int frequency) Set 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 remember sessions are accessed.
- Parameters:
frequency
- the purge frequency- Since:
- 1.0
- See Also:
-
getRememberPurgeScale
int getRememberPurgeScale()Obtains the scale at which the purging will happen in relationship to the frequency.This defaults to
RifeConfig.AuthenticationConfig.getRememberPurgeScale()
.- Returns:
- the purge scale
- Since:
- 1.0
- See Also:
-
setRememberPurgeScale
void setRememberPurgeScale(int scale) Set 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 remember sessions are accessed.
- Parameters:
scale
- the purge scale- Since:
- 1.0
- See Also:
-
createRememberId
Create a new remember ID.- Parameters:
userId
- The ID that uniquely identifies the user that has to be remembered.- Returns:
- A
String
that uniquely identifies the remembered user ID. - Throws:
RememberManagerException
- An undefined number of exceptional cases or error situations can occur when a remember ID is created. They are all indicated by throwing an instance ofRememberManagerException
. It's up to the implementations of this interface to give more specific meanings to these exceptions.- Since:
- 1.0
-
eraseRememberId
Removes one particular remember ID. This makes it instantly invalid.- Parameters:
rememberId
- The remember ID that needs to be erased.- Returns:
true
if the ID was successfully erased; orfalse
if this was not possible.- Throws:
RememberManagerException
- An undefined number of exceptional cases or error situations can occur when a remember ID is erased. They are all indicated by throwing an instance ofRememberManagerException
. It's up to the implementations of this interface to give more specific meanings to these exceptions.- Since:
- 1.0
-
eraseUserRememberIds
Removes all remember IDs for a particular user. This makes all issued remember IDs instantly invalid.- Parameters:
userId
- The id that uniquely identifies the user whose remember IDs are to be erased.- Returns:
true
if the IDs were successfully erased; orfalse
if this was not possible- Throws:
RememberManagerException
- An undefined number of exceptional cases or error situations can occur when a remember ID is erased. They are all indicated by throwing an instance ofRememberManagerException
. It's up to the implementations of this interface to give more specific meanings to these exceptions.- Since:
- 1.0
-
eraseAllRememberIds
Removes all available remember IDs. This makes all existing remember IDs instantly invalid and unusable for all users.- Throws:
RememberManagerException
- An undefined number of exceptional cases or error situations can occur when a remember ID is erased. They are all indicated by throwing an instance ofRememberManagerException
. It's up to the implementations of this interface to give more specific meanings to these exceptions.- Since:
- 1.0
-
getRememberedUserId
Retrieves the user ID that corresponds to a certain remember ID.- Parameters:
rememberId
- The remember ID that maps to the user ID.- Returns:
- the ID of the user that corresponds to the provided remember
ID; or
-1
if no user ID corresponds to the provided remember ID. - Throws:
RememberManagerException
- An undefined number of exceptional cases or error situations can occur when a user ID is retrieved. They are all indicated by throwing an instance ofRememberManagerException
. It's up to the implementations of this interface to give more specific meanings to these exceptions.- Since:
- 1.0
-
purgeRememberIds
Removes all remember IDs that are expired. This means that all remember IDs where the lifetime has been exceeded, will be removed.- Throws:
RememberManagerException
- An undefined number of exceptional cases or error situations can occur when a remember ID is purged. They are all indicated by throwing an instance ofRememberManagerException
. It's up to the implementations of this interface to give more specific meanings to these exceptions.- Since:
- 1.0
-