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 999437 2010-09-21 14:37:22Z sebb $

Field Summary
static java.lang.String KEYSTORE_ALGORITHM
          Deprecated. - not used - will be removed in next major release
static java.lang.String PROVIDER
          Deprecated. - not used - will be removed in next major release
static java.lang.String STORE_TYPE
          Deprecated. - not used - will be removed in next major release
static java.lang.String TRUSTSTORE_ALGORITHM
          Deprecated. - not used - will be removed in next major release
 
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(boolean isImplicit, javax.net.ssl.SSLContext context)
          Constructor for FTPSClient.
FTPSClient(javax.net.ssl.SSLContext context)
          Constructor for FTPSClient.
FTPSClient(java.lang.String protocol)
          Constructor for FTPSClient.
FTPSClient(java.lang.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  java.net.Socket _openDataConnection_(int command, java.lang.String arg)
          Returns a socket of the data connection.
 void execPBSZ(long pbsz)
          PBSZ command.
 void execPROT(java.lang.String prot)
          PROT command.
C - Clear
S - Safe(SSL protocol only)
E - Confidential(SSL protocol only)
P - Private
 java.lang.String getAuthValue()
          Return AUTH command use value.
 java.lang.String[] getEnabledCipherSuites()
          Returns the names of the cipher suites which could be enabled for use on this connection.
 java.lang.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.
 javax.net.ssl.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(java.lang.String command, java.lang.String args)
          Send an FTP command.
 void setAuthValue(java.lang.String auth)
          Set AUTH command use value.
 void setEnabledCipherSuites(java.lang.String[] cipherSuites)
          Controls which particular cipher suites are enabled for use on this connection.
 void setEnabledProtocols(java.lang.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(javax.net.ssl.KeyManager keyManager)
          Set a KeyManager to use
 void setNeedClientAuth(boolean isNeedClientAuth)
          Configures the socket to require client authentication.
 void setTrustManager(javax.net.ssl.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, features, getBufferSize, getDataConnectionMode, getListArguments, getListHiddenFiles, getModificationTime, getPassiveHost, getPassivePort, getRestartOffset, getStatus, getStatus, getSystemName, getSystemType, initiateListParsing, initiateListParsing, initiateListParsing, isRemoteVerificationEnabled, isUseEPSVwithIPv4, listFiles, listFiles, listFiles, listHelp, listHelp, listNames, listNames, login, login, logout, makeDirectory, printWorkingDirectory, remoteAppend, remoteRetrieve, remoteStore, remoteStoreUnique, remoteStoreUnique, removeDirectory, rename, retrieveFile, retrieveFileStream, sendNoOp, sendSiteCommand, setActiveExternalIPAddress, setActivePortRange, setBufferSize, setDataTimeout, setFileStructure, setFileTransferMode, setFileType, setFileType, setListHiddenFiles, setModificationTime, setParserFactory, setRemoteVerificationEnabled, setRestartOffset, setUseEPSVwithIPv4, 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, eprt, epsv, feat, getControlEncoding, getReply, getReplyCode, getReplyString, getReplyStrings, help, help, isStrictMultilineParsing, list, list, mdtm, mfmt, 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, getKeepAlive, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isConnected, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, 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

@Deprecated
public static java.lang.String KEYSTORE_ALGORITHM
Deprecated. - not used - will be removed in next major release

TRUSTSTORE_ALGORITHM

@Deprecated
public static java.lang.String TRUSTSTORE_ALGORITHM
Deprecated. - not used - will be removed in next major release

PROVIDER

@Deprecated
public static java.lang.String PROVIDER
Deprecated. - not used - will be removed in next major release

STORE_TYPE

@Deprecated
public static java.lang.String STORE_TYPE
Deprecated. - not used - will be removed in next major release
Constructor Detail

FTPSClient

public FTPSClient()
           throws java.security.NoSuchAlgorithmException
Constructor for FTPSClient. Sets security mode to explicit (isImplicit = false)

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

FTPSClient

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

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

FTPSClient

public FTPSClient(java.lang.String protocol)
           throws java.security.NoSuchAlgorithmException
Constructor for FTPSClient.

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

FTPSClient

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

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

FTPSClient

public FTPSClient(boolean isImplicit,
                  javax.net.ssl.SSLContext context)
Constructor for FTPSClient.

Parameters:
isImplicit - The security mode(Implicit/Explicit).
context - A pre-configured SSL Context

FTPSClient

public FTPSClient(javax.net.ssl.SSLContext context)
Constructor for FTPSClient.

Parameters:
context - A pre-configured SSL Context
Method Detail

setAuthValue

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

Parameters:
auth - AUTH command use value.

getAuthValue

public java.lang.String getAuthValue()
Return AUTH command use value.

Returns:
AUTH command use value.

_connectAction_

protected void _connectAction_()
                        throws java.io.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:
java.io.IOException - If it throw by _connectAction_.
See Also:
SocketClient._connectAction_()

setKeyManager

public void setKeyManager(javax.net.ssl.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 the underlying Socket instance is not SSL-enabled (i.e. an instance of SSLSocket with SSLSocketgetEnableSessionCreation()) enabled, this returns 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 the underlying Socket is not an SSLSocket instance, returns 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 the underlying Socket is not an SSLSocket instance, returns 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 the underlying Socket is not an SSLSocket instance, returns false.

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

setEnabledCipherSuites

public void setEnabledCipherSuites(java.lang.String[] cipherSuites)
Controls which particular cipher suites are enabled for use on this connection. Called before server negotiation.

Parameters:
cipherSuites - The cipher suites.

getEnabledCipherSuites

public java.lang.String[] getEnabledCipherSuites()
Returns the names of the cipher suites which could be enabled for use on this connection. When the underlying Socket is not an SSLSocket instance, returns null.

Returns:
An array of cipher suite names, or null

setEnabledProtocols

public void setEnabledProtocols(java.lang.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 java.lang.String[] getEnabledProtocols()
Returns the names of the protocol versions which are currently enabled for use on this connection. When the underlying Socket is not an SSLSocket instance, returns null.

Returns:
An array of protocols, or null

execPBSZ

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

Parameters:
pbsz - Protection Buffer Size.
Throws:
javax.net.ssl.SSLException - If the server reply code does not equal "200".
java.io.IOException - If an I/O error occurs while sending the command.

execPROT

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

Parameters:
prot - Data Channel Protection Level.
Throws:
javax.net.ssl.SSLException - If the server reply code does not equal "200".
java.io.IOException - If an I/O error occurs while sending the command.

sendCommand

public int sendCommand(java.lang.String command,
                       java.lang.String args)
                throws java.io.IOException
Send an FTP command. The CCC (Clear Command Channel) command causes the underlying SSLSocket instance to be assigned to a plain Socket instances

Overrides:
sendCommand in class FTP
Parameters:
command - The FTP command.
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:
java.io.IOException - If an I/O error occurs while sending the command.
See Also:
FTP.sendCommand(java.lang.String)

_openDataConnection_

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

Overrides:
_openDataConnection_ in class FTPClient
Parameters:
command - The textual representation of the FTP command to send.
arg - The arguments to the FTP command. If this parameter is set to null, then the command is sent with no arguments.
Returns:
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:
java.io.IOException - If there is any problem with the connection.
See Also:
FTPClient._openDataConnection_(int, String)

getTrustManager

public javax.net.ssl.TrustManager getTrustManager()
Get the currently configured TrustManager.

Returns:
A TrustManager instance.

setTrustManager

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

Parameters:
trustManager - The TrustManager implementation to set.


Copyright © 2001-2011 Apache Software Foundation. All Rights Reserved.