net.sf.commons.ssh
Class ConnectionFactory

java.lang.Object
  extended by net.sf.commons.ssh.ConnectionFactory
Direct Known Subclasses:
GanymedConnectionFactory, J2sshConnectionFactory, JschConnectionFactory, SshdConnectionFactory

public abstract class ConnectionFactory
extends java.lang.Object

Abstract SSH connection factory.

Since:
1.0
Author:
Sergey Vidyuk (svidyuk at gmail dot com)

Field Summary
protected  org.apache.commons.logging.Log log
          Factory logger
 
Constructor Summary
ConnectionFactory()
           
 
Method Summary
 int getKexTimeout()
          Returns the timeout value for the key exchange
 int getPort()
           
 int getSoTimeout()
           
 java.util.Set getSupportedFeatures()
          Returns Set of String — the set of supported features codes.
protected abstract  java.util.Set getSupportedFeaturesImpl()
          Creates Set of String — the set of supported features codes.
 boolean isFeatureSupported(java.lang.String feature)
          Returns true if specified feature is supported by ConnectionFactory, false otherwise.
 boolean isSendIgnore()
           
static ConnectionFactory newInstance(java.util.Set requiredFeatures)
          Creates new instance of ConnectionFactory using system properties to resolve actual connection factory instance.
 Connection openConnection(java.lang.String host, AuthenticationOptions authOptions)
          Creates new SSH connection using the specified connection settings
abstract  Connection openConnection(java.lang.String host, int port, AuthenticationOptions authOptions)
          Creates new SSH connection using the specified connection settings
 void setKexTimeout(int kexTimeout)
           
 void setPort(int port)
           
 void setSendIgnore(boolean sendIgnore)
           
 void setSoTimeout(int soTimeout)
          Enable/disable SocketOptions.SO_TIMEOUT with the specified timeout, in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Factory logger

Constructor Detail

ConnectionFactory

public ConnectionFactory()
Method Detail

newInstance

public static ConnectionFactory newInstance(java.util.Set requiredFeatures)
Creates new instance of ConnectionFactory using system properties to resolve actual connection factory instance.

Parameters:
requiredFeatures - set of required features factory must support
Returns:
new instance of ConnectionFactory
Since:
1.0

getKexTimeout

public int getKexTimeout()
Returns the timeout value for the key exchange

Returns:
the timeout value for the key exchange
Since:
1.0

getPort

public int getPort()
Returns:
the port to connect to on the remote host
Since:
1.0

getSoTimeout

public int getSoTimeout()
Returns:
the soTimeout
Since:
1.0

getSupportedFeatures

public final java.util.Set getSupportedFeatures()
Returns Set of String — the set of supported features codes.

Returns:
Set of String — the set of supported features codes.
See Also:
isFeatureSupported(String), Features

getSupportedFeaturesImpl

protected abstract java.util.Set getSupportedFeaturesImpl()
Creates Set of String — the set of supported features codes.

Returns:
Set of String — the set of supported features codes.
See Also:
isFeatureSupported(String), Features

isFeatureSupported

public boolean isFeatureSupported(java.lang.String feature)
Returns true if specified feature is supported by ConnectionFactory, false otherwise.

Parameters:
feature - feature code to check.
Returns:
true if specified feature is supported by ConnectionFactory, false otherwise.
See Also:
getSupportedFeatures(), Features

isSendIgnore

public boolean isSendIgnore()
Returns:
the send ignore flag to send random data packets

openConnection

public Connection openConnection(java.lang.String host,
                                 AuthenticationOptions authOptions)
                          throws java.io.IOException
Creates new SSH connection using the specified connection settings

Parameters:
host - host to connect
authOptions - Authentication Options (should be supported by connection factory)
Returns:
new SSH connection
Throws:
java.io.IOException - if I/O exception occurs
Since:
1.0

openConnection

public abstract Connection openConnection(java.lang.String host,
                                          int port,
                                          AuthenticationOptions authOptions)
                                   throws java.io.IOException
Creates new SSH connection using the specified connection settings

Parameters:
host - host to connect
port - port to connect
authOptions - Authentication Options (should be supported by connection factory)
Returns:
new SSH connection
Throws:
java.io.IOException - if I/O exception occurs
Since:
1.0

setKexTimeout

public void setKexTimeout(int kexTimeout)
Parameters:
kexTimeout - the kexTimeout to set
Since:
1.0

setPort

public void setPort(int port)
Parameters:
port - the port to connect to on the remote host
Since:
1.0

setSendIgnore

public void setSendIgnore(boolean sendIgnore)
Parameters:
sendIgnore - the send ignore flag to send random data packets
Since:
1.0

setSoTimeout

public void setSoTimeout(int soTimeout)
Enable/disable SocketOptions.SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a InputStream.read() will block for only this amount of time. If the timeout expires, a SocketTimeoutException is raised, though the Socket is still valid. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.

Parameters:
soTimeout - the soTimeout to set
Since:
1.0


Copyright © 2009. All Rights Reserved.