org.apache.sshd.client.session
Class ClientSessionImpl

java.lang.Object
  extended by org.apache.sshd.common.session.AbstractSession
      extended by org.apache.sshd.client.session.ClientSessionImpl
All Implemented Interfaces:
ClientSession, Session

public class ClientSessionImpl
extends AbstractSession
implements ClientSession

TODO Add javadoc

Author:
Apache MINA SSHD Project

Nested Class Summary
static class ClientSessionImpl.State
           
 
Nested classes/interfaces inherited from interface org.apache.sshd.common.Session
Session.AttributeKey<T>
 
Field Summary
 
Fields inherited from class org.apache.sshd.common.session.AbstractSession
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, uncompressBuffer, username
 
Fields inherited from interface org.apache.sshd.ClientSession
AUTHED, CLOSED, TIMEOUT, WAIT_AUTH
 
Constructor Summary
ClientSessionImpl(FactoryManager client, org.apache.mina.core.session.IoSession session)
           
 
Method Summary
 AuthFuture authAgent(java.lang.String username)
          Authenticate the session with the given username using an ssh agent.
 AuthFuture authPassword(java.lang.String username, java.lang.String password)
          Authenticate the session with the given username and password.
 AuthFuture authPublicKey(java.lang.String username, java.security.KeyPair key)
          Authenticate the session with the gien username and public key.
 CloseFuture close(boolean immediately)
          Close this session.
 ClientChannel createChannel(java.lang.String type)
          Create a channel of the given type.
 ClientChannel createChannel(java.lang.String type, java.lang.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(java.lang.String command)
          Create a channel to execute a command.
 ChannelShell createShellChannel()
          Create a channel to start a shell.
 ChannelSubsystem createSubsystemChannel(java.lang.String subsystem)
          Create a subsystem channel.
protected  void doHandleMessage(Buffer buffer)
           
 ClientFactoryManager getClientFactoryManager()
           
 KeyExchange getKex()
           
 java.util.Map<java.lang.Object,java.lang.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(ClientSessionImpl.State newState)
           
protected  void startHeartBeat()
           
 void startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote)
          Start forwarding the given local address on the client to the given address on the server.
 void 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.
 
Methods inherited from class org.apache.sshd.common.session.AbstractSession
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, getUsername, messageReceived, negociate, notImplemented, receiveKexInit, receiveNewKeys, registerChannel, removeListener, request, requestFailure, requestSuccess, sendIdentification, sendKexInit, sendNewKeys, setAttribute, unregisterChannel, writePacket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientSessionImpl

public ClientSessionImpl(FactoryManager client,
                         org.apache.mina.core.session.IoSession session)
                  throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getClientFactoryManager

public ClientFactoryManager getClientFactoryManager()

getKex

public KeyExchange getKex()

authAgent

public AuthFuture authAgent(java.lang.String username)
                     throws java.io.IOException
Description copied from interface: ClientSession
Authenticate the session with the given username using an ssh agent.

Specified by:
authAgent in interface ClientSession
Throws:
java.io.IOException

authPassword

public AuthFuture authPassword(java.lang.String username,
                               java.lang.String password)
                        throws java.io.IOException
Description copied from interface: ClientSession
Authenticate the session with the given username and password.

Specified by:
authPassword in interface ClientSession
Throws:
java.io.IOException

authPublicKey

public AuthFuture authPublicKey(java.lang.String username,
                                java.security.KeyPair key)
                         throws java.io.IOException
Description copied from interface: ClientSession
Authenticate the session with the gien username and public key.

Specified by:
authPublicKey in interface ClientSession
Throws:
java.io.IOException

createChannel

public ClientChannel createChannel(java.lang.String type)
                            throws java.lang.Exception
Description copied from interface: ClientSession
Create a channel of the given type. Same as calling createChannel(type, null).

Specified by:
createChannel in interface ClientSession
Throws:
java.lang.Exception

createChannel

public ClientChannel createChannel(java.lang.String type,
                                   java.lang.String subType)
                            throws java.lang.Exception
Description copied from interface: ClientSession
Create a channel of the given type and subtype.

Specified by:
createChannel in interface ClientSession
Throws:
java.lang.Exception

createShellChannel

public ChannelShell createShellChannel()
                                throws java.lang.Exception
Description copied from interface: ClientSession
Create a channel to start a shell.

Specified by:
createShellChannel in interface ClientSession
Throws:
java.lang.Exception

createExecChannel

public ChannelExec createExecChannel(java.lang.String command)
                              throws java.lang.Exception
Description copied from interface: ClientSession
Create a channel to execute a command.

Specified by:
createExecChannel in interface ClientSession
Throws:
java.lang.Exception

createSubsystemChannel

public ChannelSubsystem createSubsystemChannel(java.lang.String subsystem)
                                        throws java.lang.Exception
Description copied from interface: ClientSession
Create a subsystem channel.

Specified by:
createSubsystemChannel in interface ClientSession
Throws:
java.lang.Exception

createDirectTcpipChannel

public ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local,
                                                   SshdSocketAddress remote)
                                            throws java.lang.Exception
Description copied from interface: ClientSession
Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.

Specified by:
createDirectTcpipChannel in interface ClientSession
Throws:
java.lang.Exception

startLocalPortForwarding

public void startLocalPortForwarding(SshdSocketAddress local,
                                     SshdSocketAddress remote)
                              throws java.lang.Exception
Description copied from interface: ClientSession
Start forwarding the given local address on the client to the given address on the server.

Specified by:
startLocalPortForwarding in interface ClientSession
Throws:
java.lang.Exception

stopLocalPortForwarding

public void stopLocalPortForwarding(SshdSocketAddress local)
                             throws java.lang.Exception
Description copied from interface: ClientSession
Stop forwarding the given local address.

Specified by:
stopLocalPortForwarding in interface ClientSession
Throws:
java.lang.Exception

startRemotePortForwarding

public void startRemotePortForwarding(SshdSocketAddress remote,
                                      SshdSocketAddress local)
                               throws java.lang.Exception
Description copied from interface: ClientSession
Start forwarding tcpip from the given address on the server to the given address on the client. The remote host name is the address to bind to on the server:

Specified by:
startRemotePortForwarding in interface ClientSession
Throws:
java.lang.Exception

stopRemotePortForwarding

public void stopRemotePortForwarding(SshdSocketAddress remote)
                              throws java.lang.Exception
Description copied from interface: ClientSession
Stop forwarding of the given remote address.

Specified by:
stopRemotePortForwarding in interface ClientSession
Throws:
java.lang.Exception

close

public CloseFuture close(boolean immediately)
Description copied from class: AbstractSession
Close this session. This method will close all channels, then close the underlying MINA session. The call will not block until the mina session is actually closed.

Specified by:
close in interface ClientSession
Overrides:
close in class AbstractSession

handleMessage

protected void handleMessage(Buffer buffer)
                      throws java.lang.Exception
Description copied from class: AbstractSession
Abstract method for processing incoming decoded packets. The given buffer will hold the decoded packet, starting from the command byte at the read position. Packets must be processed within this call or be copied because the given buffer is meant to be changed and updated when this method returns.

Specified by:
handleMessage in class AbstractSession
Parameters:
buffer - the buffer containing the packet
Throws:
java.lang.Exception - if an exeption occurs while handling this packet.

doHandleMessage

protected void doHandleMessage(Buffer buffer)
                        throws java.lang.Exception
Throws:
java.lang.Exception

waitFor

public int waitFor(int mask,
                   long timeout)
Description copied from interface: ClientSession
Wait for a specific state.

Specified by:
waitFor in interface ClientSession

setState

public void setState(ClientSessionImpl.State newState)

startHeartBeat

protected void startHeartBeat()

sendHeartBeat

protected void sendHeartBeat()

readIdentification

protected boolean readIdentification(Buffer buffer)
                              throws java.io.IOException
Description copied from class: AbstractSession
Read the other side identification. This method is specific to the client or server side, but both should call AbstractSession.doReadIdentification(org.apache.sshd.common.util.Buffer) and store the result in the needed property.

Specified by:
readIdentification in class AbstractSession
Parameters:
buffer - the buffer containing the remote identification
Returns:
true if the identification has been fully read or false if more data is needed
Throws:
java.io.IOException - if an error occurs such as a bad protocol version

getMetadataMap

public java.util.Map<java.lang.Object,java.lang.Object> getMetadataMap()
Description copied from interface: ClientSession
Access to the metadata.

Specified by:
getMetadataMap in interface ClientSession


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.