Class SessionStorageAdapterAbstract

  • All Implemented Interfaces:
    SessionStorage

    public abstract class SessionStorageAdapterAbstract
    extends java.lang.Object
    implements SessionStorage
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected kz.greetgo.security.session.SessionStorageJdbcBuilder.Names names  
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionStorageAdapterAbstract​(kz.greetgo.security.session.SessionStorageJdbcBuilder.Names names)  
    • Field Detail

      • names

        protected final kz.greetgo.security.session.SessionStorageJdbcBuilder.Names names
    • Constructor Detail

      • SessionStorageAdapterAbstract

        public SessionStorageAdapterAbstract​(kz.greetgo.security.session.SessionStorageJdbcBuilder.Names names)
    • Method Detail

      • createSessionTableSql

        protected abstract java.lang.String createSessionTableSql()
      • isExceptionAboutTableDoesNotExists

        protected abstract boolean isExceptionAboutTableDoesNotExists​(java.sql.SQLException sqlException)
      • checkTableExistsSql

        protected abstract java.lang.String checkTableExistsSql()
      • insertSessionSql

        protected abstract java.lang.String insertSessionSql​(java.util.List<java.lang.Object> sqlParams,
                                                             SessionIdentity identity,
                                                             java.lang.Object sessionData)
      • insertSession

        public void insertSession​(SessionIdentity identity,
                                  java.lang.Object sessionData)
        Description copied from interface: SessionStorage
        Insert new session
        Specified by:
        insertSession in interface SessionStorage
        Parameters:
        identity - session identity. Unique must be identity.id - it defines session
        sessionData - additional session data (to store userId, role or something else)
      • zeroSessionAge

        public boolean zeroSessionAge​(java.lang.String sessionId)
        Description copied from interface: SessionStorage
        Makes session young
        Specified by:
        zeroSessionAge in interface SessionStorage
        Parameters:
        sessionId - session id
        Returns:
        indicates session exists: true - session exists and its age made zero, false - session is absent
      • zeroSessionAgeSql

        protected abstract java.lang.String zeroSessionAgeSql​(java.util.List<java.lang.Object> sqlParams,
                                                              java.lang.String sessionId)
      • loadLastTouchedAt

        public java.util.Date loadLastTouchedAt​(java.lang.String sessionId)
        Description copied from interface: SessionStorage
        Loads session last touched time
        Specified by:
        loadLastTouchedAt in interface SessionStorage
        Parameters:
        sessionId - session id
        Returns:
        session last touched time or null, if session is absent
      • loadLastTouchedAtSql

        protected abstract java.lang.String loadLastTouchedAtSql​(java.util.List<java.lang.Object> sqlParams,
                                                                 java.lang.String sessionId)
      • removeSessionsOlderThan

        public int removeSessionsOlderThan​(int ageInHours)
        Description copied from interface: SessionStorage
        Removes all session which age is more then ageInHours
        Specified by:
        removeSessionsOlderThan in interface SessionStorage
        Parameters:
        ageInHours - session age in hours
        Returns:
        count of removed sessions
      • removeSessionsOlderThanSql

        protected abstract java.lang.String removeSessionsOlderThanSql​(java.util.List<java.lang.Object> sqlParams,
                                                                       int ageInHours)
      • loadSession

        public SessionRow loadSession​(java.lang.String sessionId)
        Description copied from interface: SessionStorage
        Loads sessionContents
        Specified by:
        loadSession in interface SessionStorage
        Parameters:
        sessionId - session id
        Returns:
        session contents or null if session is absent or session has been deactivated
      • remove

        public boolean remove​(java.lang.String sessionId)
        Description copied from interface: SessionStorage
        Removes session with specified id
        Specified by:
        remove in interface SessionStorage
        Parameters:
        sessionId - removing session id
        Returns:
        removing flag: true - session was and removed, false - session absent with specified id
      • setLastTouchedAt

        public boolean setLastTouchedAt​(java.lang.String sessionId,
                                        java.util.Date lastTouchedAt)
        Description copied from interface: SessionStorage
        Updates field lastTouchedAt of session
        Specified by:
        setLastTouchedAt in interface SessionStorage
        Parameters:
        sessionId - updating session id
        lastTouchedAt - new value
        Returns:
        update flag: true - was session with specified id and it was update, false - otherwise