Top Description Fields Methods
org.apache.sshd.common.session

public Interface SessionContext

extends ConnectionEndpointsIndicator, UsernameHolder, SessionHeartbeatController, AttributeStore, Closeable
Imports
java.util.Map, org.apache.sshd.common.AttributeStore, .Closeable, .SshConstants, org.apache.sshd.common.auth.UsernameHolder, org.apache.sshd.common.cipher.BuiltinCiphers, .CipherInformation, org.apache.sshd.common.compression.CompressionInformation, org.apache.sshd.common.kex.KexProposalOption, .KexState, org.apache.sshd.common.mac.MacInformation, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.net.ConnectionEndpointsIndicator

A "succinct" summary of the most important attributes of an SSH session
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_SSH_VERSION_PREFIX

Default prefix expected for the client / server identification string

public static final String
FALLBACK_SSH_VERSION_PREFIX

Backward compatible special prefix

public 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.

Method Summary

Modifier and TypeMethod and Description
public CipherInformation

Returns:

The CipherInformation - or null if not negotiated yet.
getCipherInformation
(boolean
If true then the cipher for the incoming data, otherwise for the outgoing data
incoming
)

Retrieves current cipher information - Note: may change if key re-exchange executed

public Map<KexProposalOption, String>

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
getClientKexProposals
()

public String

Returns:

the client version - may be null/empty if versions not yet exchanged
getClientVersion
()

Retrieve the client version for this session.

public CompressionInformation

Returns:

The CompressionInformation - or null if not negotiated yet.
getCompressionInformation
(boolean
If true then the compression for the incoming data, otherwise for the outgoing data
incoming
)

Retrieves current compression information - Note: may change if key re-exchange executed

public Map<KexProposalOption, String>
public KexState
public MacInformation

Returns:

The MacInformation - or null if not negotiated yet.
getMacInformation
(boolean
If true then the MAC for the incoming data, otherwise for the outgoing data
incoming
)

Retrieves current MAC information - Note: may change if key re-exchange executed

public String

Returns:

The negotiated parameter value - null if invalid parameter or no negotiated value.
getNegotiatedKexParameter
(KexProposalOption
The request KexProposalOption value - ignored if null
paramType
)

Retrieve one of the negotiated values during the KEX stage

public Map<KexProposalOption, String>

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
getServerKexProposals
()

public String

Returns:

the server version - may be null/empty if versions not yet exchanged
getServerVersion
()

Retrieve the server version for this session.

public byte[]

Returns:

A clone of the established session identifier - null if not yet established
getSessionId
()

public boolean

Returns:

true if session has successfully completed the authentication phase
isAuthenticated
()

public static boolean

Returns:

true if the context is not null and the MAC(s) used to verify packet integrity have been established.
isDataIntegrityTransport
(SessionContext
The SessionContext to be examined
session
)

public static boolean

Returns:

true if the context is not null and the ciphers have been established to anything other than "none".
isSecureSessionTransport
(SessionContext
The SessionContext to be examined
session
)

public boolean

Returns:

true if this is a server session
isServerSession
()

Quick indication if this is a server or client session (instead of having to ask instanceof).

public static boolean
public static boolean

Returns:

true if version not empty and starts with either SSH-2.0- or SSH-1.99-
isValidVersionPrefix
(String
The reported client/server version
version
)

public static long
validateSessionPayloadSize(long value, String format)

Inherited from org.apache.sshd.common.AttributeStore:
clearAttributescomputeAttributeIfAbsentremoveAttributesetAttribute
Inherited from org.apache.sshd.common.auth.UsernameHolder:
getUsername
Inherited from org.apache.sshd.common.Closeable:
addCloseFutureListenerclosecloseclosegetMaxCloseWaitTimeisClosedisClosingisOpenremoveCloseFutureListener
Inherited from org.apache.sshd.common.session.SessionHeartbeatController:
disableSessionHeartbeatgetSessionHeartbeatIntervalgetSessionHeartbeatTypesetSessionHeartbeatsetSessionHeartbeat
Inherited from org.apache.sshd.common.util.net.ConnectionEndpointsIndicator:
getLocalAddressgetRemoteAddress

Field Detail

DEFAULT_SSH_VERSION_PREFIXback to summary
public static final String DEFAULT_SSH_VERSION_PREFIX

Default prefix expected for the client / server identification string

See Also
RFC 4253 - section 4.2
FALLBACK_SSH_VERSION_PREFIXback to summary
public static final String FALLBACK_SSH_VERSION_PREFIX

Backward compatible special prefix

See Also
RFC 4253 - section 5
MAX_VERSION_LINE_LENGTHback to summary
public 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.

Method Detail

getCipherInformationback to summary
public CipherInformation getCipherInformation(boolean incoming)

Retrieves current cipher information - Note: may change if key re-exchange executed

Parameters
incoming:boolean

If true then the cipher for the incoming data, otherwise for the outgoing data

Returns:CipherInformation

The CipherInformation - or null if not negotiated yet.

getClientKexProposalsback to summary
public Map<KexProposalOption, String> getClientKexProposals()
Returns:Map<KexProposalOption, String>

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()
getClientVersionback to summary
public String getClientVersion()

Retrieve the client version for this session.

Returns:String

the client version - may be null/empty if versions not yet exchanged

getCompressionInformationback to summary
public CompressionInformation getCompressionInformation(boolean incoming)

Retrieves current compression information - Note: may change if key re-exchange executed

Parameters
incoming:boolean

If true then the compression for the incoming data, otherwise for the outgoing data

Returns:CompressionInformation

The CompressionInformation - or null if not negotiated yet.

getKexNegotiationResultback to summary
public Map<KexProposalOption, String> getKexNegotiationResult()
getKexStateback to summary
public KexState getKexState()
getMacInformationback to summary
public MacInformation getMacInformation(boolean incoming)

Retrieves current MAC information - Note: may change if key re-exchange executed

Parameters
incoming:boolean

If true then the MAC for the incoming data, otherwise for the outgoing data

Returns:MacInformation

The MacInformation - or null if not negotiated yet.

getNegotiatedKexParameterback to summary
public String getNegotiatedKexParameter(KexProposalOption paramType)

Retrieve one of the negotiated values during the KEX stage

Parameters
paramType:KexProposalOption

The request KexProposalOption value - ignored if null

Returns:String

The negotiated parameter value - null if invalid parameter or no negotiated value.

See Also
getKexState()
getServerKexProposalsback to summary
public Map<KexProposalOption, String> getServerKexProposals()
Returns:Map<KexProposalOption, String>

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()
getServerVersionback to summary
public String getServerVersion()

Retrieve the server version for this session.

Returns:String

the server version - may be null/empty if versions not yet exchanged

getSessionIdback to summary
public byte[] getSessionId()
Returns:byte[]

A clone of the established session identifier - null if not yet established

isAuthenticatedback to summary
public boolean isAuthenticated()
Returns:boolean

true if session has successfully completed the authentication phase

isDataIntegrityTransportback to summary
public static boolean isDataIntegrityTransport(SessionContext session)
Parameters
session:SessionContext

The SessionContext to be examined

Returns:boolean

true if the context is not null and the MAC(s) used to verify packet integrity have been established.

See Also
getNegotiatedKexParameter, MAC_PROPOSALS
isSecureSessionTransportback to summary
public static boolean isSecureSessionTransport(SessionContext session)
Parameters
session:SessionContext

The SessionContext to be examined

Returns:boolean

true if the context is not null and the ciphers have been established to anything other than "none".

See Also
getNegotiatedKexParameter, CIPHER_PROPOSALS
isServerSessionback to summary
public boolean isServerSession()

Quick indication if this is a server or client session (instead of having to ask instanceof).

Returns:boolean

true if this is a server session

isValidSessionPayloadSizeback to summary
public static boolean isValidSessionPayloadSize(long value)
isValidVersionPrefixback to summary
public static boolean isValidVersionPrefix(String version)
Parameters
version:String

The reported client/server version

Returns:boolean

true if version not empty and starts with either SSH-2.0- or SSH-1.99-

validateSessionPayloadSizeback to summary
public static long validateSessionPayloadSize(long value, String format)