com.vhosting.netconf.transport.ssh
Class NetconfSshCather

java.lang.Object
  extended by com.vhosting.netconf.transport.NetconfCatcher
      extended by com.vhosting.netconf.transport.ssh.NetconfSshCather

public class NetconfSshCather
extends NetconfCatcher

This class is the entry point for to establish a connection Netconf over SSH-2.

Version:
1.00, 02/11/2010
Author:
Giuseppe Palmeri

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vhosting.netconf.transport.NetconfCatcher
NetconfCatcher.LogLevel
 
Constructor Summary
NetconfSshCather(java.lang.String labelConnection, SshAuthInfo ai)
          Building the catcher for a connection over SSH-2.
NetconfSshCather(java.lang.String labelConnection, SshAuthInfo ai, java.lang.String subSystem)
          Building the catcher for a connection over SSH-2.
 
Method Summary
protected  boolean doDisconnect()
          This method must necessarily be implemented with the code necessary to perform a disconnect with the server.
protected  byte[] doReadDataFromServer()
          This method must necessarily be implemented when required to read the next message from the server.
protected  void doSendDataToServer(byte[] bytes)
          This method must necessarily be implemented so that any type of message can be sent to the Netconf server.
 java.lang.Runnable getRunnableConnection()
          Create a Runnable connection using a specific name for the remote Netconf sybsystem.
 boolean isConnected()
          Check if the connection is alive or not.
 
Methods inherited from class com.vhosting.netconf.transport.NetconfCatcher
disconnect, enableLog, fireConnectionClosed, getLogLevel, getLogStream, sendHelloMsg, setLogStream, setNetconfCatcherListener, setSyncRequestsTimeout, throwTransportException, whileRpcReplyCatching
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetconfSshCather

public NetconfSshCather(java.lang.String labelConnection,
                        SshAuthInfo ai)
Building the catcher for a connection over SSH-2.

Parameters:
labelConnection - A label used to identify the connection.
ai - The authentication informations.

NetconfSshCather

public NetconfSshCather(java.lang.String labelConnection,
                        SshAuthInfo ai,
                        java.lang.String subSystem)
Building the catcher for a connection over SSH-2.

Parameters:
labelConnection - A label used to identify the connection.
ai - The authentication informations.
subSystem - The name of the SSH-2 Netconf subsystem.
Method Detail

getRunnableConnection

public java.lang.Runnable getRunnableConnection()
Create a Runnable connection using a specific name for the remote Netconf sybsystem.
 1. make the connection with the server;
 2. authenticate;
 3. Send a welcome message;
 4. Listen for any messages from the server.
 

Returns:
A Runnable object that run the connection process.

doDisconnect

protected boolean doDisconnect()
Description copied from class: NetconfCatcher
This method must necessarily be implemented with the code necessary to perform a disconnect with the server. Not have to worry about managing any exceptions, due to the disconnection.

Specified by:
doDisconnect in class NetconfCatcher
Returns:
true se si è provveduto ad effettuare la disconnessione; false se non è stato necessario effettuare la disconnessione.

doSendDataToServer

protected void doSendDataToServer(byte[] bytes)
                           throws java.io.IOException
Description copied from class: NetconfCatcher
This method must necessarily be implemented so that any type of message can be sent to the Netconf server. This method must necessarily throw an exception when the server connection was lost. In particular, for the ssh protocol this method should be implemented by adding the string ']]>]]>' after the message. See the RFC 4742. Similarly, this method be overridden if necessary for other types of transport protocols.

Specified by:
doSendDataToServer in class NetconfCatcher
Parameters:
bytes - The byte array containing the Netconf message.
Throws:
java.io.IOException - Throw this exception when the server connection was lost.

doReadDataFromServer

protected byte[] doReadDataFromServer()
                               throws java.io.IOException
Description copied from class: NetconfCatcher
This method must necessarily be implemented when required to read the next message from the server. This method must necessarily throw an exception when the server connection was lost. In particular, for the ssh protocol this method should be implemented by removing the string ']]>]]>' after the message. See the RFC 4742.

Specified by:
doReadDataFromServer in class NetconfCatcher
Returns:
The message read and made available.
Throws:
java.io.IOException - Throw this exception when the server connection was lost.

isConnected

public boolean isConnected()
Description copied from class: NetconfCatcher
Check if the connection is alive or not.

Specified by:
isConnected in class NetconfCatcher
Returns:
true if the connection is alive; false otherwise.