|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectome.services.sessions.SessionManagerImpl
public class SessionManagerImpl
Is for ISession a cache and will be kept there in sync? OR Factors out the logic from ISession and SessionManagerI Therefore either called directly, or via synchronous messages. Uses the name of a Principal as the key to the session. We may need to limit user names to prevent this. (Strictly alphanumeric)
Field Summary | |
---|---|
protected Principal |
asroot
A private session for use only by this instance for running methods via Executor . |
protected SessionCache |
cache
|
protected OmeroContext |
context
|
protected long |
defaultTimeToIdle
|
protected long |
defaultTimeToLive
|
protected Executor |
executor
|
protected CounterFactory |
factory
|
protected SessionContext |
internalSession
Internal SessionContext created during init() which is
used for all method calls internal to the session manager (see execute*
methods) |
protected long |
maxUserTimeToIdle
|
protected long |
maxUserTimeToLive
|
protected PrincipalHolder |
principalHolder
|
protected boolean |
readOnly
|
protected Roles |
roles
|
Constructor Summary | |
---|---|
SessionManagerImpl()
|
Method Summary | |
---|---|
void |
addCallback(String sessionId,
SessionCallback cb)
|
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. |
ome.model.meta.Session |
copy(ome.model.meta.Session source)
|
ome.model.meta.Session |
create(Principal principal)
|
ome.model.meta.Session |
create(Principal _principal,
String credentials)
|
protected SessionContext |
createSessionContext(List<?> list)
Takes a snapshot as from #executeSessionContextLookup(ServiceFactory, Principal) and turns
it into a SessionContext instance. |
ome.model.meta.Share |
createShare(Principal principal,
boolean enabled,
long timeToLive,
String eventType,
String description)
|
protected void |
define(ome.model.meta.Session s,
String uuid,
String message,
long started,
long idle,
long live,
String eventType,
ome.model.internal.Permissions umask)
|
int |
detach(String uuid)
Allows decrementing the reference count for a session without calling the actual SessionManager.close(String) logic. |
protected Map<String,Object> |
environment(String session,
String env)
|
boolean |
executePasswordCheck(String name,
String credentials)
Executes a password check using the Executor framework. |
ome.model.meta.Session |
find(String uuid)
|
Object |
getCallbackObject(String sessionId,
String name)
|
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. |
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)
|
void |
init()
Initialization method called by the Spring run-time to acquire an initial Session . |
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. |
String[] |
notifications(String sessionId)
|
void |
onApplicationEvent(org.springframework.context.ApplicationEvent event)
|
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. |
void |
prepareReload()
Called once before all the reload methods are called to push out the current state to database and trigger any exceptions as the current user. |
SessionContext |
reload(SessionContext ctx)
Will be called in a synchronized block by SessionCache in order
to allow for an update. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
|
void |
setCounterFactory(CounterFactory factory)
|
void |
setDefaultTimeToIdle(long defaultTimeToIdle)
|
void |
setDefaultTimeToLive(long defaultTimeToLive)
|
void |
setExecutor(Executor executor)
|
void |
setInput(String session,
String key,
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(String session,
String key,
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. |
void |
setPrincipalHolder(PrincipalHolder principal)
|
void |
setReadOnly(boolean readOnly)
|
void |
setRoles(Roles securityRoles)
|
void |
setSessionCache(SessionCache sessionCache)
|
void |
setUuid(String uuid)
|
ome.model.meta.Session |
update(ome.model.meta.Session session)
See ISession.updateSession(Session) for the logic that's
implemented here. |
ome.model.meta.Session |
update(ome.model.meta.Session session,
boolean trusted)
Same as SessionManager.update(Session) but some security checks can be
overriden. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected OmeroContext context
protected Roles roles
protected SessionCache cache
protected Executor executor
protected long defaultTimeToIdle
protected long maxUserTimeToIdle
protected long defaultTimeToLive
protected long maxUserTimeToLive
protected PrincipalHolder principalHolder
protected CounterFactory factory
protected boolean readOnly
protected Principal asroot
Executor
. The name of this Principal
will not be removed
by calls to closeAll()
.
protected SessionContext internalSession
SessionContext
created during init()
which is
used for all method calls internal to the session manager (see execute*
methods)
Constructor Detail |
---|
public SessionManagerImpl()
Method Detail |
---|
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public void setUuid(String uuid)
public void setSessionCache(SessionCache sessionCache)
public void setRoles(Roles securityRoles)
public void setExecutor(Executor executor)
public void setDefaultTimeToIdle(long defaultTimeToIdle)
public void setDefaultTimeToLive(long defaultTimeToLive)
public void setPrincipalHolder(PrincipalHolder principal)
public void setCounterFactory(CounterFactory factory)
public void setReadOnly(boolean readOnly)
public void init()
Session
.
protected void define(ome.model.meta.Session s, String uuid, String message, long started, long idle, long live, String eventType, ome.model.internal.Permissions umask)
public ome.model.meta.Session create(Principal _principal, String credentials)
create
in interface SessionManager
public ome.model.meta.Session create(Principal principal)
create
in interface SessionManager
public ome.model.meta.Share createShare(Principal principal, boolean enabled, long timeToLive, String eventType, String description)
createShare
in interface SessionManager
public ome.model.meta.Session update(ome.model.meta.Session session)
SessionManager
ISession.updateSession(Session)
for the logic that's
implemented here. Certain fields from the 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.
update
in interface SessionManager
public ome.model.meta.Session update(ome.model.meta.Session session, boolean trusted)
SessionManager
SessionManager.update(Session)
but some security checks can be
overriden. 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.
update
in interface SessionManager
protected SessionContext createSessionContext(List<?> list)
#executeSessionContextLookup(ServiceFactory, Principal)
and turns
it into a SessionContext
instance. List argument should never be
null. Abort if
#executeSessionContextLookup(ServiceFactory, Principal)
returns
null.
public ome.model.meta.Session find(String uuid)
find
in interface SessionManager
public int getReferenceCount(String uuid)
SessionManager
getReferenceCount
in interface SessionManager
public int detach(String uuid)
SessionManager
SessionManager.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.
detach
in interface SessionManager
public SessionStats getSessionStats(String uuid)
SessionManager
SessionStats
which are being counted for the given
session or throw an exception if it has been removed.
getSessionStats
in interface SessionManager
public int close(String uuid)
SessionManager
close
in interface SessionManager
public int closeAll()
SessionManager
closeAll
in interface SessionManager
public List<String> getUserRoles(String uuid)
getUserRoles
in interface SessionManager
public net.sf.ehcache.Ehcache inMemoryCache(String uuid)
SessionManager
cache
which
can be used throughout the session. On close, the cache will be disposed.
inMemoryCache
in interface SessionManager
public net.sf.ehcache.Ehcache onDiskCache(String uuid)
SessionManager
cache
which
can be used throughout the session. On close, the cache will be disposed.
onDiskCache
in interface SessionManager
public Object getInput(String session, String key) throws ome.conditions.RemovedSessionException
SessionManager
Object
stored under the given key
or null if none present. Throws an exception if there is no
Session
with the given identifier.
getInput
in interface SessionManager
session
- Not null.key
- Not null.
ome.conditions.RemovedSessionException
public Object getOutput(String session, String key) throws ome.conditions.RemovedSessionException
SessionManager
Object
stored under the given key
or null if none present. Throws an exception if there is no
Session
with the given identifier.
getOutput
in interface SessionManager
session
- Not null.key
- Not null.
ome.conditions.RemovedSessionException
public Map<String,Object> inputEnvironment(String session)
SessionManager
inputEnvironment
in interface SessionManager
public Map<String,Object> outputEnvironment(String session)
SessionManager
outputEnvironment
in interface SessionManager
protected Map<String,Object> environment(String session, String env)
public void setInput(String session, String key, Object object) throws ome.conditions.RemovedSessionException
SessionManager
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.
setInput
in interface SessionManager
session
- Not null.key
- Not null.object
- If null, key will be removed.
ome.conditions.RemovedSessionException
public void setOutput(String session, String key, Object object) throws ome.conditions.RemovedSessionException
SessionManager
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.
setOutput
in interface SessionManager
session
- Not null.key
- Not null.object
- If null, key will be removed.
ome.conditions.RemovedSessionException
public EventContext getEventContext(Principal principal)
SessionManager
EventContext
for the current Session
.
getEventContext
in interface SessionManager
public String[] notifications(String sessionId)
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
onApplicationEvent
in interface SessionManager
onApplicationEvent
in interface org.springframework.context.ApplicationListener
public void addCallback(String sessionId, SessionCallback cb)
public Object getCallbackObject(String sessionId, String name)
public ome.model.meta.Session copy(ome.model.meta.Session source)
public void prepareReload()
SessionCache.StaleCacheListener
prepareReload
in interface SessionCache.StaleCacheListener
public SessionContext reload(SessionContext ctx)
SessionCache
in order
to allow for an update.
reload
in interface SessionCache.StaleCacheListener
public boolean executePasswordCheck(String name, String credentials)
SessionManager
Executor
framework. Also
checks the credentials against current session uuids.
executePasswordCheck
in interface SessionManager
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Version: Beta-4.1.1-r5927-b91
Copyright © 2009 The University of Dundee. All Rights Reserved.