Secure iNet Factory

com.jscape.inet.ssh.connection
Class Connection

java.lang.Object
  extended by com.jscape.inet.ssh.connection.Connection
Direct Known Subclasses:
ConnectionClient

public abstract class Connection
extends java.lang.Object

Version:
1.0
Author:
Alex Usun

Nested Class Summary
static interface Connection.ConnectionClosedListener
          The connection closer public interface.
 
Field Summary
static java.lang.String NAME
          The SSH service name
 
Method Summary
 void addChannel(Channel channel)
          Adds a channel to the channel pool so this channel can receive its messages.
 void addChannelHandler(java.lang.String requestName, ChannelRequestHandler handler)
          Adds the channel request handler to the connection service.
 void addGlobalHandler(java.lang.String requestName, GlobalRequestHandler handler)
          Adds the global request handler to the connection service.
 void close()
           
 boolean containsChannelHandler(java.lang.String requestName)
          Checks if the channel request handler is already added.
 boolean containsGlobalHandler(java.lang.String requestName)
          Checks if the request handler is already added.
 long getNextChannelId()
          Obtains the next available channel #.
 Transport getTransport()
          Gets underlying transport for this connection
 com.jscape.inet.ssh.connection.messages.SshMsgRequestSuccess globalRequest(java.lang.String name, boolean wantReply, byte[] data)
           
 boolean isClosed()
           
 void removeChannel(Channel channel)
          Removes the channel from the pool.
 void removeChannelHandler(java.lang.String requestName)
          Removes the channel handler.
 void removeGlobalHandler(java.lang.String requestName)
          Removes the global handler.
 com.jscape.inet.ssh.connection.messages.SshMsgChannelOpenConfirmation requestChannel(com.jscape.inet.ssh.connection.messages.SshMsgChannelOpen request)
          Requests the connection channel.
 void sendMessage(Message message)
          Sends the specified message to peer.
 void setConnectionClosedListener(Connection.ConnectionClosedListener value)
          Set connection closer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
The SSH service name

See Also:
Constant Field Values
Method Detail

setConnectionClosedListener

public void setConnectionClosedListener(Connection.ConnectionClosedListener value)
Set connection closer.

Parameters:
value - a listener instance

close

public void close()

sendMessage

public void sendMessage(Message message)
                 throws java.io.IOException
Sends the specified message to peer.

Parameters:
message - the message to send
Throws:
java.io.IOException - if an I/O error occurs

getNextChannelId

public long getNextChannelId()
Obtains the next available channel #.

Returns:
the next available channel #

requestChannel

public com.jscape.inet.ssh.connection.messages.SshMsgChannelOpenConfirmation requestChannel(com.jscape.inet.ssh.connection.messages.SshMsgChannelOpen request)
                                                                                     throws java.io.IOException
Requests the connection channel.

Parameters:
request - the SSH_MSG_CHANNEL_OPEN request
Returns:
the SSH_MSG_CHANNEL_OPEN_CONFIRMATION
Throws:
java.io.IOException - if an I/O error occurs
ConnectionException - if the channel cannot be opened

globalRequest

public com.jscape.inet.ssh.connection.messages.SshMsgRequestSuccess globalRequest(java.lang.String name,
                                                                                  boolean wantReply,
                                                                                  byte[] data)
                                                                           throws java.io.IOException
Throws:
java.io.IOException

isClosed

public boolean isClosed()

addChannel

public void addChannel(Channel channel)
Adds a channel to the channel pool so this channel can receive its messages.

Parameters:
channel - the channel to add

removeChannel

public void removeChannel(Channel channel)
Removes the channel from the pool.

Parameters:
channel - the channel to remove

addGlobalHandler

public void addGlobalHandler(java.lang.String requestName,
                             GlobalRequestHandler handler)
Adds the global request handler to the connection service.

Parameters:
requestName - the global request name
handler - the request handler

removeGlobalHandler

public void removeGlobalHandler(java.lang.String requestName)
Removes the global handler.

Parameters:
requestName - the handler's request name

containsGlobalHandler

public boolean containsGlobalHandler(java.lang.String requestName)
Checks if the request handler is already added.

Parameters:
requestName - the global request name
Returns:
true if the appropriate handler is already added; false otherwise

addChannelHandler

public void addChannelHandler(java.lang.String requestName,
                              ChannelRequestHandler handler)
Adds the channel request handler to the connection service.

Parameters:
requestName - the global request name
handler - the request handler

removeChannelHandler

public void removeChannelHandler(java.lang.String requestName)
Removes the channel handler.

Parameters:
requestName - the handler's request name

containsChannelHandler

public boolean containsChannelHandler(java.lang.String requestName)
Checks if the channel request handler is already added.

Parameters:
requestName - the global request name
Returns:
true if the appropriate handler is already added; false otherwise

getTransport

public Transport getTransport()
Gets underlying transport for this connection

Returns:
a Transport instance

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved