Package com.jgcomptech.tools.authc
Class Session
- java.lang.Object
-
- com.jgcomptech.tools.authc.Session
-
public final class Session extends java.lang.ObjectAn object representing a user login session.- Since:
- 1.4.0, 1.5.0 Updated to add open time and duration
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.time.DurationgetDuration()Returns a Duration object containing the elapsed time the session has been opened.java.lang.StringgetDurationFullString()Returns a string of the elapsed time the session has been opened in sentence format.java.lang.StringgetDurationString()Returns a string of the elapsed time the session has been opened in the format 00:00:00.java.lang.StringgetDurationStringLong()Returns a string of the elapsed time the session has been opened in the format 00:00:00.0000.java.time.LocalDateTimegetOpenTime()Returns a LocalDateTime object containing the timestamp when the session was opened.java.lang.StringgetUsername()Returns the username of the logged in user.UserRolegetUserRole()Returns the user role of the logged in user.inthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
Session
public Session(java.lang.String username, UserRole userRole)Creates an instance of a session.- Parameters:
username- the username of the logged in useruserRole- the user role of the logged in user
-
-
Method Detail
-
getUsername
public java.lang.String getUsername()
Returns the username of the logged in user.- Returns:
- the username of the logged in user
-
getUserRole
public UserRole getUserRole()
Returns the user role of the logged in user.- Returns:
- the user role of the logged in user
-
getOpenTime
public java.time.LocalDateTime getOpenTime()
Returns a LocalDateTime object containing the timestamp when the session was opened.- Returns:
- a LocalDateTime object containing the timestamp when the session was opened
- Since:
- 1.5.0
-
getDuration
public java.time.Duration getDuration()
Returns a Duration object containing the elapsed time the session has been opened.- Returns:
- a Duration object containing the elapsed time the session has been opened
- Since:
- 1.5.0
-
getDurationString
public java.lang.String getDurationString()
Returns a string of the elapsed time the session has been opened in the format 00:00:00.- Returns:
- a string of the elapsed time the session has been opened in the format 00:00:00
- Since:
- 1.5.0
-
getDurationStringLong
public java.lang.String getDurationStringLong()
Returns a string of the elapsed time the session has been opened in the format 00:00:00.0000.- Returns:
- a string of the elapsed time the session has been opened in the format 00:00:00.0000
- Since:
- 1.5.0
-
getDurationFullString
public java.lang.String getDurationFullString()
Returns a string of the elapsed time the session has been opened in sentence format.- Returns:
- a string of the elapsed time the session has been opened in sentence format
- Since:
- 1.5.0
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-