com.sshtools.virtualsession.ssh
Class AbstractSshProtocolTransport

java.lang.Object
  extended bycom.sshtools.virtualsession.ssh.AbstractSshProtocolTransport
All Implemented Interfaces:
ProfileTransport, VirtualSessionTransport

public abstract class AbstractSshProtocolTransport
extends java.lang.Object
implements VirtualSessionTransport

An implementation of a VirtualSessionTransport that uses J2SSH Maverick to make a connection to a remote host.

Version:
$Revision: 1.1 $
Author:
$Author: richard $

Field Summary
static int AUTH_CANCELLED
           
static int AUTH_FAILED
           
static int AUTH_OK
           
protected  int authAttempt
           
protected  boolean connectionPending
           
protected  ForwardingClient forwardingClient
           
protected  HostKeyVerification hostKeyVerification
           
protected  java.lang.String ident
           
protected  SSHSchemeOptions opts
           
protected  ResourceProfile profile
           
protected  SshSession session
           
protected  SshClient ssh
           
protected  int version
           
protected  VirtualSession virtualSession
           
 
Constructor Summary
AbstractSshProtocolTransport()
           
AbstractSshProtocolTransport(HostKeyVerification hostKeyVerification)
           
 
Method Summary
abstract  int authenticate(ResourceProfile profile, java.awt.Component parent)
           
protected  boolean authImpl()
           
 void configureForwardingClient(ForwardingClient fc)
           
 boolean connect(ResourceProfile profile)
          Connect to a host (or resource) using the URI provided in the ResourceProfile}.
abstract  BannerDisplay createBannerDisplay(java.awt.Component parent)
          Create a banner display
 SshClient createClient(ResourceProfile profile, java.awt.Component parent)
          Create the client
 ForwardingClient createForwardingClient()
          Create the forwarding client
 SshSession createSession(ResourceProfile profile, SshClient client)
          Create the session
 void disconnect()
          Disconnect from the currently connected resource.
 SshClient getClient()
          Return the client, or null if not connected.
 ForwardingClient getForwardingClient()
           
 java.lang.String getHostDescription()
          If the host has provided some information about itself, this method will return it.
 HostKeyVerification getHostKeyVerification()
           
 java.awt.Component getParent()
           
 ResourceProfile getProfile()
          Get the profile that was used to connect this transport.
 java.lang.String getProtocolDescription()
          Return a short description of the protocol, for example "Telnet" or "SSH2"
 java.lang.Object getProvider()
          Return the underlying provider of the terminal.
 SshSession getSession()
          Return the session, or null if there is no session connected
 java.lang.String getTransportDescription()
          Return a short description of the transport, for example "Socket" or "SOCKS5"
 VirtualSession getVirtualSession()
          Get the virtual session for this connection
 void init(VirtualSession virtualSession)
          Initialise the transport.
 boolean isConnected()
          Get if the transport is currently connected to a host
 boolean isConnectionPending()
          Return true if a connection is due to be made
abstract  void postAuthenticate()
          Invoked after the client has been authenticated
abstract  void postCreateClient()
          Invoked after the client has been created
abstract  void postCreateSession()
          Invoked after the session has been created
 void setHostKeyVerification(HostKeyVerification hostKeyVerification)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sshtools.profile.ProfileTransport
cloneVirtualSession, isCloneVirtualSessionSupported
 

Field Detail

AUTH_OK

public static final int AUTH_OK
See Also:
Constant Field Values

AUTH_FAILED

public static final int AUTH_FAILED
See Also:
Constant Field Values

AUTH_CANCELLED

public static final int AUTH_CANCELLED
See Also:
Constant Field Values

ssh

protected SshClient ssh

session

protected SshSession session

virtualSession

protected VirtualSession virtualSession

profile

protected ResourceProfile profile

authAttempt

protected int authAttempt

hostKeyVerification

protected HostKeyVerification hostKeyVerification

connectionPending

protected boolean connectionPending

opts

protected SSHSchemeOptions opts

ident

protected java.lang.String ident

version

protected int version

forwardingClient

protected ForwardingClient forwardingClient
Constructor Detail

AbstractSshProtocolTransport

public AbstractSshProtocolTransport()

AbstractSshProtocolTransport

public AbstractSshProtocolTransport(HostKeyVerification hostKeyVerification)
Method Detail

getParent

public java.awt.Component getParent()

createSession

public SshSession createSession(ResourceProfile profile,
                                SshClient client)
                         throws SshException,
                                ChannelOpenException
Create the session

Parameters:
profile - profile
client - client
Returns:
session
Throws:
java.io.IOException - on any error
SshException
ChannelOpenException

authenticate

public abstract int authenticate(ResourceProfile profile,
                                 java.awt.Component parent)
                          throws AuthenticationException,
                                 SshException
Throws:
AuthenticationException
SshException

createForwardingClient

public ForwardingClient createForwardingClient()
                                        throws SshException
Create the forwarding client

Throws:
SshException

configureForwardingClient

public void configureForwardingClient(ForwardingClient fc)
                               throws SshException
Throws:
SshException

createClient

public SshClient createClient(ResourceProfile profile,
                              java.awt.Component parent)
                       throws SshException
Create the client

Parameters:
profile - profile
parent - parent component
Returns:
client
Throws:
java.io.IOException - on any error
SshException

createBannerDisplay

public abstract BannerDisplay createBannerDisplay(java.awt.Component parent)
Create a banner display

Parameters:
parent - parent component
Returns:
banner display

getClient

public SshClient getClient()
Return the client, or null if not connected.

Returns:
client

getSession

public SshSession getSession()
Return the session, or null if there is no session connected

Returns:
session

disconnect

public void disconnect()
                throws java.io.IOException
Description copied from interface: ProfileTransport
Disconnect from the currently connected resource. If a connection is not currently being maintained, an IOException will be thrown.

Specified by:
disconnect in interface ProfileTransport
Throws:
java.io.IOException - on any disconnection error

getVirtualSession

public VirtualSession getVirtualSession()
Description copied from interface: VirtualSessionTransport
Get the virtual session for this connection

Specified by:
getVirtualSession in interface VirtualSessionTransport
Returns:
virtual session

getProvider

public java.lang.Object getProvider()
Description copied from interface: ProfileTransport
Return the underlying provider of the terminal. This should be used to return the underlying object that creates and maintains the terminal transport, its purpose is to allow additional features such as SFTP to be implemented in the terminal.

Specified by:
getProvider in interface ProfileTransport
Returns:

connect

public boolean connect(ResourceProfile profile)
                throws ProfileException,
                       AuthenticationException
Description copied from interface: ProfileTransport
Connect to a host (or resource) using the URI provided in the ResourceProfile}. The URI will supply such details as host, user etc. Any protocol specific authentication will also be performed.

Specified by:
connect in interface ProfileTransport
Parameters:
profile - profile
Returns:
true if connected OK
Throws:
ProfileException - on any connection error
AuthenticationException - if authentication fails

authImpl

protected boolean authImpl()
                    throws AuthenticationException,
                           SshException,
                           ProfileException
Throws:
AuthenticationException
SshException
ProfileException

postCreateClient

public abstract void postCreateClient()
                               throws SshException
Invoked after the client has been created

Throws:
java.io.IOException - on any error
SshException

postAuthenticate

public abstract void postAuthenticate()
                               throws SshException
Invoked after the client has been authenticated

Throws:
java.io.IOException - on any error
SshException

postCreateSession

public abstract void postCreateSession()
                                throws SshException
Invoked after the session has been created

Throws:
java.io.IOException - session
SshException

getProfile

public ResourceProfile getProfile()
Description copied from interface: ProfileTransport
Get the profile that was used to connect this transport. This will be null if disconnected.

Specified by:
getProfile in interface ProfileTransport
Returns:
profile

isConnected

public boolean isConnected()
Description copied from interface: VirtualSessionTransport
Get if the transport is currently connected to a host

Specified by:
isConnected in interface VirtualSessionTransport
Returns:
connected

init

public void init(VirtualSession virtualSession)
Description copied from interface: VirtualSessionTransport
Initialise the transport. Should be called just after instantiation.

Specified by:
init in interface VirtualSessionTransport
Parameters:
virtualSession - virtual session

getHostDescription

public java.lang.String getHostDescription()
Description copied from interface: ProfileTransport
If the host has provided some information about itself, this method will return it. Otherwise null will be returned.

Specified by:
getHostDescription in interface ProfileTransport
Returns:
host description

getProtocolDescription

public java.lang.String getProtocolDescription()
Description copied from interface: ProfileTransport
Return a short description of the protocol, for example "Telnet" or "SSH2"

Specified by:
getProtocolDescription in interface ProfileTransport
Returns:

getTransportDescription

public java.lang.String getTransportDescription()
Description copied from interface: ProfileTransport
Return a short description of the transport, for example "Socket" or "SOCKS5"

Specified by:
getTransportDescription in interface ProfileTransport
Returns:

isConnectionPending

public boolean isConnectionPending()
Description copied from interface: VirtualSessionTransport
Return true if a connection is due to be made

Specified by:
isConnectionPending in interface VirtualSessionTransport
Returns:
connection pending

getForwardingClient

public ForwardingClient getForwardingClient()

getHostKeyVerification

public HostKeyVerification getHostKeyVerification()
Returns:
Returns the hostKeyVerification.

setHostKeyVerification

public void setHostKeyVerification(HostKeyVerification hostKeyVerification)
Parameters:
hostKeyVerification - The hostKeyVerification to set.


Copyright © 2003-2004 3SP LTD. All Rights Reserved.