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(java.lang.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.
|
ome.model.meta.Session |
createFromRequest(SessionManager.CreationRequest request) |
ome.model.meta.Share |
createShare(ome.system.Principal principal,
boolean enabled,
long timeToLive,
java.lang.String eventType,
java.lang.String description,
long groupId) |
ome.model.meta.Session |
createWithAgent(ome.system.Principal principal,
java.lang.String agent,
java.lang.String ip) |
ome.model.meta.Session |
createWithAgent(ome.system.Principal principal,
java.lang.String credentials,
java.lang.String agent,
java.lang.String ip) |
int |
detach(java.lang.String uuid)
Allows decrementing the reference count for a session without calling the
actual
close(String) logic. |
boolean |
executePasswordCheck(java.lang.String name,
java.lang.String credentials)
Executes a password check using the
Executor framework. |
ome.model.meta.Session |
find(java.lang.String uuid)
Finds a
Session and update the last access time. |
ome.model.meta.Session |
findQuietly(java.lang.String uuid)
Finds a
Session without updating the last access time. |
java.util.List<ome.model.meta.Session> |
findSameUser(java.lang.String uuid,
java.lang.String... agent)
Returns a non-null, possibly empty list of session instances belonging
to the same user as the given session with one of the given agents.
|
ome.system.EventContext |
getEventContext(ome.system.Principal principal)
Provides a partial
EventContext for the current Session . |
java.lang.Object |
getInput(java.lang.String session,
java.lang.String key)
Returns the input environment
Object stored under the given key
or null if none present. |
java.lang.Object |
getOutput(java.lang.String session,
java.lang.String key)
Returns the output environment
Object stored under the given key
or null if none present. |
int |
getReferenceCount(java.lang.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.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> |
getSessionData()
Return all sessions that are active with associated possibly varying
session data information.
|
SessionStats |
getSessionStats(java.lang.String uuid)
Return the
SessionStats which are being counted for the given
session or throw an exception if it has been removed. |
java.util.List<java.lang.String> |
getUserRoles(java.lang.String uuid) |
net.sf.ehcache.Ehcache |
inMemoryCache(java.lang.String uuid)
Returns after possibly creating an in-memory
cache which
can be used throughout the session. |
java.util.Map<java.lang.String,java.lang.Object> |
inputEnvironment(java.lang.String session)
Returns a copy of the input environment.
|
net.sf.ehcache.Ehcache |
onDiskCache(java.lang.String uuid)
Returns after possibly creating an on-disk
cache which
can be used throughout the session. |
java.util.Map<java.lang.String,java.lang.Object> |
outputEnvironment(java.lang.String session)
Returns a copy of the output environment.
|
ome.system.EventContext |
reload(java.lang.String uuid)
Similar to
getEventContext(Principal) but uses the internal
reload logic to get a fresh representation of the context. |
void |
setInput(java.lang.String session,
java.lang.String key,
java.lang.Object object)
Places the
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. |
void |
setOutput(java.lang.String session,
java.lang.String key,
java.lang.Object object)
Places the
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. |
ome.model.IObject |
setSecurityContext(ome.system.Principal principal,
ome.model.IObject obj)
Sets the context for the current session to the given value.
|
ome.model.meta.Session |
update(ome.model.meta.Session session)
Certain fields from the
Session instance will
be copied and then saved to the db, as well as a new
SessionContext created. |
ome.model.meta.Session |
update(ome.model.meta.Session session,
boolean trust)
Same as
update(Session) but some security checks can be
overridden. |
ome.model.meta.Session createFromRequest(SessionManager.CreationRequest request)
ome.model.meta.Session createWithAgent(ome.system.Principal principal, java.lang.String credentials, java.lang.String agent, java.lang.String ip)
principal
- credentials
- agent
- ip
- ome.model.meta.Session createWithAgent(ome.system.Principal principal, java.lang.String agent, java.lang.String ip)
principal
- agent
- ip
- ome.model.meta.Share createShare(ome.system.Principal principal, boolean enabled, long timeToLive, java.lang.String eventType, java.lang.String description, long groupId)
principal
- enabled
- timeToLive
- eventType
- description
- groupId
- ome.model.IObject setSecurityContext(ome.system.Principal principal, ome.model.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
.principal
- Principal
for which the context should be set.obj
- IObject
which represents the new context.ome.model.meta.Session update(ome.model.meta.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.ome.model.meta.Session update(ome.model.meta.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(java.lang.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(java.lang.String uuid)
SessionStats getSessionStats(java.lang.String uuid)
SessionStats
which are being counted for the given
session or throw an exception if it has been removed.ome.model.meta.Session find(java.lang.String uuid)
Session
and update the last access time.uuid
- ome.conditions.SessionTimeoutException
- if the session has timed out during this call. It will then
be removed and subsequent calls will throw a
RemovedSessionException
ome.conditions.RemovedSessionException
- if a previous call already excised this sessionome.model.meta.Session findQuietly(java.lang.String uuid)
Session
without updating the last access time.uuid
- ome.conditions.SessionTimeoutException
- if the session has timed out during this call. It will then
be removed and subsequent calls will throw a
RemovedSessionException
ome.conditions.RemovedSessionException
- if a previous call already excised this sessionjava.util.List<ome.model.meta.Session> findSameUser(java.lang.String uuid, java.lang.String... agent)
null
may be included in the list to include null agents.java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> getSessionData()
int close(java.lang.String uuid)
int closeAll()
ome.system.EventContext getEventContext(ome.system.Principal principal) throws ome.conditions.RemovedSessionException
EventContext
for the current Session
.principal
- Non null.ome.conditions.RemovedSessionException
- if no session with the given Principal.getName()
ome.system.EventContext reload(java.lang.String uuid) throws ome.conditions.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.ome.conditions.RemovedSessionException
- If the uuid does not exist.java.util.List<java.lang.String> getUserRoles(java.lang.String uuid)
boolean executePasswordCheck(java.lang.String name, java.lang.String credentials)
Executor
framework. Also
checks the credentials against current session uuids.name
- credentials
- net.sf.ehcache.Ehcache inMemoryCache(java.lang.String uuid)
cache
which
can be used throughout the session. On close, the cache will be disposed.net.sf.ehcache.Ehcache onDiskCache(java.lang.String uuid)
cache
which
can be used throughout the session. On close, the cache will be disposed.java.lang.Object getInput(java.lang.String session, java.lang.String key) throws ome.conditions.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.ome.conditions.RemovedSessionException
java.lang.Object getOutput(java.lang.String session, java.lang.String key) throws ome.conditions.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.ome.conditions.RemovedSessionException
void setInput(java.lang.String session, java.lang.String key, java.lang.Object object) throws ome.conditions.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.ome.conditions.RemovedSessionException
void setOutput(java.lang.String session, java.lang.String key, java.lang.Object object) throws ome.conditions.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.ome.conditions.RemovedSessionException
java.util.Map<java.lang.String,java.lang.Object> inputEnvironment(java.lang.String session)
session
- The session id.java.util.Map<java.lang.String,java.lang.Object> outputEnvironment(java.lang.String session)
session
- The session id.