Package org.apache.sshd.common.session
Interface SessionContext
-
- All Superinterfaces:
AttributeRepository
,AttributeStore
,java.lang.AutoCloseable
,java.nio.channels.Channel
,java.io.Closeable
,Closeable
,ConnectionEndpointsIndicator
,PropertyResolver
,SessionHeartbeatController
,UsernameHolder
- All Known Subinterfaces:
ClientSession
,ServerSession
,Session
- All Known Implementing Classes:
AbstractClientSession
,AbstractServerSession
,AbstractSession
,ClientSessionImpl
,ServerSessionImpl
,SessionHelper
public interface SessionContext extends ConnectionEndpointsIndicator, UsernameHolder, SessionHeartbeatController, AttributeStore, Closeable
A "succinct" summary of the most important attributes of an SSH session
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T>
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
SessionHeartbeatController.HeartbeatType
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SSH_VERSION_PREFIX
Default prefix expected for the client / server identification stringstatic java.lang.String
FALLBACK_SSH_VERSION_PREFIX
Backward compatible special prefixstatic int
MAX_VERSION_LINE_LENGTH
Maximum number of characters for any single line sent as part of the initial handshake - according to RFC 4253 - section 4.2:-
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description CipherInformation
getCipherInformation(boolean incoming)
Retrieves current cipher information - Note: may change if key re-exchange executedjava.util.Map<KexProposalOption,java.lang.String>
getClientKexProposals()
java.lang.String
getClientVersion()
Retrieve the client version for this session.CompressionInformation
getCompressionInformation(boolean incoming)
Retrieves current compression information - Note: may change if key re-exchange executedjava.util.Map<KexProposalOption,java.lang.String>
getKexNegotiationResult()
KexState
getKexState()
MacInformation
getMacInformation(boolean incoming)
Retrieves current MAC information - Note: may change if key re-exchange executedjava.lang.String
getNegotiatedKexParameter(KexProposalOption paramType)
Retrieve one of the negotiated values during the KEX stagejava.util.Map<KexProposalOption,java.lang.String>
getServerKexProposals()
java.lang.String
getServerVersion()
Retrieve the server version for this session.byte[]
getSessionId()
boolean
isAuthenticated()
static boolean
isDataIntegrityTransport(SessionContext session)
static boolean
isSecureSessionTransport(SessionContext session)
boolean
isServerSession()
Quick indication if this is a server or client session (instead of having to askinstanceof
).static boolean
isValidVersionPrefix(java.lang.String version)
-
Methods inherited from interface org.apache.sshd.common.AttributeRepository
attributeKeys, getAttribute, getAttributesCount, resolveAttribute
-
Methods inherited from interface org.apache.sshd.common.AttributeStore
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.util.net.ConnectionEndpointsIndicator
getLocalAddress, getRemoteAddress
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty
-
Methods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
-
Methods inherited from interface org.apache.sshd.common.auth.UsernameHolder
getUsername
-
-
-
-
Field Detail
-
DEFAULT_SSH_VERSION_PREFIX
static final java.lang.String DEFAULT_SSH_VERSION_PREFIX
Default prefix expected for the client / server identification string- See Also:
- RFC 4253 - section 4.2, Constant Field Values
-
FALLBACK_SSH_VERSION_PREFIX
static final java.lang.String FALLBACK_SSH_VERSION_PREFIX
Backward compatible special prefix- See Also:
- RFC 4253 - section 5, Constant Field Values
-
MAX_VERSION_LINE_LENGTH
static final int MAX_VERSION_LINE_LENGTH
Maximum number of characters for any single line sent as part of the initial handshake - according to RFC 4253 - section 4.2:The maximum length of the string is 255 characters, including the Carriage Return and Line Feed.
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 askinstanceof
).- Returns:
true
if this is a server session
-
getClientVersion
java.lang.String getClientVersion()
Retrieve the client version for this session.- Returns:
- the client version - may be
null
/empty if versions not yet exchanged
-
getClientKexProposals
java.util.Map<KexProposalOption,java.lang.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:
getKexState()
-
getServerVersion
java.lang.String getServerVersion()
Retrieve the server version for this session.- Returns:
- the server version - may be
null
/empty if versions not yet exchanged
-
getServerKexProposals
java.util.Map<KexProposalOption,java.lang.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()
-
getKexState
KexState getKexState()
-
getKexNegotiationResult
java.util.Map<KexProposalOption,java.lang.String> getKexNegotiationResult()
-
getNegotiatedKexParameter
java.lang.String getNegotiatedKexParameter(KexProposalOption paramType)
Retrieve one of the negotiated values during the KEX stage- Parameters:
paramType
- The requestKexProposalOption
value - ignored ifnull
- Returns:
- The negotiated parameter value -
null
if invalid parameter or no negotiated value. - See Also:
getKexState()
-
getCipherInformation
CipherInformation getCipherInformation(boolean incoming)
Retrieves current cipher information - Note: may change if key re-exchange executed- Parameters:
incoming
- Iftrue
then the cipher for the incoming data, otherwise for the outgoing data- Returns:
- The
CipherInformation
- ornull
if not negotiated yet.
-
getCompressionInformation
CompressionInformation getCompressionInformation(boolean incoming)
Retrieves current compression information - Note: may change if key re-exchange executed- Parameters:
incoming
- Iftrue
then the compression for the incoming data, otherwise for the outgoing data- Returns:
- The
CompressionInformation
- ornull
if not negotiated yet.
-
getMacInformation
MacInformation getMacInformation(boolean incoming)
Retrieves current MAC information - Note: may change if key re-exchange executed- Parameters:
incoming
- Iftrue
then the MAC for the incoming data, otherwise for the outgoing data- Returns:
- The
MacInformation
- ornull
if not negotiated yet.
-
isAuthenticated
boolean isAuthenticated()
- Returns:
true
if session has successfully completed the authentication phase
-
isValidVersionPrefix
static boolean isValidVersionPrefix(java.lang.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
- TheSessionContext
to be examined- Returns:
true
if the context is notnull
and the ciphers have been established to anything other than "none".- See Also:
getNegotiatedKexParameter
,CIPHER_PROPOSALS
-
isDataIntegrityTransport
static boolean isDataIntegrityTransport(SessionContext session)
- Parameters:
session
- TheSessionContext
to be examined- Returns:
true
if the context is notnull
and the MAC(s) used to verify packet integrity have been established.- See Also:
getNegotiatedKexParameter
,MAC_PROPOSALS
-
-