com.enterprisedt.net.ftp
Class AdvancedSSHSettings

java.lang.Object
  extended by com.enterprisedt.net.ftp.AdvancedSSHSettings

public class AdvancedSSHSettings
extends java.lang.Object

Advanced settings specifically for the SFTP (FTP over SSH) protocol. Generally these settings are not required for basic use of the protocol.

All settings must be set before connecting to the server.

Version:
$Revision: 1.8 $
Author:
Bruce Blackshaw

Method Summary
 void disableAllAlgorithms()
          Disables all algorithms.
 void disableAllAlgorithms(int algorithmType)
          Disables all algorithms of a particular type.
 SSHAuthenticationType getAuthenticationType()
          Get the type of authentication that is set up to be used.
 SSHFTPAlgorithm[] getEnabledAlgorithms()
          Returns an array containing all enabled algorithms (of all types).
 SSHFTPAlgorithm[] getEnabledAlgorithms(int algorithmType)
          Returns an array containing all enabled algorithms of a particular type.
 int getMaxPacketSize()
          Get the max packet size set
 byte[] getPrivateKeyBytes()
          Returns a byte-array containing the client's private key if one has been set.
 java.lang.String getPrivateKeyFile()
          Get the path of the file from which the client's private key was read (if setPrivateKeyFile was previously called).
 java.lang.String getPrivateKeyFilePassphrase()
          Get the passphrase for the private key file.
 java.io.InputStream getPrivateKeyInputStream()
          Returns an InputStream for the client's private key, used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.
 java.lang.String getRemoteEOL()
          Get the remote EOL string that is forced to be used irrespective of what is detected from server information.
 SSHAuthPrompt[] getSSHAuthPrompts()
          Get the array of authentication prompts that are to be used for keyboard-interactive authentication.
 SSHFTPValidator getSSHServerValidator()
          Returns a reference to the host validator, which validates the server's public key.
 boolean isDisableWaitForChannelClose()
          Is waiting for server acknowledge on closure of a channel disabled?
 boolean isPortsInKnownHosts()
          Are non-standard port numbers used in known_hosts files? If so then hosts are stored as [hostname]:port if the port number is not 22.
 boolean isRekeyEnabled()
          Is re-keying after 1 GB enabled? If enabled (the default), after 1 GB of transfer a new set of cryptographic keys are established.
 void setAlgorithmEnabled(SSHFTPAlgorithm algorithm, boolean enable)
          Enable/disable the given algorithm.
 void setAuthenticationType(SSHAuthenticationType sshAuthenticationType)
          Set the authentication type to be used.
 void setDisableWaitForChannelClose(boolean disableWaitForChannelClose)
          Disables waiting for an acknowledgement from the server when the client has requested that a channel be closed.
 void setMaxPacketSize(int maxPacketSize)
          Set the maximum packet size.
 void setPortsInKnownHosts(boolean portsInKnownHosts)
          Change whether or not non-standard port numbers are used in known_hosts files.
 void setPrivateKeyBytes(byte[] privateKeyBytes)
          Reads the client's private key from the given byte-array.
 void setPrivateKeyFile(java.lang.String privateKeyFileName)
          Read the client's private key file, used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.
 void setPrivateKeyFilePassphrase(java.lang.String privateKeyFilePassphrase)
          Set the passphrase for the private key file.
 void setPrivateKeyInputStream(java.io.InputStream privateKeyInputStream)
          Read the client's private key from the given InputStream.
 void setRekeyEnabled(boolean enableRekey)
          Set flag to disable or enable re-keying after 1 GB
 void setRemoteEOL(java.lang.String remoteEOL)
          Set a remoteEOL to be forced, irrespective of what is detected from server information
 void setSSHAuthPrompts(SSHAuthPrompt[] authPrompts)
          Set the array of authentication prompts that are to be used for keyboard-interactive authentication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSSHServerValidator

public SSHFTPValidator getSSHServerValidator()
Returns a reference to the host validator, which validates the server's public key.

Returns:
Returns the host validator.

isDisableWaitForChannelClose

public boolean isDisableWaitForChannelClose()
Is waiting for server acknowledge on closure of a channel disabled?

Returns:
true if disabled, false otherwise

setDisableWaitForChannelClose

public void setDisableWaitForChannelClose(boolean disableWaitForChannelClose)
                                   throws FTPException
Disables waiting for an acknowledgement from the server when the client has requested that a channel be closed.

Parameters:
disableWaitForChannelClose - true to disable the wait
Throws:
FTPException

isRekeyEnabled

public boolean isRekeyEnabled()
Is re-keying after 1 GB enabled? If enabled (the default), after 1 GB of transfer a new set of cryptographic keys are established. This is a security measure, not supported by all servers.

Returns:
true if enabled (the default)

setRekeyEnabled

public void setRekeyEnabled(boolean enableRekey)
Set flag to disable or enable re-keying after 1 GB

Parameters:
enableRekey - true to enable, false to disable

getPrivateKeyFile

public java.lang.String getPrivateKeyFile()
Get the path of the file from which the client's private key was read (if setPrivateKeyFile was previously called). The private key is used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.

Returns:
path to file, or null if not set

setPrivateKeyFile

public void setPrivateKeyFile(java.lang.String privateKeyFileName)
                       throws FTPException
Read the client's private key file, used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.

Parameters:
privateKeyFileName - path to file
Throws:
FTPException - Thrown if an error occurs while reading the private key.

getPrivateKeyInputStream

public java.io.InputStream getPrivateKeyInputStream()
Returns an InputStream for the client's private key, used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.

Returns:
reference to InputStream, or null if not set

setPrivateKeyInputStream

public void setPrivateKeyInputStream(java.io.InputStream privateKeyInputStream)
                              throws FTPException
Read the client's private key from the given InputStream. The private key is used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.

Parameters:
privateKeyInputStream - InputStream from which the private key can be read
Throws:
FTPException - Thrown if an error occurs while reading the private key.

getPrivateKeyBytes

public byte[] getPrivateKeyBytes()
Returns a byte-array containing the client's private key if one has been set. The private key is used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.

Returns:
Byte-array containing the client's private key, or null if not set

setPrivateKeyBytes

public void setPrivateKeyBytes(byte[] privateKeyBytes)
                        throws FTPException
Reads the client's private key from the given byte-array. The private key is used for client authentication if SSHAuthenticationType.PUBLIC_KEY is being used.

Parameters:
privateKeyBytes - Byte-array containing the client's private key
Throws:
FTPException - Thrown if an error occurs while parsing the private key.

getPrivateKeyFilePassphrase

public java.lang.String getPrivateKeyFilePassphrase()
Get the passphrase for the private key file.

Returns:
passphrase

setPrivateKeyFilePassphrase

public void setPrivateKeyFilePassphrase(java.lang.String privateKeyFilePassphrase)
                                 throws FTPException
Set the passphrase for the private key file.

Parameters:
privateKeyFilePassphrase - passphrase to set
Throws:
FTPException

getEnabledAlgorithms

public SSHFTPAlgorithm[] getEnabledAlgorithms()
Returns an array containing all enabled algorithms (of all types).

Returns:
An array of all enabled algorithms.

getEnabledAlgorithms

public SSHFTPAlgorithm[] getEnabledAlgorithms(int algorithmType)
                                       throws SSHFTPException
Returns an array containing all enabled algorithms of a particular type.

Parameters:
algorithmType - Type of algorithms to return (See SSHFTPAlgorithm).
Returns:
An array of all enabled algorithms of the given type.
Throws:
SSHFTPException - Thrown if the given algorithm-type is invalid.

disableAllAlgorithms

public void disableAllAlgorithms(int algorithmType)
                          throws FTPException
Disables all algorithms of a particular type. Note that one algorithm of each type must be enabled before you can connect to a server.

Parameters:
algorithmType - Type of algorithms to return (See SSHFTPAlgorithm).
Throws:
FTPException

disableAllAlgorithms

public void disableAllAlgorithms()
                          throws FTPException
Disables all algorithms. Note that one algorithm of each type must be enabled before you can connect to a server.

Throws:
FTPException

setAlgorithmEnabled

public void setAlgorithmEnabled(SSHFTPAlgorithm algorithm,
                                boolean enable)
                         throws FTPException
Enable/disable the given algorithm.

Parameters:
algorithm - Algorithm to enable/disable.
enable - Flag indicating whether the algorithm should be enabled or disabled.
Throws:
FTPException

getMaxPacketSize

public int getMaxPacketSize()
Get the max packet size set

Returns:
-1 if not set, or else the set size

setMaxPacketSize

public void setMaxPacketSize(int maxPacketSize)
                      throws FTPException
Set the maximum packet size. This should be used if errors are being received such as "packet too long: xxxx". Set the size smaller than the size listed in the error message.

Parameters:
maxPacketSize - size to set
Throws:
FTPException

getAuthenticationType

public SSHAuthenticationType getAuthenticationType()
Get the type of authentication that is set up to be used.

Returns:
SSHAuthenticationType

setAuthenticationType

public void setAuthenticationType(SSHAuthenticationType sshAuthenticationType)
                           throws FTPException
Set the authentication type to be used. Different fields need to be set depending on the type use, e.g. SSHAuthenticationType.PUBLIC_KEY requires the client's private key and passphrase to be set.

Parameters:
sshAuthenticationType - authentication type to be used
Throws:
FTPException

getSSHAuthPrompts

public SSHAuthPrompt[] getSSHAuthPrompts()
Get the array of authentication prompts that are to be used for keyboard-interactive authentication.

Returns:
array of prompts

setSSHAuthPrompts

public void setSSHAuthPrompts(SSHAuthPrompt[] authPrompts)
                       throws FTPException
Set the array of authentication prompts that are to be used for keyboard-interactive authentication.

Parameters:
authPrompts - prompts to set up
Throws:
FTPException

isPortsInKnownHosts

public boolean isPortsInKnownHosts()
Are non-standard port numbers used in known_hosts files? If so then hosts are stored as [hostname]:port if the port number is not 22.

Default is true.

Returns:
true if non-standard ports used in known_hosts

setPortsInKnownHosts

public void setPortsInKnownHosts(boolean portsInKnownHosts)
                          throws FTPException
Change whether or not non-standard port numbers are used in known_hosts files. If so then hosts are stored as [hostname]:port if the port number is not 22.

Parameters:
portsInKnownHosts - true to enable, false to disable
Throws:
FTPException

setRemoteEOL

public void setRemoteEOL(java.lang.String remoteEOL)
                  throws FTPException
Set a remoteEOL to be forced, irrespective of what is detected from server information

Parameters:
remoteEOL - remoteEOL to force
Throws:
FTPException

getRemoteEOL

public java.lang.String getRemoteEOL()
Get the remote EOL string that is forced to be used irrespective of what is detected from server information.

Returns:
String, or null if autodetect is to be used


Copyright © 2001-2009 Enterprise Distributed Technologies Ltd. All Rights Reserved.