public class ClientSessionImpl extends AbstractClientSession
ClientSession
Modifier and Type | Class and Description |
---|---|
private static class |
ClientSessionImpl.Services
Encapsulates and protects against concurrent access the service switching.
|
AbstractSession.MessageCodingSettings
AbstractCloseable.State
ClientSession.ClientSessionEvent
SessionHeartbeatController.HeartbeatType
AttributeRepository.AttributeKey<T>
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> |
authErrorHolder
Also guards setting an earlyError and the authFuture together.
|
private AuthFuture |
authFuture
|
private java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> |
beforeAuthErrorHolder |
private java.util.concurrent.atomic.AtomicBoolean |
initialServiceRequestSent |
private java.util.Map<java.lang.Object,java.lang.Object> |
metadataMap
For clients to store their own metadata
|
sendImmediateClientIdentification, sendImmediateKexInit
channelListenerProxy, channelListeners, clientProposal, clientVersion, currentService, decodeLock, decoderBuffer, decoderLength, decoderState, encodeLock, firstKexPacketFollows, ignorePacketDataLength, ignorePacketsCount, ignorePacketsFrequency, ignorePacketsVariance, inBlocksCount, inBytesCount, inCipher, inCipherSize, inCompression, initialKexDone, inMac, inMacResult, inMacSize, inPacketsCount, inSettings, kex, kexFutureHolder, kexHandler, kexInitializedFuture, kexState, lastKeyTimeValue, maxRekeyBlocks, maxRekeyBytes, maxRekeyInterval, maxRekyPackets, negotiationResult, outBlocksCount, outBytesCount, outCipher, outCipherSize, outCompression, outMac, outMacSize, outPacketsCount, outSettings, random, requestLock, seqi, seqo, serverProposal, serverVersion, SESSION, sessionId, sessionListenerProxy, sessionListeners, tunnelListenerProxy, tunnelListeners, uncompressBuffer, unmodClientProposal, unmodNegotiationResult, unmodServerProposal
authStart, idleStart, initialKexProposal
closeFuture, futureLock, state
log
REMOTE_COMMAND_WAIT_EVENTS
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH
EMPTY
NONE
Constructor and Description |
---|
ClientSessionImpl(ClientFactoryManager client,
IoSession ioSession) |
Modifier and Type | Method and Description |
---|---|
AuthFuture |
auth()
Starts the authentication process.
|
void |
exceptionCaught(java.lang.Throwable t)
Handle any exceptions that occurred on this session.
|
private ClientSessionImpl.Services |
getCurrentServices() |
java.util.Map<java.lang.Object,java.lang.Object> |
getMetadataMap()
Access to the metadata.
|
protected java.util.List<Service> |
getServices() |
java.util.Set<ClientSession.ClientSessionEvent> |
getSessionState() |
protected void |
handleDisconnect(int code,
java.lang.String msg,
java.lang.String lang,
Buffer buffer) |
protected CurrentService |
initializeCurrentService()
Creates a new
CurrentService instance managing this session's current SSH service. |
protected java.lang.String |
nextServiceName() |
protected void |
preClose()
preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.
|
protected void |
sendInitialServiceRequest() |
protected void |
signalAuthFailure(java.lang.Throwable t) |
protected void |
signalSessionEvent(SessionListener.Event event)
Sends a session event to all currently registered session listeners
|
void |
switchToNextService() |
protected <C extends java.util.Collection<ClientSession.ClientSessionEvent>> |
updateCurrentSessionState(C state) |
java.util.Set<ClientSession.ClientSessionEvent> |
waitFor(java.util.Collection<ClientSession.ClientSessionEvent> mask,
long timeout)
Wait for any one of a specific state to be signaled.
|
addPasswordIdentity, addPublicKeyIdentity, checkKeys, createChannel, createChannel, createDirectTcpipChannel, createExecChannel, createShellChannel, createSubsystemChannel, getClientProxyConnector, getConnectAddress, getConnectionContext, getConnectionService, getFactoryManager, getForwarder, getHostBasedAuthenticationReporter, getKeyIdentityProvider, getPasswordAuthenticationReporter, getPasswordIdentityProvider, getPublicKeyAuthenticationReporter, getRegisteredIdentities, getServerKey, getServerKeyVerifier, getUserAuthFactories, getUserAuthService, getUserInteraction, initializeKeyExchangePhase, initializeProxyConnector, readIdentification, receiveKexInit, receiveKexInit, removePasswordIdentity, removePublicKeyIdentity, resolveAvailableSignaturesProposal, sendClientIdentification, sendKexInit, setClientProxyConnector, setConnectAddress, setHostBasedAuthenticationReporter, setKexSeed, setKeyIdentityProvider, setPasswordAuthenticationReporter, setPasswordIdentityProvider, setPublicKeyAuthenticationReporter, setServerKey, setServerKeyVerifier, setUserAuthFactories, setUserInteraction, signalExtraServerVersionInfo, startDynamicPortForwarding, startLocalPortForwarding, startRemotePortForwarding, startService, stopDynamicPortForwarding, stopLocalPortForwarding, stopRemotePortForwarding, switchToNoneCipher
addChannelListener, addPortForwardingEventListener, addSessionListener, aeadOutgoingBuffer, appendOutgoingMac, attachSession, calculatePadLength, checkRekey, comparePreferredKexProposalOption, createBuffer, decode, determineRekeyBlockLimit, doHandleMessage, doInvokeUnimplementedMessageHandler, doKexNegotiation, doWritePacket, encode, encryptOutgoingBuffer, getChannelListenerProxy, getCipherInformation, getClientKexData, getClientKexProposals, getClientVersion, getCompressionInformation, getInnerCloseable, getKex, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getPortForwardingEventListenerProxy, getServerKexData, getServerKexProposals, getServerVersion, getService, getSession, getSession, getSessionId, getSessionListenerProxy, handleFirstKexPacketFollows, handleKexExtension, handleKexInit, handleKexMessage, handleMessage, handleNewCompression, handleNewKeys, handleServiceAccept, handleServiceAccept, handleServiceRequest, handleServiceRequest, initializeKeyExchangeMessageHandler, isRekeyBlocksCountExceeded, isRekeyDataSizeExceeded, isRekeyPacketCountsExceeded, isRekeyRequired, isRekeyTimeIntervalExceeded, messageReceived, negotiate, notImplemented, prepareBuffer, prepareNewKeys, preProcessEncodeBuffer, receiveKexInit, reExchangeKeys, refreshConfiguration, removeChannelListener, removePortForwardingEventListener, removeSessionListener, request, request, requestFailure, requestNewKeysExchange, requestSuccess, resolveIgnoreBufferDataLength, resolveOutputPacket, resolveSessionKexProposal, sendKexInit, sendNewKeys, setClientKexData, setInputEncoding, setNegotiationResult, setOutputEncoding, setServerKexData, validateIncomingMac, validateKexState, validateServiceKexState, validateTargetBuffer, writePacket, writePacket
attributeKeys, calculateNextIgnorePacketCount, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, clearAttributes, computeAttributeIfAbsent, createProposal, disconnect, doInvokeDebugMessageHandler, doInvokeIgnoreMessageHandler, doReadIdentification, getAttribute, getAttributesCount, getAuthTimeout, getAuthTimeoutStart, getBoundLocalPortForwards, getBoundRemotePortForward, getChannelStreamWriterResolver, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKexProposal, getLocalForwardsBindings, getParentPropertyResolver, getProperties, getRemoteForwardsBindings, getReservedSessionMessagesHandler, getSessionDisconnectHandler, getStartedLocalPortForwards, getStartedRemotePortForwards, getTimeoutStatus, getUnknownChannelReferenceHandler, getUsername, handleDebug, handleDisconnect, handleIgnore, handleUnimplemented, invokeSessionSignaller, isAuthenticated, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort, isServerSession, mergeProposals, removeAttribute, resetAuthTimeout, resetIdleTimeout, resizeKey, resolveAvailableSignaturesProposal, resolveChannelStreamWriterResolver, resolveIdentificationString, resolvePeerAddress, resolveReservedSessionMessagesHandler, resolveUnknownChannelReferenceHandler, sendDebugMessage, sendIdentification, sendIgnoreMessage, sendNotImplemented, setAttribute, setAuthenticated, setChannelStreamWriterResolver, setReservedSessionMessagesHandler, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setUsername, signalDisconnect, signalDisconnect, signalExceptionCaught, signalExceptionCaught, signalNegotiationEnd, signalNegotiationEnd, signalNegotiationOptionsCreated, signalNegotiationOptionsCreated, signalNegotiationStart, signalNegotiationStart, signalPeerIdentificationReceived, signalPeerIdentificationReceived, signalReadPeerIdentificationLine, signalReadPeerIdentificationLine, signalSendIdentification, signalSendIdentification, signalSessionClosed, signalSessionClosed, signalSessionCreated, signalSessionCreated, signalSessionEstablished, signalSessionEstablished, signalSessionEvent, toString
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactories
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createDynamicPortForwardingTracker, createExecChannel, createLocalPortForwardingTracker, createLocalPortForwardingTracker, createRemotePortForwardingTracker, createShellChannel, executeRemoteCommand, executeRemoteCommand, executeRemoteCommand, passwordIteratorOf, providerOf, waitFor
createBuffer, createBuffer, disconnect, getAuthTimeout, getAuthTimeoutStart, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKex, getLocalAddress, getRemoteAddress, getService, getTimeoutStatus, prepareBuffer, reExchangeKeys, request, request, request, request, resetAuthTimeout, resetIdleTimeout, resolveAttribute, resolveAttribute, sendDebugMessage, sendIgnoreMessage, setAuthenticated, writePacket, writePacket, writePacket, writePacket
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isDataIntegrityTransport, isSecureSessionTransport, isServerSession, isValidSessionPayloadSize, isValidVersionPrefix, validateSessionPayloadSize
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmpty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
setUsername
getUsername
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNames
getSignatureFactories, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames
getKexExtensionHandler, setKexExtensionHandler
addSessionListener, getSessionListenerProxy, removeSessionListener
getReservedSessionMessagesHandler, setReservedSessionMessagesHandler
getSessionDisconnectHandler, setSessionDisconnectHandler
addChannelListener, getChannelListenerProxy, removeChannelListener
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandler
setUserAuthFactoriesNames
getUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNames
startLocalPortForwarding
getBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort
private volatile AuthFuture authFuture
auth()
; null
before the first call to
auth()
.
Volatile because of unsynchronized access in updateCurrentSessionState(Collection)
.private final java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> beforeAuthErrorHolder
private final java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> authErrorHolder
private final java.util.concurrent.atomic.AtomicBoolean initialServiceRequestSent
private java.util.Map<java.lang.Object,java.lang.Object> metadataMap
public ClientSessionImpl(ClientFactoryManager client, IoSession ioSession) throws java.lang.Exception
java.lang.Exception
protected CurrentService initializeCurrentService()
AbstractSession
CurrentService
instance managing this session's current SSH service.
This initialization method is invoked once from the AbstractSession
constructor. Do not rely on subclass
fields being initialized.
initializeCurrentService
in class AbstractSession
CurrentService
instance for the sessionprivate ClientSessionImpl.Services getCurrentServices()
protected java.util.List<Service> getServices()
getServices
in class AbstractSession
public AuthFuture auth() throws java.io.IOException
ClientSession
ClientAuthenticationManager.addPasswordIdentity(String)
or
ClientAuthenticationManager.addPublicKeyIdentity(java.security.KeyPair)
.java.io.IOException
- if failed to generate the futureClientAuthenticationManager.addPasswordIdentity(String)
,
ClientAuthenticationManager.addPublicKeyIdentity(java.security.KeyPair)
public void exceptionCaught(java.lang.Throwable t)
SessionHelper
SshException
.exceptionCaught
in interface Session
exceptionCaught
in class SessionHelper
t
- the exception to processprotected void preClose()
AbstractCloseable
preClose
in class AbstractSession
protected void handleDisconnect(int code, java.lang.String msg, java.lang.String lang, Buffer buffer) throws java.lang.Exception
handleDisconnect
in class SessionHelper
java.lang.Exception
protected void signalAuthFailure(java.lang.Throwable t)
protected java.lang.String nextServiceName()
public void switchToNextService() throws java.io.IOException
java.io.IOException
protected void signalSessionEvent(SessionListener.Event event) throws java.lang.Exception
SessionHelper
signalSessionEvent
in class SessionHelper
event
- The event to sendjava.lang.Exception
- If any of the registered listeners threw an exception.protected void sendInitialServiceRequest() throws java.io.IOException
java.io.IOException
public java.util.Set<ClientSession.ClientSessionEvent> waitFor(java.util.Collection<ClientSession.ClientSessionEvent> mask, long timeout)
ClientSession
mask
- The request ClientSession.ClientSessionEvent
s masktimeout
- Wait time in milliseconds - non-positive means foreverClientSession.ClientSessionEvent.TIMEOUT
value is set)public java.util.Set<ClientSession.ClientSessionEvent> getSessionState()
ClientSession.waitFor(Collection, long)
protected <C extends java.util.Collection<ClientSession.ClientSessionEvent>> C updateCurrentSessionState(C state)
public java.util.Map<java.lang.Object,java.lang.Object> getMetadataMap()
ClientSession
Map
- Note: access to the map is not synchronized
in any way - up to
the user to take care of mutual exclusion if necessary