Class SessionID

java.lang.Object
com.iizix.comm.session.SessionID
All Implemented Interfaces:
ISessionStatistics

public final class SessionID extends Object implements ISessionStatistics
The session ID is used to identify a transaction session that can be used to pick up communication again after a broken link, and also to store additional information about a user and other settings to easy re-establishing a session. This could be e.g. User ID and Passwords entered by the User in various points throughout the UI. This can safely be stored in this instance as it is a volatile instance that do not persist.
Author:
Christopher Mindus
  • Field Details

    • EMPTY

      public static SessionID[] EMPTY
      Empty array.
    • PROP_REMOTE_ADDR

      public static final String PROP_REMOTE_ADDR
      Session ID properties defined.
      See Also:
    • PROP_COMM_ERROR

      public static final String PROP_COMM_ERROR
      See Also:
    • RANDOM_BYTES

      public static final int RANDOM_BYTES
      The random bytes of a session identifier, 16: 128 bits of Utilities.getSecureRandom(), rendered as 32 hex characters before the dash and the serial. Six bytes before CC-FIX-RECONNECT-TOKEN (RT-D-1): enough for a handle, too few for the masked form of the log lines to hide 64 random bits (maskID(String)).
      See Also:
  • Constructor Details

  • Method Details

    • getOpenSessionsCount

      public static int getOpenSessionsCount()
      Gets the count of open sessions.
    • getOpenSessions

      public static SessionID[] getOpenSessions()
      Gets all the Session ID's open.
    • maskID

      public static String maskID(String id)
      Masks a session identifier for a log line (CC-FIX-RECONNECT-TOKEN): the beginning and the end of its random part with "..." between them, the serial after the dash kept, so that a line can still be found and matched across the server log, the HTTP request log and a support case while the identifier cannot be used to reconnect to the session. The one helper for the form: every line that names a session identifier goes through it, the request log's reconnect member too, and the client's maskSessionID of iz/communication.js produces the same form. A random part of 24 characters or more shows MASK_SHOWN at each end (a 32-hex identifier hides 24, 96 random bits), one of 8 to 23 shows 2 at each end, a shorter one only the dots. A temporary identifier of a reconnecting manager (RECONNECT-n) is no secret and is returned as it is; so is null, and so is a string that holds the dots already: masking twice is masking once (a URL the client masked before it was logged, a line masked again).
      Parameters:
      id - The session identifier, or whatever string a client presented as one.
      Returns:
      The masked form, e.g. a1b2...e9f0-17; null for null.
    • getTransactionManager

      public ISessionTransMgr getTransactionManager()
      Gets the Session Transaction Manager.
      Returns:
      The instance, never null.
    • getSessionStatistics

      public SessionStatistics getSessionStatistics()
      Gets the statistics instance of the session.
      Specified by:
      getSessionStatistics in interface ISessionStatistics
      Returns:
      The SessionStatistics instance.
    • getSessionInfo

      public SessionInfo getSessionInfo()
      Gets the session info.
    • getSessionID

      public String getSessionID()
      Gets the session identifier.
      Returns:
      The session identifier, or null if disposed of.
    • getLogString

      public String getLogString()
      Gets the string representation of this SessionID for logging.
    • getFullLogInfo

      public String getFullLogInfo()
      Gets the string representation of this SessionID for logging when a complete "dump" is needed for diagnostics, critical errors, etc.
    • toString

      public String toString()
      The string representation: the identifier masked (maskID(String)) and the remote address once known. Every session line of a server log is built from it (CC-FIX-RECONNECT-TOKEN): the full identifier is a reconnection handle and is written to no log; getSessionID() has it, for the server monitor's end-point record and the session tables.
      Overrides:
      toString in class Object