public interface SessionManager
Session
instances for optimized login.
SessionManager
implementations should strive to be only in-memory
representations of the database used as a performance optimization. When
possible, all changes should be made to the database as quickly and as
synchronously as possible.Modifier and Type | Interface and Description |
---|---|
static class |
SessionManager.CreationRequest
Extensible data object which can be passed to create* methods to stop
the explosion of different methods.
|
Modifier and Type | Method and Description |
---|---|
int |
close(String uuid)
If reference count for the session is less than 1, close the session.
|
int |
closeAll()
Close all sessions with checking for the necessary reference counts.
|
Session |
createFromRequest(SessionManager.CreationRequest request) |
Share |
createShare(Principal principal,
boolean enabled,
long timeToLive,
String eventType,
String description,
long groupId) |
Session |
createWithAgent(Principal principal,
String agent,
String ip) |
Session |
createWithAgent(Principal principal,
String credentials,
String agent,
String ip) |
int |
detach(String uuid)
Allows decrementing the reference count for a session without calling the
actual
close(String) logic. |
boolean |
executePasswordCheck(String name,
String credentials)
Executes a password check using the
Executor framework. |
Session |
find(String uuid) |
List<Session> |
findByUser(String user) |
List<Session> |
findByUserAndAgent(String user,
String... agent)
Returns a non-null, possibly empty list of session instances
belonging to the given user and with one of the given agents.
|
EventContext |
getEventContext(Principal principal)
Provides a partial
EventContext for the current Session . |
Object |
getInput(String session,
String key)
Returns the input environment
Object stored under the given key
or null if none present. |
Object |
getOutput(String session,
String key)
Returns the output environment
Object stored under the given key
or null if none present. |
int |
getReferenceCount(String uuid)
Return the number of client which are presumed to be attached to this
session or throw an exception if there's no such session.
|
Map<String,Map<String,Object>> |
getSessionData()
Return all sessions that are active with associated possibly varying
session data information.
|
SessionStats |
getSessionStats(String uuid)
Return the
SessionStats which are being counted for the given
session or throw an exception if it has been removed. |
List<String> |
getUserRoles(String uuid) |
net.sf.ehcache.Ehcache |
inMemoryCache(String uuid)
Returns after possibly creating an in-memory
cache which
can be used throughout the session. |
Map<String,Object> |
inputEnvironment(String session)
Returns a copy of the input environment.
|
net.sf.ehcache.Ehcache |
onDiskCache(String uuid)
Returns after possibly creating an on-disk
cache which
can be used throughout the session. |
Map<String,Object> |
outputEnvironment(String session)
Returns a copy of the output environment.
|
EventContext |
reload(String uuid)
Similar to
getEventContext(Principal) but uses the internal
reload logic to get a fresh representation of the context. |
void |
setInput(String session,
String key,
Object object)
|
void |
setOutput(String session,
String key,
Object object)
|
IObject |
setSecurityContext(Principal principal,
IObject obj)
Sets the context for the current session to the given value.
|
Session |
update(Session session)
Certain fields from the
Session instance will
be copied and then saved to the db, as well as a new
SessionContext created. |
Session |
update(Session session,
boolean trust)
Same as
update(Session) but some security checks can be
overridden. |
Session createFromRequest(SessionManager.CreationRequest request)
Session createWithAgent(Principal principal, String credentials, String agent, String ip)
principal
- credentials
- agent
- ip
- Session createWithAgent(Principal principal, String agent, String ip)
principal
- agent
- ip
- Share createShare(Principal principal, boolean enabled, long timeToLive, String eventType, String description, long groupId)
principal
- enabled
- timeToLive
- eventType
- description
- groupId
- IObject setSecurityContext(Principal principal, IObject obj)
ExperimenterGroup
then the active group is
changed, and any active shares are deactivated. If it is an
Share
then the share is activate (the group is
left alone). Unless otherwise specified, the user's default group is used
as the initial context. Passing any other object will result in an
ApiUsageException
.Session update(Session session)
Session
instance will
be copied and then saved to the db, as well as a new
SessionContext
created. This method assumes that the user is NOT
an admin.Session update(Session session, boolean trust)
update(Session)
but some security checks can be
overridden. This is usually done by checking with the
SecuritySystem
but here the server is in a critical
state, and instead will trust the method invoker.int detach(String uuid)
close(String)
logic. This is useful when it is assumed
that another user will re-attach to the same session. A timeout can still
cause the session to be removed.uuid
- int getReferenceCount(String uuid)
SessionStats getSessionStats(String uuid)
SessionStats
which are being counted for the given
session or throw an exception if it has been removed.Session find(String uuid)
uuid
- SessionTimeoutException
- if the session has timed out during this call. It will then
be removed and subsequent calls will throw a
RemovedSessionException
RemovedSessionException
- if a previous call already excised this sessionList<Session> findByUserAndAgent(String user, String... agent)
Map<String,Map<String,Object>> getSessionData()
int close(String uuid)
int closeAll()
EventContext getEventContext(Principal principal) throws RemovedSessionException
EventContext
for the current Session
.principal
- Non null.RemovedSessionException
- if no session with the given Principal.getName()
EventContext reload(String uuid) throws RemovedSessionException
getEventContext(Principal)
but uses the internal
reload logic to get a fresh representation of the context. This queries
all of the user management tables (experimenter, experimentergroup, etc)
and so should not be used anywhere in a critical path.uuid
- non null.RemovedSessionException
- If the uuid does not exist.boolean executePasswordCheck(String name, String credentials)
Executor
framework. Also
checks the credentials against current session uuids.name
- credentials
- net.sf.ehcache.Ehcache inMemoryCache(String uuid)
cache
which
can be used throughout the session. On close, the cache will be disposed.net.sf.ehcache.Ehcache onDiskCache(String uuid)
cache
which
can be used throughout the session. On close, the cache will be disposed.Object getInput(String session, String key) throws RemovedSessionException
Object
stored under the given key
or null if none present. Throws an exception if there is no
Session
with the given identifier.session
- Not null.key
- Not null.RemovedSessionException
Object getOutput(String session, String key) throws RemovedSessionException
Object
stored under the given key
or null if none present. Throws an exception if there is no
Session
with the given identifier.session
- Not null.key
- Not null.RemovedSessionException
void setInput(String session, String key, Object object) throws RemovedSessionException
argument
in the input environment under the
given key, possibly initializing the Map
Throws an exception if
there is no Session
with the given identifier.session
- Not null.key
- Not null.object
- If null, key will be removed.RemovedSessionException
void setOutput(String session, String key, Object object) throws RemovedSessionException
argument
in the output environment under the
given key, possibly initializing the Map
Throws an exception if
there is no Session
with the given identifier.session
- Not null.key
- Not null.object
- If null, key will be removed.RemovedSessionException
Map<String,Object> inputEnvironment(String session)
session
- The session id.
Version: 5.2.4-ice35-b23
Copyright © 2016 The University of Dundee & Open Microscopy Environment. All Rights Reserved.