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

public Interface SessionDisconnectHandler

Imports
java.io.IOException, java.util.Map, org.apache.sshd.common.Service, org.apache.sshd.common.kex.KexProposalOption, org.apache.sshd.common.session.helpers.TimeoutIndicator, org.apache.sshd.common.util.buffer.Buffer, org.apache.sshd.core.CoreModuleProperties

Invoked when the internal session code decides it should disconnect a session due to some consideration. Usually allows intervening in the decision and even canceling it.
Author
Apache MINA SSHD Project

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

true if OK to ignore the exceeded attempt count and allow more attempts

Note

choosing to ignore this disconnect reason does not reset the current count - i.e., it will be re-invoked on the next attempt.

handleAuthCountDisconnectReason
(Session
The session being authenticated
session
,
Service
The Service instance through which the request was received
service
,
String
The authentication service name
serviceName
,
String
The authentication method name
method
,
String
The authentication username
user
,
int
The authentication attempt count
currentAuthCount
,
int
The maximum allowed attempts
maxAuthCount
)

Invoked if the number of authentication attempts exceeded the maximum allowed

public default boolean

Returns:

true if OK to ignore the change
handleAuthParamsDisconnectReason
(Session
The session being authenticated
session
,
Service
The Service instance through which the request was received
service
,
String
The original username being authenticated
authUser
,
String
The requested username
username
,
String
The original authentication service name
authService
,
String
The requested service name
serviceName
)

Invoked if the authentication parameters changed in mid-authentication process.

public default boolean

Returns:

true if disregard the violation - if false then session will disconnect
handleKexDisconnectReason
(Session
The session where the violation occurred
session
,
Map<KexProposalOption, String>
The client options
c2sOptions
,
Map<KexProposalOption, String>
The server options
s2cOptions
,
Map<KexProposalOption, String>
The negotiated KEX options
negotiatedGuess
,
KexProposalOption
The violating KexProposalOption
option
)

Invoked if after KEX negotiation parameters resolved one of the options violates some internal constraint (e.g., cannot negotiate a value, or RFC 8308 - section 2.2).

public default boolean

Returns:

true if accept the exceeding session regardless of the threshold. If false then exceeding session will be disconnected
handleSessionsCountDisconnectReason
(Session
The session that caused the excess
session
,
Service
The Service instance through which the request was received
service
,
String
The authenticated username that is associated with the session.
username
,
int
The current sessions count
currentSessionCount
,
int
The maximum allowed sessions count
maxSessionCount
)

Called to inform that the maximum allowed concurrent sessions threshold has been exceeded

Note

when handler is invoked the session is not yet marked as having been authenticated, nor has the authentication success been acknowledged to the peer.

public default boolean

Returns:

true if expired timeout should be reset (i.e., no disconnect). If false then session will disconnect due to the expired timeout
handleTimeoutDisconnectReason
(Session
The session whose timeout has expired
session
,
TimeoutIndicator
The expired timeout
timeoutStatus
)

Invoked when an internal timeout has expired (e.g., authentication, idle).

public default boolean

Returns:

true if disregard the request (e.g., the handler handled it)
handleUnsupportedServiceDisconnectReason
(Session
The session through which the command was received
session
,
int
The service related command
cmd
,
String
The service name
serviceName
,
Buffer
Any extra data received in the packet containing the request
buffer
)

Invoked when a request has been made related to an unknown SSH service as described in RFC 4253 - section 10.

Method Detail

handleAuthCountDisconnectReasonback to summary
public default boolean handleAuthCountDisconnectReason(Session session, Service service, String serviceName, String method, String user, int currentAuthCount, int maxAuthCount) throws IOException

Invoked if the number of authentication attempts exceeded the maximum allowed

Parameters
session:Session

The session being authenticated

service:Service

The Service instance through which the request was received

serviceName:String

The authentication service name

method:String

The authentication method name

user:String

The authentication username

currentAuthCount:int

The authentication attempt count

maxAuthCount:int

The maximum allowed attempts

Returns:boolean

true if OK to ignore the exceeded attempt count and allow more attempts

Note

choosing to ignore this disconnect reason does not reset the current count - i.e., it will be re-invoked on the next attempt.

Exceptions
IOException:
If failed to handle the event
handleAuthParamsDisconnectReasonback to summary
public default boolean handleAuthParamsDisconnectReason(Session session, Service service, String authUser, String username, String authService, String serviceName) throws IOException

Invoked if the authentication parameters changed in mid-authentication process.

Parameters
session:Session

The session being authenticated

service:Service

The Service instance through which the request was received

authUser:String

The original username being authenticated

username:String

The requested username

authService:String

The original authentication service name

serviceName:String

The requested service name

Returns:boolean

true if OK to ignore the change

Exceptions
IOException:
If failed to handle the event
handleKexDisconnectReasonback to summary
public default boolean handleKexDisconnectReason(Session session, Map<KexProposalOption, String> c2sOptions, Map<KexProposalOption, String> s2cOptions, Map<KexProposalOption, String> negotiatedGuess, KexProposalOption option) throws IOException

Invoked if after KEX negotiation parameters resolved one of the options violates some internal constraint (e.g., cannot negotiate a value, or RFC 8308 - section 2.2).

Parameters
session:Session

The session where the violation occurred

c2sOptions:Map<KexProposalOption, String>

The client options

s2cOptions:Map<KexProposalOption, String>

The server options

negotiatedGuess:Map<KexProposalOption, String>

The negotiated KEX options

option:KexProposalOption

The violating KexProposalOption

Returns:boolean

true if disregard the violation - if false then session will disconnect

Exceptions
IOException:
if attempted to exchange some packets to fix the situation
handleSessionsCountDisconnectReasonback to summary
public default boolean handleSessionsCountDisconnectReason(Session session, Service service, String username, int currentSessionCount, int maxSessionCount) throws IOException

Called to inform that the maximum allowed concurrent sessions threshold has been exceeded

Note

when handler is invoked the session is not yet marked as having been authenticated, nor has the authentication success been acknowledged to the peer.

Parameters
session:Session

The session that caused the excess

service:Service

The Service instance through which the request was received

username:String

The authenticated username that is associated with the session.

currentSessionCount:int

The current sessions count

maxSessionCount:int

The maximum allowed sessions count

Returns:boolean

true if accept the exceeding session regardless of the threshold. If false then exceeding session will be disconnected

Exceptions
IOException:
If failed to handle the event, Note: choosing to ignore this disconnect reason does not reset the current concurrent sessions counter in any way - i.e., the handler will be re-invoked every time the threshold is exceeded.
See Also
CoreModuleProperties#MAX_CONCURRENT_SESSIONS
handleTimeoutDisconnectReasonback to summary
public default boolean handleTimeoutDisconnectReason(Session session, TimeoutIndicator timeoutStatus) throws IOException

Invoked when an internal timeout has expired (e.g., authentication, idle).

Parameters
session:Session

The session whose timeout has expired

timeoutStatus:TimeoutIndicator

The expired timeout

Returns:boolean

true if expired timeout should be reset (i.e., no disconnect). If false then session will disconnect due to the expired timeout

Exceptions
IOException:
If failed to handle the event
handleUnsupportedServiceDisconnectReasonback to summary
public default boolean handleUnsupportedServiceDisconnectReason(Session session, int cmd, String serviceName, Buffer buffer) throws IOException

Invoked when a request has been made related to an unknown SSH service as described in RFC 4253 - section 10.

Parameters
session:Session

The session through which the command was received

cmd:int

The service related command

serviceName:String

The service name

buffer:Buffer

Any extra data received in the packet containing the request

Returns:boolean

true if disregard the request (e.g., the handler handled it)

Exceptions
IOException:
If failed to handle the request