public class SessionHandler
extends java.lang.Object
| Constructor and Description |
|---|
SessionHandler(java.util.Random random)
Constructs a
SessionHandler with 1-hour-long sessions. |
SessionHandler(java.util.Random random,
long sessionLifetime)
Constructs a
SessionHandler provided sessionLifetime sessions and using an in-memory database. |
| Modifier and Type | Method and Description |
|---|---|
protected long |
generateExpiration()
Generates the expiration date using the current real time.
|
protected java.lang.String |
generateSessionID()
Generates a new session ID encoded in base64.
|
Session |
getSession(java.lang.String sessionID) |
Session |
newSession()
Creates a new session.
|
void |
refresh(java.lang.String sessionID)
Refreshes the expiration date of the session identified by
sessionID. |
boolean |
removeSession(java.lang.String sessionID)
Removes the session identified by
sessionID from the active sessions. |
public SessionHandler(java.util.Random random)
SessionHandler with 1-hour-long sessions.
Use a secure Random implementation (see java.security.SecureRandom).random - the random number generator used to create session IDs.public SessionHandler(java.util.Random random,
long sessionLifetime)
SessionHandler provided sessionLifetime sessions and using an in-memory database.
Use a secure Random implementation (see java.security.SecureRandom).random - the random number generator used to create session IDs.sessionLifetime - the time before a session is considered invalid in milliseconds.public Session newSession()
public Session getSession(java.lang.String sessionID)
sessionID - session idpublic void refresh(java.lang.String sessionID)
sessionID.sessionID - the identifier of the session.public boolean removeSession(java.lang.String sessionID)
sessionID from the active sessions.sessionID - the identifier of the session.false if no sessions are referenced by sessionID, true otherwiseprotected java.lang.String generateSessionID()
protected long generateExpiration()
System.currentTimeMillis()