Interface UserSessionProvider

    • Method Detail

      • getUserSessionsStream

        Stream<UserSessionModel> getUserSessionsStream​(RealmModel realm,
                                                       UserModel user)
        Obtains the online user sessions associated with the specified user.
        Parameters:
        realm - a reference to the realm.
        user - the user whose sessions are being searched.
        Returns:
        a non-null Stream of online user sessions.
      • getUserSessionsStream

        Stream<UserSessionModel> getUserSessionsStream​(RealmModel realm,
                                                       ClientModel client)
        Obtains the online user sessions associated with the specified client.
        Parameters:
        realm - a reference to the realm.
        client - the client whose user sessions are being searched.
        Returns:
        a non-null Stream of online user sessions.
      • getUserSessionsStream

        Stream<UserSessionModel> getUserSessionsStream​(RealmModel realm,
                                                       ClientModel client,
                                                       Integer firstResult,
                                                       Integer maxResults)
        Obtains the online user sessions associated with the specified client, starting from the firstResult and containing at most maxResults.
        Parameters:
        realm - a reference tot he realm.
        client - the client whose user sessions are being searched.
        firstResult - first result to return. Ignored if negative or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of online user sessions.
      • getUserSessionByBrokerUserIdStream

        Stream<UserSessionModel> getUserSessionByBrokerUserIdStream​(RealmModel realm,
                                                                    String brokerUserId)
        Obtains the online user sessions associated with the user that matches the specified brokerUserId.
        Parameters:
        realm - a reference to the realm.
        brokerUserId - the id of the broker user whose sessions are being searched.
        Returns:
        a non-null Stream of online user sessions.
      • getUserSessionWithPredicate

        UserSessionModel getUserSessionWithPredicate​(RealmModel realm,
                                                     String id,
                                                     boolean offline,
                                                     Predicate<UserSessionModel> predicate)
        Return userSession of specified ID as long as the predicate passes. Otherwise returns null. If predicate doesn't pass, implementation can do some best-effort actions to try have predicate passing (eg. download userSession from other DC)
      • getActiveClientSessionStats

        Map<String,​Long> getActiveClientSessionStats​(RealmModel realm,
                                                           boolean offline)
        Returns a summary of client sessions key is client.getId()
        Parameters:
        realm -
        offline -
        Returns:
      • removeUserSession

        void removeUserSession​(RealmModel realm,
                               UserSessionModel session)
        This will remove attached ClientLoginSessionModels too
      • removeAllExpired

        void removeAllExpired()
        Remove expired user sessions and client sessions in all the realms
      • removeExpired

        void removeExpired​(RealmModel realm)
        Removes expired user sessions owned by this realm from this provider. If this `UserSessionProvider` uses `UserSessionPersister`, the removal of the expired user sessions is also propagated to relevant `UserSessionPersister`.
        Parameters:
        realm - RealmModel Realm where all the expired user sessions to be removed from.
      • removeUserSessions

        void removeUserSessions​(RealmModel realm)
      • onRealmRemoved

        void onRealmRemoved​(RealmModel realm)
      • createOfflineUserSession

        UserSessionModel createOfflineUserSession​(UserSessionModel userSession)
        Newly created userSession won't contain attached AuthenticatedClientSessions
      • removeOfflineUserSession

        void removeOfflineUserSession​(RealmModel realm,
                                      UserSessionModel userSession)
        Removes the attached clientSessions as well
      • getOfflineUserSessionsStream

        Stream<UserSessionModel> getOfflineUserSessionsStream​(RealmModel realm,
                                                              UserModel user)
        Obtains the offline user sessions associated with the specified user.
        Parameters:
        realm - a reference to the realm.
        user - the user whose offline sessions are being searched.
        Returns:
        a non-null Stream of offline user sessions.
      • getOfflineUserSessionByBrokerUserIdStream

        Stream<UserSessionModel> getOfflineUserSessionByBrokerUserIdStream​(RealmModel realm,
                                                                           String brokerUserId)
        Obtains the offline user sessions associated with the user that matches the specified brokerUserId.
        Parameters:
        realm - a reference to the realm.
        brokerUserId - the id of the broker user whose sessions are being searched.
        Returns:
        a non-null Stream of offline user sessions.
      • getOfflineUserSessionsStream

        Stream<UserSessionModel> getOfflineUserSessionsStream​(RealmModel realm,
                                                              ClientModel client,
                                                              Integer firstResult,
                                                              Integer maxResults)
        Obtains the offline user sessions associated with the specified client, starting from the firstResult and containing at most maxResults.
        Parameters:
        realm - a reference tot he realm.
        client - the client whose user sessions are being searched.
        firstResult - first result to return. Ignored if negative or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of offline user sessions.
      • importUserSessions

        void importUserSessions​(Collection<UserSessionModel> persistentUserSessions,
                                boolean offline)
        Triggered by persister during pre-load. It imports authenticatedClientSessions too
      • close

        void close()
        Specified by:
        close in interface Provider
      • getStartupTime

        int getStartupTime​(RealmModel realm)