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.MessageCodingSettingsAbstractCloseable.StateClientSession.ClientSessionEventSessionHeartbeatController.HeartbeatTypeAttributeRepository.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, sendImmediateKexInitchannelListenerProxy, 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, unmodServerProposalauthStart, idleStart, initialKexProposalcloseFuture, futureLock, statelogREMOTE_COMMAND_WAIT_EVENTSDEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTHEMPTYNONE| 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, switchToNoneCipheraddChannelListener, 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, writePacketattributeKeys, 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, toStringgetCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactoriesdoCloseGracefully, doCloseImmediatelyaddCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerdebug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateDynamicPortForwardingTracker, createExecChannel, createLocalPortForwardingTracker, createLocalPortForwardingTracker, createRemotePortForwardingTracker, createShellChannel, executeRemoteCommand, executeRemoteCommand, executeRemoteCommand, passwordIteratorOf, providerOf, waitForcreateBuffer, 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, writePacketgetCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isDataIntegrityTransport, isSecureSessionTransport, isServerSession, isValidSessionPayloadSize, isValidVersionPrefix, validateSessionPayloadSizedisableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeatgetBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmptyclearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeattributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePairaddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenersetUsernamegetUsernamegetCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNamesgetSignatureFactories, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNamesgetSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNamesgetKexExtensionHandler, setKexExtensionHandleraddSessionListener, getSessionListenerProxy, removeSessionListenergetReservedSessionMessagesHandler, setReservedSessionMessagesHandlergetSessionDisconnectHandler, setSessionDisconnectHandleraddChannelListener, getChannelListenerProxy, removeChannelListenergetChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolveraddPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenergetUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandlersetUserAuthFactoriesNamesgetUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNamesstartLocalPortForwardinggetBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPortprivate 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.Exceptionprotected CurrentService initializeCurrentService()
AbstractSessionCurrentService 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 AbstractSessionCurrentService instance for the sessionprivate ClientSessionImpl.Services getCurrentServices()
protected java.util.List<Service> getServices()
getServices in class AbstractSessionpublic AuthFuture auth() throws java.io.IOException
ClientSessionClientAuthenticationManager.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)
SessionHelperSshException.exceptionCaught in interface SessionexceptionCaught in class SessionHelpert - the exception to processprotected void preClose()
AbstractCloseablepreClose in class AbstractSessionprotected void handleDisconnect(int code,
java.lang.String msg,
java.lang.String lang,
Buffer buffer)
throws java.lang.Exception
handleDisconnect in class SessionHelperjava.lang.Exceptionprotected void signalAuthFailure(java.lang.Throwable t)
protected java.lang.String nextServiceName()
public void switchToNextService()
throws java.io.IOException
java.io.IOExceptionprotected void signalSessionEvent(SessionListener.Event event) throws java.lang.Exception
SessionHelpersignalSessionEvent in class SessionHelperevent - The event to sendjava.lang.Exception - If any of the registered listeners threw an exception.protected void sendInitialServiceRequest()
throws java.io.IOException
java.io.IOExceptionpublic java.util.Set<ClientSession.ClientSessionEvent> waitFor(java.util.Collection<ClientSession.ClientSessionEvent> mask, long timeout)
ClientSessionmask - The request ClientSession.ClientSessionEvents 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()
ClientSessionMap - Note: access to the map is not synchronized in any way - up to
the user to take care of mutual exclusion if necessary