public class ClientSessionImpl extends AbstractClientSession
AbstractCloseable.State
ClientSession.ClientSessionEvent
Session.AttributeKey<T>, Session.TimeoutStatus
SignatureFactoriesManager.Utils
attributes, authed, authTimeoutStart, channelListenerProxy, channelListeners, clientProposal, clientVersion, currentService, decodeLock, decoderBuffer, decoderLength, decoderState, encodeLock, firstKexPacketFollows, i_c, i_s, idleTimeoutStart, ignorePacketDataLength, ignorePacketsCount, ignorePacketsFrequency, ignorePacketsVariance, inBlocksCount, inBytesCount, inCipher, inCipherSize, inCompression, inMac, inMacResult, inPacketsCount, ioSession, isServer, kex, kexFutureHolder, kexState, lastKeyTimeValue, maxRekeyBlocks, maxRekeyBytes, maxRekeyInterval, maxRekyPackets, negotiationResult, outBlocksCount, outBytesCount, outCipher, outCipherSize, outCompression, outMac, outPacketsCount, pendingPackets, random, requestLock, seqi, seqo, serverProposal, serverVersion, SESSION, sessionId, sessionListenerProxy, sessionListeners, timeoutStatus, uncompressBuffer, username
closeFuture, lock, state
log
DEFAULT_SSH_VERSION_PREFIX
DEFAULT_PASSWORD_PROMPTS, PASSWORD_PROMPTS, PREFERRED_AUTHS
Constructor and Description |
---|
ClientSessionImpl(ClientFactoryManager client,
IoSession session) |
Modifier and Type | Method and Description |
---|---|
AuthFuture |
auth()
Starts the authentication process.
|
protected void |
checkKeys() |
ChannelShell |
createShellChannel()
Create a channel to start a shell.
|
void |
exceptionCaught(Throwable t)
Handle any exceptions that occurred on this session.
|
Map<Object,Object> |
getMetadataMap()
Access to the metadata.
|
protected List<Service> |
getServices() |
protected void |
handleDisconnect(int code,
String msg,
String lang,
Buffer buffer) |
protected void |
handleMessage(Buffer buffer)
Abstract method for processing incoming decoded packets.
|
protected String |
nextServiceName() |
protected boolean |
readIdentification(Buffer buffer)
Read the other side identification.
|
protected void |
receiveKexInit(Map<KexProposalOption,String> proposal,
byte[] seed) |
protected void |
sendClientIdentification() |
protected void |
sendInitialServiceRequest() |
protected byte[] |
sendKexInit(Map<KexProposalOption,String> proposal)
Send the key exchange initialization packet.
|
protected void |
sendSessionEvent(SessionListener.Event event) |
protected void |
setKexSeed(byte... seed) |
void |
switchToNextService() |
KeyExchangeFuture |
switchToNoneCipher()
Switch to a none cipher for performance.
|
Set<ClientSession.ClientSessionEvent> |
waitFor(Collection<ClientSession.ClientSessionEvent> mask,
long timeout)
Wait for any one of a specific state to be signaled.
|
addPasswordIdentity, addPublicKeyIdentity, createChannel, createChannel, createDirectTcpipChannel, createExecChannel, createScpClient, createScpClient, createSftpClient, createSftpClient, createSftpClient, createSftpFileSystem, createSftpFileSystem, createSftpFileSystem, createSftpFileSystem, createSftpFileSystem, createSftpFileSystem, createSubsystemChannel, getConnectionService, getFactoryManager, getPasswordIdentityProvider, getRegisteredIdentities, getScpTransferEventListener, getServerKeyVerifier, getTcpipForwarder, getUserAuthFactories, getUserAuthService, getUserInteraction, removePasswordIdentity, removePublicKeyIdentity, resolveAvailableSignaturesProposal, setPasswordIdentityProvider, setScpTransferEventListener, setServerKeyVerifier, setUserAuthFactories, setUserInteraction, startDynamicPortForwarding, startLocalPortForwarding, startRemotePortForwarding, startService, stopDynamicPortForwarding, stopLocalPortForwarding, stopRemotePortForwarding
addChannelListener, addSessionListener, attachSession, calculateNextIgnorePacketCount, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, checkRekey, comparePreferredKexProposalOption, createBuffer, createBuffer, createProposal, decode, disconnect, doHandleMessage, doReadIdentification, doWritePacket, encode, getAttribute, getAuthTimeout, getChannelListenerProxy, getCipherInformation, getClientVersion, getCompressionInformation, getIdleTimeout, getInnerCloseable, getIoSession, getKex, getLock, getMacInformation, getNegotiatedKexParameter, getParentPropertyResolver, getProperties, getServerVersion, getService, getSession, getSession, getSessionId, getSessionListenerProxy, getTimeoutStatus, getUsername, handleDebug, handleDebug, handleDisconnect, handleFirstKexPacketFollows, handleIgnore, handleIgnore, handleKexInit, handleKexMessage, handleNewKeys, handleServiceAccept, handleServiceAccept, handleServiceRequest, handleServiceRequest, handleUnimplemented, handleUnimplemented, isAuthenticated, isRekeyBlocksCountExceeded, isRekeyDataSizeExceeded, isRekeyPacketCountsExceeded, isRekeyRequired, isRekeyTimeIntervalExceeded, mergeProposals, messageReceived, negotiate, notImplemented, preClose, prepareBuffer, receiveKexInit, receiveKexInit, receiveNewKeys, reExchangeKeys, refreshConfiguration, removeChannelListener, removeSessionListener, request, requestFailure, requestNewKeysExchange, requestSuccess, resetIdleTimeout, resizeKey, resolveAvailableSignaturesProposal, resolveIgnoreBufferDataLength, sendIdentification, sendKexInit, sendNewKeys, serviceAccept, setAttribute, setAuthenticated, setNegotiationResult, setUsername, toString, validateKexState, writePacket, writePacket
getCipherFactories, getCompressionFactories, getKeyExchangeFactories, getKeyPairProvider, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKeyExchangeFactories, setKeyPairProvider, setMacFactories, setSignatureFactories
doCloseGracefully, doCloseImmediately
builder, close, isClosed, isClosing
close, isOpen
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createBuffer, createBuffer, disconnect, getAttribute, getAuthTimeout, getCipherInformation, getClientVersion, getCompressionInformation, getIdleTimeout, getIoSession, getKex, getMacInformation, getNegotiatedKexParameter, getServerVersion, getService, getSessionId, getTimeoutStatus, isAuthenticated, prepareBuffer, reExchangeKeys, request, resetIdleTimeout, setAttribute, setAuthenticated, writePacket, writePacket
getCipherFactories, getCompressionFactories, getKeyExchangeFactories, getMacFactories, setCipherFactories, setCompressionFactories, setKeyExchangeFactories, setMacFactories
getKeyPairProvider, setKeyPairProvider
getSignatureFactories, setSignatureFactories
addSessionListener, getSessionListenerProxy, removeSessionListener
addChannelListener, getChannelListenerProxy, removeChannelListener
getParentPropertyResolver, getProperties
setUsername
getUsername
public ClientSessionImpl(ClientFactoryManager client, IoSession session) throws Exception
Exception
protected List<Service> getServices()
getServices
in class AbstractSession
public AuthFuture auth() throws IOException
ClientSession
ClientAuthenticationManager.addPasswordIdentity(String)
or ClientAuthenticationManager.addPublicKeyIdentity(java.security.KeyPair)
.IOException
- if failed to generate the futureClientAuthenticationManager.addPasswordIdentity(String)
,
ClientAuthenticationManager.addPublicKeyIdentity(java.security.KeyPair)
public void exceptionCaught(Throwable t)
AbstractSession
SshException
.exceptionCaught
in interface Session
exceptionCaught
in class AbstractSession
t
- the exception to processprotected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception
handleDisconnect
in class AbstractSession
Exception
protected String nextServiceName()
public void switchToNextService() throws IOException
IOException
public KeyExchangeFuture switchToNoneCipher() throws IOException
ClientSession
Switch to a none cipher for performance.
This should be done after the authentication phase has been performed. After such a switch, interactive channels are not allowed anymore. Both client and server must have been configured to support the none cipher. If that's not the case, the returned future will be set with an exception.
KeyExchangeFuture
that can be used to wait for the exchange
to be finishedIOException
- if a key exchange is already runningpublic ChannelShell createShellChannel() throws IOException
ClientSession
ChannelShell
IOException
- If failed to create the requested channelprotected void handleMessage(Buffer buffer) throws Exception
AbstractSession
handleMessage
in class AbstractSession
buffer
- the buffer containing the packetException
- if an exception occurs while handling this packet.AbstractSession.doHandleMessage(Buffer)
public Set<ClientSession.ClientSessionEvent> waitFor(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)protected boolean readIdentification(Buffer buffer) throws IOException
AbstractSession
AbstractSession.doReadIdentification(Buffer, boolean)
and
store the result in the needed property.readIdentification
in class AbstractSession
buffer
- the buffer containing the remote identificationtrue
if the identification has been fully read or
false
if more data is neededIOException
- if an error occurs such as a bad protocol versionprotected void sendClientIdentification()
protected byte[] sendKexInit(Map<KexProposalOption,String> proposal) throws IOException
AbstractSession
sendKexInit
in class AbstractSession
proposal
- our proposal for key exchange negotiationIOException
- if an error occurred sending the packetprotected void setKexSeed(byte... seed)
setKexSeed
in class AbstractSession
seed
- The result of the KEXINIT handshake - required for correct
session key establishmentprotected void receiveKexInit(Map<KexProposalOption,String> proposal, byte[] seed) throws IOException
receiveKexInit
in class AbstractSession
IOException
protected void checkKeys() throws SshException
checkKeys
in class AbstractSession
SshException
protected void sendSessionEvent(SessionListener.Event event) throws IOException
sendSessionEvent
in class AbstractSession
IOException
protected void sendInitialServiceRequest() throws IOException
IOException
public Map<Object,Object> getMetadataMap()
ClientSession
Map
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.