Class SessionManagerImpl

    • Constructor Detail

      • SessionManagerImpl

        public SessionManagerImpl()
    • Method Detail

      • setUuid

        public void setUuid​(java.lang.String uuid)
      • setSessionCache

        public void setSessionCache​(SessionCache sessionCache)
      • setExecutor

        public void setExecutor​(Executor executor)
      • setDefaultTimeToIdle

        public void setDefaultTimeToIdle​(long defaultTimeToIdle)
      • setMaxUserTimeToIdle

        public void setMaxUserTimeToIdle​(long maxUserTimeToIdle)
      • setDefaultTimeToLive

        public void setDefaultTimeToLive​(long defaultTimeToLive)
      • setMaxUserTimeToLive

        public void setMaxUserTimeToLive​(long maxUserTimeToLive)
      • setPrincipalHolder

        public void setPrincipalHolder​(PrincipalHolder principal)
      • setCounterFactory

        public void setCounterFactory​(CounterFactory factory)
      • setSessionProvider

        public void setSessionProvider​(SessionProvider sessionProvider)
      • init

        public void init()
        Initialization method called by the Spring run-time to acquire an initial Session.
      • define

        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)
      • createSessionContext

        protected SessionContext createSessionContext​(java.util.List<?> list,
                                                      SessionContext previous)
        Takes a snapshot as from 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.
      • findSameUser

        public java.util.List<ome.model.meta.Session> findSameUser​(java.lang.String uuid,
                                                                   java.lang.String... agents)
        Description copied from interface: SessionManager
        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. Sudo is taken into account. If the agent list is empty then all are included. A null may be included in the list to include null agents.
        Specified by:
        findSameUser in interface SessionManager
      • getReferenceCount

        public int getReferenceCount​(java.lang.String uuid)
        Description copied from interface: SessionManager
        Return the number of client which are presumed to be attached to this session or throw an exception if there's no such session.
        Specified by:
        getReferenceCount in interface SessionManager
      • detach

        public int detach​(java.lang.String uuid)
        Description copied from interface: SessionManager
        Allows decrementing the reference count for a session without calling the actual 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.
        Specified by:
        detach in interface SessionManager
        Returns:
        See above.
      • close

        public int close​(java.lang.String uuid)
        Description copied from interface: SessionManager
        If reference count for the session is less than 1, close the session. Otherwise decrement the reference count. The current reference count is returned. If -1, then no such session existed. If -2, then the session was removed.
        Specified by:
        close in interface SessionManager
      • getSessionData

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>> getSessionData()
        Description copied from interface: SessionManager
        Return all sessions that are active with associated possibly varying session data information.
        Specified by:
        getSessionData in interface SessionManager
      • closeAll

        public int closeAll()
        Description copied from interface: SessionManager
        Close all sessions with checking for the necessary reference counts.
        Specified by:
        closeAll in interface SessionManager
      • getUserRoles

        public java.util.List<java.lang.String> getUserRoles​(java.lang.String uuid)
        Specified by:
        getUserRoles in interface SessionManager
      • inMemoryCache

        public net.sf.ehcache.Ehcache inMemoryCache​(java.lang.String uuid)
        Description copied from interface: SessionManager
        Returns after possibly creating an in-memory cache which can be used throughout the session. On close, the cache will be disposed.
        Specified by:
        inMemoryCache in interface SessionManager
      • onDiskCache

        public net.sf.ehcache.Ehcache onDiskCache​(java.lang.String uuid)
        Description copied from interface: SessionManager
        Returns after possibly creating an on-disk cache which can be used throughout the session. On close, the cache will be disposed.
        Specified by:
        onDiskCache in interface SessionManager
      • inputEnvironment

        public java.util.Map<java.lang.String,​java.lang.Object> inputEnvironment​(java.lang.String session)
        Description copied from interface: SessionManager
        Returns a copy of the input environment.
        Specified by:
        inputEnvironment in interface SessionManager
        Parameters:
        session - The session id.
        Returns:
        Not null
      • outputEnvironment

        public java.util.Map<java.lang.String,​java.lang.Object> outputEnvironment​(java.lang.String session)
        Description copied from interface: SessionManager
        Returns a copy of the output environment.
        Specified by:
        outputEnvironment in interface SessionManager
        Parameters:
        session - The session id.
        Returns:
        Not null.
      • environment

        protected java.util.Map<java.lang.String,​java.lang.Object> environment​(java.lang.String session,
                                                                                     java.lang.String env)
      • setInput

        public void setInput​(java.lang.String session,
                             java.lang.String key,
                             java.lang.Object object)
                      throws ome.conditions.RemovedSessionException
        Description copied from interface: SessionManager
        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.
        Specified by:
        setInput in interface SessionManager
        Parameters:
        session - Not null.
        key - Not null.
        object - If null, key will be removed.
        Throws:
        ome.conditions.RemovedSessionException
      • setOutput

        public void setOutput​(java.lang.String session,
                              java.lang.String key,
                              java.lang.Object object)
                       throws ome.conditions.RemovedSessionException
        Description copied from interface: SessionManager
        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.
        Specified by:
        setOutput in interface SessionManager
        Parameters:
        session - Not null.
        key - Not null.
        object - If null, key will be removed.
        Throws:
        ome.conditions.RemovedSessionException
      • reload

        public ome.system.EventContext reload​(java.lang.String uuid)
        Description copied from interface: SessionManager
        Similar to SessionManager.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.
        Specified by:
        reload in interface SessionManager
        Parameters:
        uuid - non null.
        Returns:
        See above.
      • notifications

        public java.lang.String[] notifications​(java.lang.String sessionId)
      • addCallback

        public void addCallback​(java.lang.String sessionId,
                                SessionCallback cb)
      • getCallbackObject

        public java.lang.Object getCallbackObject​(java.lang.String sessionId,
                                                  java.lang.String name)
      • prepareReload

        public void prepareReload()
      • executePasswordCheck

        public boolean executePasswordCheck​(java.lang.String name,
                                            java.lang.String credentials)
        Description copied from interface: SessionManager
        Executes a password check using the Executor framework. Also checks the credentials against current session uuids.
        Specified by:
        executePasswordCheck in interface SessionManager
        Returns:
        See above.
      • setSecurityContext

        public ome.model.IObject setSecurityContext​(ome.system.Principal principal,
                                                    ome.model.IObject obj)
        Description copied from interface: SessionManager
        Sets the context for the current session to the given value. If it is an 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.
        Specified by:
        setSecurityContext in interface SessionManager
        Parameters:
        principal - Principal for which the context should be set.
        obj - IObject which represents the new context.
        Returns:
        See above.