Class Session

  • All Implemented Interfaces:
    AccessControlled, Identifiable

    public class Session
    extends BasicItem
    A session represents the time between login and logout for a single user. Hence, a session item is automatically created when a user logs in, and is automatically updated when the user logs out.

    A session said to be active when the user is logged in.

    Version:
    2.0
    Author:
    Nicklas
    • Constructor Detail

    • Method Detail

      • getQuery

        public static ItemQuery<Session> getQuery​(User user)
        Get a query configured to retrieve sessions for the specified user.
        Parameters:
        user - The user to retreive sessions for, null is allowed if the logged in user has generic READ permission for sessions in which case all sessions will be returned
        Returns:
        An ItemQuery object
      • autoLogout

        static int autoLogout()
        Cleanup method that sets a logout-time on all sessions that doesn't have a logout time.
        Returns:
        The number of sessions updated
        Since:
        3.18
      • getType

        public Item getType()
        Description copied from interface: Identifiable
        Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.
        Returns:
        A value indicating the type of item
      • initPermissions

        void initPermissions​(int granted,
                             int denied)
                      throws BaseException
        READ permission is granted if the logged in user is the owner of this session. All other permissions are denied.
        Overrides:
        initPermissions in class BasicItem
        Parameters:
        granted - Permissions that have been granted by the subclass
        denied - Permissions that have been denied by the subclass
        Throws:
        BaseException - If the permissions couldn't be initialised
      • getLoginTime

        public Date getLoginTime()
        Get the date and time the user logged in.
        Returns:
        A Date object with the login time
      • getLogoutTime

        public Date getLogoutTime()
        Get the date and time the user logged out.
        Returns:
        A Date object with the logout time
      • getLoginComment

        public String getLoginComment()
        Get the login comment.
        Returns:
        A String object with the login comment
      • getImpersonated

        public boolean getImpersonated()
        Check if another user was acting as the user of this session.
        Returns:
        TRUE if the user was impersonated, FALSE otherwise
      • getRemoteId

        public String getRemoteId()
        Get the remote ID of the host the user used for this session. Typically it is the IP-address of the user's computer.
        Returns:
        A String object with remote ID
      • getLocation

        public String getLocation()
        Get the location of the host the user used for this session.
        Returns:
        A String object with location or null if not known
        Since:
        3.12
      • getLocationLatitude

        public Float getLocationLatitude()
        Get the location latitude of the host the user used for this session.
        Returns:
        A Float object with latitude or null if not known
        Since:
        3.12
      • getLocationLongitude

        public Float getLocationLongitude()
        Get the location longitude of the host the user used for this session.
        Returns:
        A Float object with longitude or null if not known
        Since:
        3.12
      • getAuthenticationMethod

        public String getAuthenticationMethod()
        Get the authentication method that was used to login to this session.
        Since:
        3.9