Interface SessionContext

All Superinterfaces:
AttributeRepository, AttributeStore, AutoCloseable, Channel, Closeable, Closeable, ConnectionEndpointsIndicator, PropertyResolver, SessionHeartbeatController, UsernameHolder
All Known Subinterfaces:
ClientSession, ServerSession, Session
All Known Implementing Classes:
AbstractClientSession, AbstractServerSession, AbstractSession, ClientSessionImpl, ServerSessionImpl, SessionHelper

A "succinct" summary of the most important attributes of an SSH session
  • Field Details

  • Method Details

    • getSessionId

      byte[] getSessionId()
      Returns:
      A clone of the established session identifier - null if not yet established
    • isServerSession

      boolean isServerSession()
      Quick indication if this is a server or client session (instead of having to ask instanceof).
      Returns:
      true if this is a server session
    • getClientVersion

      String getClientVersion()
      Retrieve the client version for this session.
      Returns:
      the client version - may be null/empty if versions not yet exchanged
    • getClientKexProposals

      Map<KexProposalOption,String> getClientKexProposals()
      Returns:
      An un-modifiable map of the latest KEX client proposal options May be empty if KEX not yet completed or re-keying in progress
      See Also:
    • getServerVersion

      String getServerVersion()
      Retrieve the server version for this session.
      Returns:
      the server version - may be null/empty if versions not yet exchanged
    • getServerKexProposals

      Map<KexProposalOption,String> getServerKexProposals()
      Returns:
      An un-modifiable map of the latest KEX client proposal options. May be empty if KEX not yet completed or re-keying in progress
      See Also:
    • getKexState

      KexState getKexState()
    • getKexNegotiationResult

      Map<KexProposalOption,String> getKexNegotiationResult()
    • getNegotiatedKexParameter

      String getNegotiatedKexParameter(KexProposalOption paramType)
      Retrieve one of the negotiated values during the KEX stage
      Parameters:
      paramType - The request KexProposalOption value - ignored if null
      Returns:
      The negotiated parameter value - null if invalid parameter or no negotiated value.
      See Also:
    • getCipherInformation

      CipherInformation getCipherInformation(boolean incoming)
      Retrieves current cipher information - Note: may change if key re-exchange executed
      Parameters:
      incoming - If true then the cipher for the incoming data, otherwise for the outgoing data
      Returns:
      The CipherInformation - or null if not negotiated yet.
    • getCompressionInformation

      CompressionInformation getCompressionInformation(boolean incoming)
      Retrieves current compression information - Note: may change if key re-exchange executed
      Parameters:
      incoming - If true then the compression for the incoming data, otherwise for the outgoing data
      Returns:
      The CompressionInformation - or null if not negotiated yet.
    • getMacInformation

      MacInformation getMacInformation(boolean incoming)
      Retrieves current MAC information - Note: may change if key re-exchange executed
      Parameters:
      incoming - If true then the MAC for the incoming data, otherwise for the outgoing data
      Returns:
      The MacInformation - or null if not negotiated yet.
    • isAuthenticated

      boolean isAuthenticated()
      Returns:
      true if session has successfully completed the authentication phase
    • isValidVersionPrefix

      static boolean isValidVersionPrefix(String version)
      Parameters:
      version - The reported client/server version
      Returns:
      true if version not empty and starts with either "SSH-2.0-" or "SSH-1.99-"
    • isSecureSessionTransport

      static boolean isSecureSessionTransport(SessionContext session)
      Parameters:
      session - The SessionContext to be examined
      Returns:
      true if the context is not null and the ciphers have been established to anything other than "none".
      See Also:
    • isDataIntegrityTransport

      static boolean isDataIntegrityTransport(SessionContext session)
      Parameters:
      session - The SessionContext to be examined
      Returns:
      true if the context is not null and the MAC(s) used to verify packet integrity have been established.
      See Also: