public class SessionManagerImpl extends java.lang.Object implements SessionManager, SessionCache.StaleCacheListener, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
ApplicationListener, which should be
 used to keep the Session instances up-to-date.SessionManager.CreationRequest| Modifier and Type | Field and Description | 
|---|---|
| protected LightAdminPrivileges | adminPrivileges | 
| protected ome.system.Principal | asrootA private session for use only by this instance for running methods via
  Executor. | 
| protected SessionCache | cache | 
| protected ome.system.OmeroContext | context | 
| protected long | defaultTimeToIdle | 
| protected long | defaultTimeToLive | 
| protected Executor | executor | 
| protected CounterFactory | factory | 
| static java.lang.String | GROUP_SUDO_NS | 
| protected SessionContext | internalSessionInternal  SessionContextcreated duringinit()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 ome.system.Roles | roles | 
| protected SessionProvider | sessionProvider | 
| Constructor and Description | 
|---|
| SessionManagerImpl() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addCallback(java.lang.String sessionId,
           SessionCallback cb) | 
| 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 | copy(ome.model.meta.Session source) | 
| ome.model.meta.Session | createFromRequest(SessionManager.CreationRequest request) | 
| protected SessionContext | createSessionContext(java.util.List<?> list,
                    SessionContext previous)Takes a snapshot as from
  executeSessionContextLookup(ServiceFactory, Principal, Session)and turns it into aSessionContextinstance. | 
| 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) | 
| protected void | define(ome.model.meta.Session s,
      java.lang.String uuid,
      java.lang.String message,
      long started,
      long idle,
      long live,
      java.lang.String eventType,
      java.lang.String agent,
      java.lang.String ip) | 
| protected void | define(ome.model.meta.Session s,
      java.lang.String uuid,
      java.lang.String message,
      long started,
      SessionManager.CreationRequest req) | 
| int | detach(java.lang.String uuid)Allows decrementing the reference count for a session without calling the
 actual  SessionManager.close(String)logic. | 
| protected java.util.Map<java.lang.String,java.lang.Object> | environment(java.lang.String session,
           java.lang.String env) | 
| boolean | executePasswordCheck(java.lang.String name,
                    java.lang.String credentials)Executes a password check using the  Executorframework. | 
| ome.model.meta.Session | find(java.lang.String uuid)Finds a  Sessionand update the last access time. | 
| ome.model.meta.Session | findQuietly(java.lang.String uuid)Finds a  Sessionwithout updating the last access time. | 
| java.util.List<ome.model.meta.Session> | findSameUser(java.lang.String uuid,
            java.lang.String... agents)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. | 
| java.lang.Object | getCallbackObject(java.lang.String sessionId,
                 java.lang.String name) | 
| ome.system.EventContext | getEventContext(ome.system.Principal principal)Provides a partial  EventContextfor the currentSession. | 
| java.lang.Object | getInput(java.lang.String session,
        java.lang.String key)Returns the input environment  Objectstored 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  Objectstored 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  SessionStatswhich 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) | 
| void | init()Initialization method called by the Spring run-time to acquire an initial
  Session. | 
| net.sf.ehcache.Ehcache | inMemoryCache(java.lang.String uuid)Returns after possibly creating an in-memory  cachewhich
 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. | 
| java.lang.String[] | notifications(java.lang.String sessionId) | 
| void | onApplicationEvent(org.springframework.context.ApplicationEvent event) | 
| net.sf.ehcache.Ehcache | onDiskCache(java.lang.String uuid)Returns after possibly creating an on-disk  cachewhich
 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. | 
| void | prepareReload() | 
| SessionContext | reload(SessionContext ctx)Will be called in a synchronized block by  SessionCachein order
 to allow for an update. | 
| ome.system.EventContext | reload(java.lang.String uuid)Similar to  SessionManager.getEventContext(Principal)but uses the internal
 reload logic to get a fresh representation of the context. | 
| void | setAdminPrivileges(LightAdminPrivileges adminPrivileges) | 
| 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(java.lang.String session,
        java.lang.String key,
        java.lang.Object object)Places the  argumentin the input environment under the
 given key, possibly initializing theMapThrows an exception if
 there is noSessionwith the given identifier. | 
| void | setMaxUserTimeToIdle(long maxUserTimeToIdle) | 
| void | setMaxUserTimeToLive(long maxUserTimeToLive) | 
| void | setOutput(java.lang.String session,
         java.lang.String key,
         java.lang.Object object)Places the  argumentin the output environment under the
 given key, possibly initializing theMapThrows an exception if
 there is noSessionwith the given identifier. | 
| void | setPrincipalHolder(PrincipalHolder principal) | 
| void | setReadOnly(ReadOnlyStatus readOnly) | 
| void | setRoles(ome.system.Roles securityRoles) | 
| ome.model.IObject | setSecurityContext(ome.system.Principal principal,
                  ome.model.IObject obj)Sets the context for the current session to the given value. | 
| void | setSessionCache(SessionCache sessionCache) | 
| void | setSessionProvider(SessionProvider sessionProvider) | 
| void | setUuid(java.lang.String uuid) | 
| ome.model.meta.Session | update(ome.model.meta.Session session)Certain fields from the  Sessioninstance will
 be copied and then saved to the db, as well as a newSessionContextcreated. | 
| ome.model.meta.Session | update(ome.model.meta.Session session,
      boolean trusted)Same as  SessionManager.update(Session)but some security checks can be
 overridden. | 
public static final java.lang.String GROUP_SUDO_NS
protected ome.system.OmeroContext context
protected ome.system.Roles roles
protected LightAdminPrivileges adminPrivileges
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 SessionProvider sessionProvider
protected ome.system.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)public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic void setUuid(java.lang.String uuid)
public void setSessionCache(SessionCache sessionCache)
public void setRoles(ome.system.Roles securityRoles)
public void setAdminPrivileges(LightAdminPrivileges adminPrivileges)
public void setExecutor(Executor executor)
public void setDefaultTimeToIdle(long defaultTimeToIdle)
public void setMaxUserTimeToIdle(long maxUserTimeToIdle)
public void setDefaultTimeToLive(long defaultTimeToLive)
public void setMaxUserTimeToLive(long maxUserTimeToLive)
public void setPrincipalHolder(PrincipalHolder principal)
public void setCounterFactory(CounterFactory factory)
public void setReadOnly(ReadOnlyStatus readOnly)
public void setSessionProvider(SessionProvider sessionProvider)
public void init()
Session.protected void define(ome.model.meta.Session s,
                      java.lang.String uuid,
                      java.lang.String message,
                      long started,
                      SessionManager.CreationRequest req)
protected void define(ome.model.meta.Session s,
                      java.lang.String uuid,
                      java.lang.String message,
                      long started,
                      long idle,
                      long live,
                      java.lang.String eventType,
                      java.lang.String agent,
                      java.lang.String ip)
public ome.model.meta.Session createFromRequest(SessionManager.CreationRequest request)
createFromRequest in interface SessionManagerpublic ome.model.meta.Session createWithAgent(ome.system.Principal _principal,
                                              java.lang.String credentials,
                                              java.lang.String agent,
                                              java.lang.String ip)
createWithAgent in interface SessionManagerpublic ome.model.meta.Session createWithAgent(ome.system.Principal principal,
                                              java.lang.String agent,
                                              java.lang.String ip)
createWithAgent in interface SessionManagerpublic ome.model.meta.Share createShare(ome.system.Principal principal,
                                        boolean enabled,
                                        long timeToLive,
                                        java.lang.String eventType,
                                        java.lang.String description,
                                        long groupId)
createShare in interface SessionManagerpublic ome.model.meta.Session update(ome.model.meta.Session session)
SessionManagerSession 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 SessionManagerpublic ome.model.meta.Session update(ome.model.meta.Session session,
                                     boolean trusted)
SessionManagerSessionManager.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.update in interface SessionManagerprotected SessionContext createSessionContext(java.util.List<?> list, SessionContext previous)
executeSessionContextLookup(ServiceFactory, Principal, Session)
 and turns it into a SessionContext instance.
 List argument should never be null. Abort if
 executeSessionContextLookup(ServiceFactory, Principal, Session)
 returns null.public ome.model.meta.Session find(java.lang.String uuid)
SessionManagerSession and update the last access time.find in interface SessionManagerpublic ome.model.meta.Session findQuietly(java.lang.String uuid)
SessionManagerSession without updating the last access time.findQuietly in interface SessionManagerpublic java.util.List<ome.model.meta.Session> findSameUser(java.lang.String uuid,
                                                           java.lang.String... agents)
SessionManagernull may be included in the list to include null agents.findSameUser in interface SessionManagerpublic int getReferenceCount(java.lang.String uuid)
SessionManagergetReferenceCount in interface SessionManagerpublic int detach(java.lang.String uuid)
SessionManagerSessionManager.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 SessionManagerpublic SessionStats getSessionStats(java.lang.String uuid)
SessionManagerSessionStats which are being counted for the given
 session or throw an exception if it has been removed.getSessionStats in interface SessionManagerpublic int close(java.lang.String uuid)
SessionManagerclose in interface SessionManagerpublic java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> getSessionData()
SessionManagergetSessionData in interface SessionManagerpublic int closeAll()
SessionManagercloseAll in interface SessionManagerpublic java.util.List<java.lang.String> getUserRoles(java.lang.String uuid)
getUserRoles in interface SessionManagerpublic net.sf.ehcache.Ehcache inMemoryCache(java.lang.String uuid)
SessionManagercache which
 can be used throughout the session. On close, the cache will be disposed.inMemoryCache in interface SessionManagerpublic net.sf.ehcache.Ehcache onDiskCache(java.lang.String uuid)
SessionManagercache which
 can be used throughout the session. On close, the cache will be disposed.onDiskCache in interface SessionManagerpublic java.lang.Object getInput(java.lang.String session,
                                 java.lang.String key)
                          throws ome.conditions.RemovedSessionException
SessionManagerObject 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 SessionManagersession - Not null.key - Not null.ome.conditions.RemovedSessionExceptionpublic java.lang.Object getOutput(java.lang.String session,
                                  java.lang.String key)
                           throws ome.conditions.RemovedSessionException
SessionManagerObject 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 SessionManagersession - Not null.key - Not null.ome.conditions.RemovedSessionExceptionpublic java.util.Map<java.lang.String,java.lang.Object> inputEnvironment(java.lang.String session)
SessionManagerinputEnvironment in interface SessionManagersession - The session id.public java.util.Map<java.lang.String,java.lang.Object> outputEnvironment(java.lang.String session)
SessionManageroutputEnvironment in interface SessionManagersession - The session id.protected java.util.Map<java.lang.String,java.lang.Object> environment(java.lang.String session,
                                                                       java.lang.String env)
public void setInput(java.lang.String session,
                     java.lang.String key,
                     java.lang.Object object)
              throws ome.conditions.RemovedSessionException
SessionManagerargument 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 SessionManagersession - Not null.key - Not null.object - If null, key will be removed.ome.conditions.RemovedSessionExceptionpublic void setOutput(java.lang.String session,
                      java.lang.String key,
                      java.lang.Object object)
               throws ome.conditions.RemovedSessionException
SessionManagerargument 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 SessionManagersession - Not null.key - Not null.object - If null, key will be removed.ome.conditions.RemovedSessionExceptionpublic ome.system.EventContext getEventContext(ome.system.Principal principal)
SessionManagerEventContext for the current Session.getEventContext in interface SessionManagerprincipal - Non null.public ome.system.EventContext reload(java.lang.String uuid)
SessionManagerSessionManager.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.reload in interface SessionManageruuid - non null.public java.lang.String[] notifications(java.lang.String sessionId)
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>public void addCallback(java.lang.String sessionId,
                        SessionCallback cb)
public java.lang.Object getCallbackObject(java.lang.String sessionId,
                                          java.lang.String name)
public ome.model.meta.Session copy(ome.model.meta.Session source)
public void prepareReload()
public SessionContext reload(SessionContext ctx)
SessionCache in order
 to allow for an update.reload in interface SessionCache.StaleCacheListenerpublic boolean executePasswordCheck(java.lang.String name,
                                    java.lang.String credentials)
SessionManagerExecutor framework. Also
 checks the credentials against current session uuids.executePasswordCheck in interface SessionManagerpublic ome.model.IObject setSecurityContext(ome.system.Principal principal,
                                            ome.model.IObject obj)
SessionManagerExperimenterGroup 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.setSecurityContext in interface SessionManagerprincipal - Principal for which the context should be set.obj - IObject which represents the new context.