public class ClientSessionImpl extends AbstractSession implements ClientSession
Session.AttributeKey<T>, Session.State
attributes, authed, channels, clientProposal, clientVersion, closeFuture, closing, decodeLock, decoderBuffer, decoderLength, decoderState, encodeLock, factoryManager, I_C, I_S, inCipher, inCipherSize, inCompression, inMac, inMacResult, ioSession, kex, listeners, lock, log, negociated, nextChannelId, outCipher, outCipherSize, outCompression, outMac, random, requestLock, requestResult, seqi, seqo, serverProposal, serverVersion, SESSION, sessionId, tcpipForwarder, uncompressBuffer, username
AUTHED, CLOSED, TIMEOUT, WAIT_AUTH
Constructor and Description |
---|
ClientSessionImpl(ClientFactoryManager client,
IoSession session) |
Modifier and Type | Method and Description |
---|---|
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.
|
CloseFuture |
close(boolean immediately)
Close this session.
|
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.
|
protected void |
doHandleMessage(Buffer buffer) |
ClientFactoryManager |
getClientFactoryManager()
Return ClientFactoryManager for this session.
|
KeyExchange |
getKex() |
Map<Object,Object> |
getMetadataMap()
Access to the metadata.
|
protected void |
handleMessage(Buffer buffer)
Abstract method for processing incoming decoded packets.
|
protected boolean |
readIdentification(Buffer buffer)
Read the other side identification.
|
protected void |
sendHeartBeat() |
void |
setState(Session.State newState) |
protected void |
startHeartBeat() |
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 |
stopLocalPortForwarding(SshdSocketAddress local)
Stop forwarding the given local address.
|
void |
stopRemotePortForwarding(SshdSocketAddress remote)
Stop forwarding of the given remote address.
|
int |
waitFor(int mask,
long timeout)
Wait for a specific state.
|
addListener, attachSession, channelClose, channelData, channelEof, channelExtendedData, channelFailure, channelOpenConfirmation, channelOpenFailure, channelRequest, channelWindowAdjust, createBuffer, createProposal, decode, disconnect, doReadIdentification, exceptionCaught, getAttribute, getChannel, getFactoryManager, getIntProperty, getIoSession, getNextChannelId, getSession, getSession, getState, getTcpipForwarder, getUsername, messageReceived, negociate, notImplemented, receiveKexInit, receiveNewKeys, registerChannel, removeListener, request, requestFailure, requestSuccess, sendIdentification, sendKexInit, sendNewKeys, setAttribute, unregisterChannel, writePacket
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, createBuffer, exceptionCaught, getAttribute, getFactoryManager, getIntProperty, getState, getTcpipForwarder, getUsername, registerChannel, removeListener, request, setAttribute, unregisterChannel, writePacket
public ClientSessionImpl(ClientFactoryManager client, IoSession session) throws Exception
Exception
public ClientFactoryManager getClientFactoryManager()
ClientSession
getClientFactoryManager
in interface ClientSession
public KeyExchange getKex()
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
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
public CloseFuture close(boolean immediately)
AbstractSession
close
in interface ClientSession
close
in class AbstractSession
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
public void setState(Session.State newState)
setState
in class AbstractSession
protected void startHeartBeat()
protected void sendHeartBeat()
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 versionpublic Map<Object,Object> getMetadataMap()
ClientSession
getMetadataMap
in interface ClientSession
Copyright © 2008–2013 The Apache Software Foundation. All rights reserved.