com.apamax.authentication
Event SessionCache


An event which holds a cache of user sessions and tokens. Sessions have a timeout within which they must be refreshed to continue the session, and a maximum session length after which the session will expire even if refreshed.
See Also:
com.apamax.authentication.SessionCache#create() - Session caches must be created with the create static action.
com.apamax.authentication.SessionCache#destroy() - Session caches must be destroyed with the destroy action before disposing of them.

Action summary
 stringadd(string user)

Add a new cache entry for a user and return the token. Should be called after authenticating the user via another means.
 stringcheck(string token)

Check whether a token is a valid session. If valid, refreshes the timestamp on the cache entry.
 stringcheckHeader(string header)

Check whether an Authorization headers contains a valid token. If valid, refreshes the timestamp on the cache entry.
 com.apamax.authentication.SessionCachestatic create(integer timeoutSecs, integer maxSessionLengthSecs)

Create a SesseionCache object.
 voiddestroy()

Stop the background garbage collection listener. Must be called before discarding the last reference to the SessionCache.
 voidexpireAll(string user)

Remove all cache entries for a given user.
 
Action detail

add

string add(string user)
Add a new cache entry for a user and return the token. Should be called after authenticating the user via another means.
Parameters:
user - The user to add the entry for.

check

string check(string token)
Check whether a token is a valid session. If valid, refreshes the timestamp on the cache entry.
Parameters:
token - The session token to check.
Returns:
The user for the token if valid, "" if not.

checkHeader

string checkHeader(string header)
Check whether an Authorization headers contains a valid token. If valid, refreshes the timestamp on the cache entry.
Parameters:
header
Returns:
The user for the token if valid, "" if not.
Throws:
IllegalArgumentException if it is not a CacheToken header.

create

com.apamax.authentication.SessionCache static create(integer timeoutSecs, integer maxSessionLengthSecs)
Create a SesseionCache object.
Parameters:
timeoutSecs - Cache entries must be checked at least once every timeoutSecs or they will expire.
maxSessionLengthSecs - Cache entries will always expire after at most maxSessionLengthSecs.
Returns:
A new SessionCache.

destroy

void destroy()
Stop the background garbage collection listener. Must be called before discarding the last reference to the SessionCache.

expireAll

void expireAll(string user)
Remove all cache entries for a given user.
Parameters:
user - The user to expire cache entries for.