Class OSSession


  • @Immutable
    public class OSSession
    extends java.lang.Object
    This class encapsulates information about users who are currently logged in to an operating system.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String host  
      private static java.time.format.DateTimeFormatter LOGIN_FORMAT  
      private long loginTime  
      private java.lang.String terminalDevice  
      private java.lang.String userName  
    • Constructor Summary

      Constructors 
      Constructor Description
      OSSession​(java.lang.String userName, java.lang.String terminalDevice, long loginTime, java.lang.String host)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getHost()
      Gets the remote host from which the user logged in
      long getLoginTime()
      Gets the time the user logged in
      java.lang.String getTerminalDevice()
      Gets the terminal device (such as tty, pts, etc.) the user used to log in
      java.lang.String getUserName()
      Gets the login name of the user
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOGIN_FORMAT

        private static final java.time.format.DateTimeFormatter LOGIN_FORMAT
      • userName

        private final java.lang.String userName
      • terminalDevice

        private final java.lang.String terminalDevice
      • loginTime

        private final long loginTime
      • host

        private final java.lang.String host
    • Constructor Detail

      • OSSession

        public OSSession​(java.lang.String userName,
                         java.lang.String terminalDevice,
                         long loginTime,
                         java.lang.String host)
    • Method Detail

      • getUserName

        public java.lang.String getUserName()
        Gets the login name of the user
        Returns:
        the userName
      • getTerminalDevice

        public java.lang.String getTerminalDevice()
        Gets the terminal device (such as tty, pts, etc.) the user used to log in
        Returns:
        the terminalDevice
      • getLoginTime

        public long getLoginTime()
        Gets the time the user logged in
        Returns:
        the loginTime, in milliseconds since the 1970 epoch
      • getHost

        public java.lang.String getHost()
        Gets the remote host from which the user logged in
        Returns:
        the host as either an IPv4 or IPv6 representation. If the host is unspecified, may also be an empty string, depending on the platform.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object