public class ClientSessionImpl extends AbstractSession implements ClientSession
AbstractSession.PendingWriteFuture
Session.AttributeKey<T>
Modifier and Type | Field and Description |
---|---|
protected AuthFuture |
authFuture |
attributes, authed, clientProposal, clientVersion, currentService, decodeLock, decoderBuffer, decoderLength, decoderState, encodeLock, factoryManager, I_C, I_S, inBytes, inCipher, inCipherSize, inCompression, inMac, inMacResult, inPackets, ioSession, isServer, kex, KEX_STATE_DONE, KEX_STATE_INIT, KEX_STATE_KEYS, KEX_STATE_RUN, kexState, lastKeyTime, listeners, negotiated, outBytes, outCipher, outCipherSize, outCompression, outMac, outPackets, pendingPackets, random, reexchangeFuture, requestLock, requestResult, seqi, seqo, serverProposal, serverVersion, SESSION, sessionId, uncompressBuffer, username
CLOSED, closeFuture, GRACEFUL, IMMEDIATE, lock, log, OPENED, state
AUTHED, CLOSED, TIMEOUT, WAIT_AUTH
Constructor and Description |
---|
ClientSessionImpl(ClientFactoryManager client,
IoSession session) |
Modifier and Type | Method and Description |
---|---|
void |
addPasswordIdentity(String password) |
void |
addPublicKeyIdentity(KeyPair key) |
AuthFuture |
auth() |
AuthFuture |
authAgent(String user)
Authenticate the session with the given username using an ssh agent.
|
AuthFuture |
authInteractive(String user,
String password)
Authenticate the session with the given username and password.
|
AuthFuture |
authPassword(String user,
String password)
Authenticate the session with the given username and password.
|
AuthFuture |
authPublicKey(String user,
KeyPair key)
Authenticate the session with the given username and public key.
|
protected void |
checkKeys() |
ClientChannel |
createChannel(String type)
Create a channel of the given type.
|
ClientChannel |
createChannel(String type,
String subType)
Create a channel of the given type and subtype.
|
ChannelDirectTcpip |
createDirectTcpipChannel(SshdSocketAddress local,
SshdSocketAddress remote)
Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.
|
ChannelExec |
createExecChannel(String command)
Create a channel to execute a command.
|
ScpClient |
createScpClient()
Create an SCP client from this session.
|
SftpClient |
createSftpClient()
Create an SFTP client from this session.
|
ChannelShell |
createShellChannel()
Create a channel to start a shell.
|
ChannelSubsystem |
createSubsystemChannel(String subsystem)
Create a subsystem channel.
|
ClientFactoryManager |
getFactoryManager()
Retrieve the factory manager
|
Map<Object,Object> |
getMetadataMap()
Access to the metadata.
|
protected Service[] |
getServices() |
protected void |
handleMessage(Buffer buffer)
Abstract method for processing incoming decoded packets.
|
protected boolean |
readIdentification(Buffer buffer)
Read the other side identification.
|
protected void |
receiveKexInit(Buffer buffer) |
void |
resetIdleTimeout() |
protected void |
sendEvent(SessionListener.Event event) |
protected void |
sendInitialServiceRequest() |
protected void |
sendKexInit() |
SshdSocketAddress |
startLocalPortForwarding(SshdSocketAddress local,
SshdSocketAddress remote)
Start forwarding the given local address on the client to the given address on the server.
|
SshdSocketAddress |
startRemotePortForwarding(SshdSocketAddress remote,
SshdSocketAddress local)
Start forwarding tcpip from the given address on the server to the
given address on the client.
|
void |
startService(String name) |
void |
stopLocalPortForwarding(SshdSocketAddress local)
Stop forwarding the given local address.
|
void |
stopRemotePortForwarding(SshdSocketAddress remote)
Stop forwarding of the given remote address.
|
protected void |
switchToNextService() |
int |
waitFor(int mask,
long timeout)
Wait for a specific state.
|
addListener, attachSession, checkRekey, createBuffer, createBuffer, createProposal, decode, disconnect, doHandleMessage, doReadIdentification, doWritePacket, exceptionCaught, getAttribute, getClientVersion, getInnerCloseable, getIntProperty, getIoSession, getKex, getLock, getLongProperty, getServerVersion, getSession, getSession, getSessionId, getUsername, isAuthenticated, messageReceived, negotiate, notImplemented, postClose, receiveKexInit, receiveNewKeys, reExchangeKeys, removeListener, request, requestFailure, requestSuccess, sendIdentification, sendKexInit, sendNewKeys, serviceAccept, setAttribute, setAuthenticated, setUsername, toString, writePacket
doCloseGracefully, doCloseImmediately
close
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close
addListener, createBuffer, createBuffer, exceptionCaught, getAttribute, getClientVersion, getIntProperty, getServerVersion, getUsername, reExchangeKeys, removeListener, request, setAttribute, writePacket
protected AuthFuture authFuture
public ClientSessionImpl(ClientFactoryManager client, IoSession session) throws Exception
Exception
protected Service[] getServices()
getServices
in class AbstractSession
public ClientFactoryManager getFactoryManager()
AbstractSession
getFactoryManager
in interface ClientSession
getFactoryManager
in interface Session
getFactoryManager
in class AbstractSession
public void addPasswordIdentity(String password)
addPasswordIdentity
in interface ClientSession
public void addPublicKeyIdentity(KeyPair key)
addPublicKeyIdentity
in interface ClientSession
public AuthFuture auth() throws IOException
auth
in interface ClientSession
IOException
public AuthFuture authAgent(String user) throws IOException
ClientSession
authAgent
in interface ClientSession
IOException
public AuthFuture authPassword(String user, String password) throws IOException
ClientSession
authPassword
in interface ClientSession
IOException
public AuthFuture authInteractive(String user, String password) throws IOException
ClientSession
authInteractive
in interface ClientSession
IOException
public AuthFuture authPublicKey(String user, KeyPair key) throws IOException
ClientSession
authPublicKey
in interface ClientSession
IOException
protected void switchToNextService() throws IOException
IOException
public ClientChannel createChannel(String type) throws IOException
ClientSession
createChannel(type, null)
.createChannel
in interface ClientSession
IOException
public ClientChannel createChannel(String type, String subType) throws IOException
ClientSession
createChannel
in interface ClientSession
IOException
public ChannelShell createShellChannel() throws IOException
ClientSession
createShellChannel
in interface ClientSession
IOException
public ChannelExec createExecChannel(String command) throws IOException
ClientSession
createExecChannel
in interface ClientSession
IOException
public ChannelSubsystem createSubsystemChannel(String subsystem) throws IOException
ClientSession
createSubsystemChannel
in interface ClientSession
IOException
public ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
ClientSession
createDirectTcpipChannel
in interface ClientSession
IOException
public ScpClient createScpClient()
ClientSession
createScpClient
in interface ClientSession
public SftpClient createSftpClient() throws IOException
ClientSession
createSftpClient
in interface ClientSession
IOException
public SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
ClientSession
startLocalPortForwarding
in interface ClientSession
IOException
public void stopLocalPortForwarding(SshdSocketAddress local) throws IOException
ClientSession
stopLocalPortForwarding
in interface ClientSession
IOException
public SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException
ClientSession
startRemotePortForwarding
in interface ClientSession
IOException
public void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException
ClientSession
stopRemotePortForwarding
in interface ClientSession
IOException
protected void handleMessage(Buffer buffer) throws Exception
AbstractSession
handleMessage
in class AbstractSession
buffer
- the buffer containing the packetException
- if an exeption occurs while handling this packet.public int waitFor(int mask, long timeout)
ClientSession
waitFor
in interface ClientSession
protected boolean readIdentification(Buffer buffer) throws IOException
AbstractSession
AbstractSession.doReadIdentification(org.apache.sshd.common.util.Buffer)
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 sendKexInit() throws IOException
sendKexInit
in class AbstractSession
IOException
protected void receiveKexInit(Buffer buffer) throws IOException
receiveKexInit
in class AbstractSession
IOException
protected void checkKeys() throws SshException
checkKeys
in class AbstractSession
SshException
protected void sendEvent(SessionListener.Event event) throws IOException
sendEvent
in class AbstractSession
IOException
protected void sendInitialServiceRequest() throws IOException
IOException
public void startService(String name) throws Exception
startService
in class AbstractSession
Exception
public void resetIdleTimeout()
resetIdleTimeout
in class AbstractSession
public Map<Object,Object> getMetadataMap()
ClientSession
getMetadataMap
in interface ClientSession
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.