org.apache.commons.net.ftp
Class FTPSClient

java.lang.Object
  extended by org.apache.commons.net.SocketClient
      extended by org.apache.commons.net.ftp.FTP
          extended by org.apache.commons.net.ftp.FTPClient
              extended by org.apache.commons.net.ftp.FTPSClient
All Implemented Interfaces:
Configurable

public class FTPSClient
extends FTPClient

FTP over SSL processing. If desired, the JVM property -Djavax.net.debug=all can be used to see wire-level SSL details.

Since:
2.0
Version:
$Id: FTPSClient.java 658520 2008-05-21 01:14:11Z sebb $

Field Summary
static String KEYSTORE_ALGORITHM
          keystore algorithm name.
static String PROVIDER
          provider name.
static String STORE_TYPE
          truststore type.
static String TRUSTSTORE_ALGORITHM
          truststore algorithm name.
 
Fields inherited from class org.apache.commons.net.ftp.FTPClient
ACTIVE_LOCAL_DATA_CONNECTION_MODE, ACTIVE_REMOTE_DATA_CONNECTION_MODE, PASSIVE_LOCAL_DATA_CONNECTION_MODE, PASSIVE_REMOTE_DATA_CONNECTION_MODE
 
Fields inherited from class org.apache.commons.net.ftp.FTP
_commandSupport_, _controlEncoding, _controlInput_, _controlOutput_, _newReplyString, _replyCode, _replyLines, _replyString, ASCII_FILE_TYPE, BINARY_FILE_TYPE, BLOCK_TRANSFER_MODE, CARRIAGE_CONTROL_TEXT_FORMAT, COMPRESSED_TRANSFER_MODE, DEFAULT_CONTROL_ENCODING, DEFAULT_DATA_PORT, DEFAULT_PORT, EBCDIC_FILE_TYPE, FILE_STRUCTURE, LOCAL_FILE_TYPE, NON_PRINT_TEXT_FORMAT, PAGE_STRUCTURE, RECORD_STRUCTURE, STREAM_TRANSFER_MODE, strictMultilineParsing, TELNET_TEXT_FORMAT
 
Fields inherited from class org.apache.commons.net.SocketClient
_defaultPort_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL
 
Constructor Summary
FTPSClient()
          Constructor for FTPSClient.
FTPSClient(boolean isImplicit)
          Constructor for FTPSClient.
FTPSClient(String protocol)
          Constructor for FTPSClient.
FTPSClient(String protocol, boolean isImplicit)
          Constructor for FTPSClient.
 
Method Summary
protected  void _connectAction_()
          Because there are so many connect() methods, the _connectAction_() method is provided as a means of performing some action immediately after establishing a connection, rather than reimplementing all of the connect() methods.
protected  Socket _openDataConnection_(int command, String arg)
          Returns a socket of the data connection.
 void execPBSZ(long pbsz)
          PBSZ command.
 void execPROT(String prot)
          PROT command.
C - Clear
S - Safe(SSL protocol only)
E - Confidential(SSL protocol only)
P - Private
 String getAuthValue()
          Return AUTH command use value.
 String[] getEnabledCipherSuites()
          Returns the names of the cipher suites which could be enabled for use on this connection.
 String[] getEnabledProtocols()
          Returns the names of the protocol versions which are currently enabled for use on this connection.
 boolean getEnableSessionCreation()
          Returns true if new SSL sessions may be established by this socket.
 boolean getNeedClientAuth()
          Returns true if the socket will require client authentication.
 TrustManager getTrustManager()
          Get the currently configured TrustManager.
 boolean getUseClientMode()
          Returns true if the socket is set to use client mode in its first handshake.
 boolean getWantClientAuth()
          Returns true if the socket will request client authentication.
 int sendCommand(String command, String args)
          I carry out an ftp command.
 void setAuthValue(String auth)
          Set AUTH command use value.
 void setEnabledCipherSuites(String[] cipherSuites)
          Controls which particular cipher suites are enabled for use on this connection.
 void setEnabledProtocols(String[] protocolVersions)
          Controls which particular protocol versions are enabled for use on this connection.
 void setEnabledSessionCreation(boolean isCreation)
          Controls whether new a SSL session may be established by this socket.
 void setKeyManager(KeyManager keyManager)
          Set a KeyManager to use
 void setNeedClientAuth(boolean isNeedClientAuth)
          Configures the socket to require client authentication.
 void setTrustManager(TrustManager trustManager)
          Override the default TrustManager to use.
 void setUseClientMode(boolean isClientMode)
          Configures the socket to use client (or server) mode in its first handshake.
 void setWantClientAuth(boolean isWantClientAuth)
          Configures the socket to request client authentication, but only if such a request is appropriate to the cipher suite negotiated.
 
Methods inherited from class org.apache.commons.net.ftp.FTPClient
abort, allocate, allocate, appendFile, appendFileStream, changeToParentDirectory, changeWorkingDirectory, completePendingCommand, configure, deleteFile, disconnect, enterLocalActiveMode, enterLocalPassiveMode, enterRemoteActiveMode, enterRemotePassiveMode, getBufferSize, getDataConnectionMode, getListArguments, getListHiddenFiles, getModificationTime, getPassiveHost, getPassivePort, getRestartOffset, getStatus, getStatus, getSystemName, initiateListParsing, initiateListParsing, initiateListParsing, isRemoteVerificationEnabled, listFiles, listFiles, listHelp, listHelp, listNames, listNames, login, login, logout, makeDirectory, printWorkingDirectory, remoteAppend, remoteRetrieve, remoteStore, remoteStoreUnique, remoteStoreUnique, removeDirectory, rename, retrieveFile, retrieveFileStream, sendNoOp, sendSiteCommand, setBufferSize, setDataTimeout, setFileStructure, setFileTransferMode, setFileType, setFileType, setListHiddenFiles, setParserFactory, setRemoteVerificationEnabled, setRestartOffset, storeFile, storeFileStream, storeUniqueFile, storeUniqueFile, storeUniqueFileStream, storeUniqueFileStream, structureMount
 
Methods inherited from class org.apache.commons.net.ftp.FTP
abor, acct, addProtocolCommandListener, allo, allo, appe, cdup, cwd, dele, getControlEncoding, getReply, getReplyCode, getReplyString, getReplyStrings, help, help, isStrictMultilineParsing, list, list, mdtm, mkd, mode, nlst, nlst, noop, pass, pasv, port, pwd, quit, rein, removeProtocolCommandListener, rest, retr, rmd, rnfr, rnto, sendCommand, sendCommand, sendCommand, setControlEncoding, setStrictMultilineParsing, site, smnt, stat, stat, stor, stou, stou, stru, syst, type, type, user
 
Methods inherited from class org.apache.commons.net.SocketClient
connect, connect, connect, connect, connect, connect, getConnectTimeout, getDefaultPort, getDefaultTimeout, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSoLinger, getSoTimeout, getTcpNoDelay, isConnected, setConnectTimeout, setDefaultPort, setDefaultTimeout, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEYSTORE_ALGORITHM

public static String KEYSTORE_ALGORITHM
keystore algorithm name.


TRUSTSTORE_ALGORITHM

public static String TRUSTSTORE_ALGORITHM
truststore algorithm name.


PROVIDER

public static String PROVIDER
provider name.


STORE_TYPE

public static String STORE_TYPE
truststore type.

Constructor Detail

FTPSClient

public FTPSClient()
           throws NoSuchAlgorithmException
Constructor for FTPSClient.

Throws:
NoSuchAlgorithmException - A requested cryptographic algorithm is not available in the environment.

FTPSClient

public FTPSClient(boolean isImplicit)
           throws NoSuchAlgorithmException
Constructor for FTPSClient.

Parameters:
isImplicit - The secutiry mode(Implicit/Explicit).
Throws:
NoSuchAlgorithmException - A requested cryptographic algorithm is not available in the environment.

FTPSClient

public FTPSClient(String protocol)
           throws NoSuchAlgorithmException
Constructor for FTPSClient.

Parameters:
protocol - the protocol
Throws:
NoSuchAlgorithmException - A requested cryptographic algorithm is not available in the environment.

FTPSClient

public FTPSClient(String protocol,
                  boolean isImplicit)
           throws NoSuchAlgorithmException
Constructor for FTPSClient.

Parameters:
protocol - the protocol
isImplicit - The secutiry mode(Implicit/Explicit).
Throws:
NoSuchAlgorithmException - A requested cryptographic algorithm is not available in the environment.
Method Detail

setAuthValue

public void setAuthValue(String auth)
Set AUTH command use value. This processing is done before connected processing.

Parameters:
auth - AUTH command use value.

getAuthValue

public String getAuthValue()
Return AUTH command use value.

Returns:
AUTH command use value.

_connectAction_

protected void _connectAction_()
                        throws IOException
Because there are so many connect() methods, the _connectAction_() method is provided as a means of performing some action immediately after establishing a connection, rather than reimplementing all of the connect() methods.

Overrides:
_connectAction_ in class FTPClient
Throws:
IOException - If it throw by _connectAction_.
See Also:
SocketClient._connectAction_()

setKeyManager

public void setKeyManager(KeyManager keyManager)
Set a KeyManager to use

Parameters:
keyManager - The KeyManager implementation to set.

setEnabledSessionCreation

public void setEnabledSessionCreation(boolean isCreation)
Controls whether new a SSL session may be established by this socket.

Parameters:
isCreation - The established socket flag.

getEnableSessionCreation

public boolean getEnableSessionCreation()
Returns true if new SSL sessions may be established by this socket. When a socket does not have a ssl socket, This return False.

Returns:
true - Indicates that sessions may be created; this is the default. false - indicates that an existing session must be resumed.

setNeedClientAuth

public void setNeedClientAuth(boolean isNeedClientAuth)
Configures the socket to require client authentication.

Parameters:
isNeedClientAuth - The need client auth flag.

getNeedClientAuth

public boolean getNeedClientAuth()
Returns true if the socket will require client authentication. When a socket does not have a ssl socket, This return False.

Returns:
true - If the server mode socket should request that the client authenticate itself.

setWantClientAuth

public void setWantClientAuth(boolean isWantClientAuth)
Configures the socket to request client authentication, but only if such a request is appropriate to the cipher suite negotiated.

Parameters:
isWantClientAuth - The want client auth flag.

getWantClientAuth

public boolean getWantClientAuth()
Returns true if the socket will request client authentication. When a socket does not have a ssl socket, This return False.

Returns:
true - If the server mode socket should request that the client authenticate itself.

setUseClientMode

public void setUseClientMode(boolean isClientMode)
Configures the socket to use client (or server) mode in its first handshake.

Parameters:
isClientMode - The use client mode flag.

getUseClientMode

public boolean getUseClientMode()
Returns true if the socket is set to use client mode in its first handshake. When a socket does not have a ssl socket, This return False.

Returns:
true - If the socket should start its first handshake in "client" mode.

setEnabledCipherSuites

public void setEnabledCipherSuites(String[] cipherSuites)
Controls which particular cipher suites are enabled for use on this connection. I perform setting before a server negotiation.

Parameters:
cipherSuites - The cipher suites.

getEnabledCipherSuites

public String[] getEnabledCipherSuites()
Returns the names of the cipher suites which could be enabled for use on this connection. When a socket does not have a ssl socket, This return null.

Returns:
An array of cipher suite names.

setEnabledProtocols

public void setEnabledProtocols(String[] protocolVersions)
Controls which particular protocol versions are enabled for use on this connection. I perform setting before a server negotiation.

Parameters:
protocolVersions - The protocol versions.

getEnabledProtocols

public String[] getEnabledProtocols()
Returns the names of the protocol versions which are currently enabled for use on this connection. When a socket does not have a ssl socket, This return null.

Returns:
An array of protocols.

execPBSZ

public void execPBSZ(long pbsz)
              throws SSLException,
                     IOException
PBSZ command. pbsz value: 0 to (2^32)-1 decimal integer.

Parameters:
pbsz - Protection Buffer Size.
Throws:
SSLException - If it server reply code not equal "200".
IOException - If an I/O error occurs while either sending the command.

execPROT

public void execPROT(String prot)
              throws SSLException,
                     IOException
PROT command.
C - Clear
S - Safe(SSL protocol only)
E - Confidential(SSL protocol only)
P - Private

Parameters:
prot - Data Channel Protection Level.
Throws:
SSLException - If it server reply code not equal "200".
IOException - If an I/O error occurs while either sending the command.

sendCommand

public int sendCommand(String command,
                       String args)
                throws IOException
I carry out an ftp command. When a CCC command was carried out, I steep socket and SocketFactory in a state of not ssl.

Overrides:
sendCommand in class FTP
Parameters:
command - The text representation of the FTP command to send.
args - The arguments to the FTP command. If this parameter is set to null, then the command is sent with no argument.
Returns:
server reply.
Throws:
IOException - If an I/O error occurs while either sending the command.
See Also:
FTP.sendCommand(java.lang.String)

_openDataConnection_

protected Socket _openDataConnection_(int command,
                                      String arg)
                               throws IOException
Returns a socket of the data connection. Wrapped as an SSLSocket, which carries out handshake processing.

Overrides:
_openDataConnection_ in class FTPClient
Parameters:
arg - The arguments to the FTP command. If this parameter is set to null, then the command is sent with no argument.
command - The text representation of the FTP command to send.
Returns:
A Socket corresponding to the established data connection. Null is returned if an FTP protocol error is reported at any point during the establishment and initialization of the connection.
Throws:
IOException - If there is any problem with the connection.
See Also:
org.apache.commons.net.ftp.FTPClient#_openDataConnection_(java.lang.String, int)

getTrustManager

public TrustManager getTrustManager()
Get the currently configured TrustManager.

Returns:
A TrustManager instance.

setTrustManager

public void setTrustManager(TrustManager trustManager)
Override the default TrustManager to use.

Parameters:
trustManager - The TrustManager implementation to set.


Copyright © 1997-2008 The Apache Software Foundation. All Rights Reserved.