org.apache.commons.net.ftp

Class FTPSClient


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

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.

Constructor Summary

FTPSClient()
Constructor for FTPSClient.
FTPSClient(String protocol)
Constructor for FTPSClient.
FTPSClient(String protocol, boolean isImplicit)
Constructor for FTPSClient.
FTPSClient(boolean isImplicit)
Constructor for FTPSClient.

Method Summary

protected @Override
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.
boolean
getEnableSessionCreation()
Returns true if new SSL sessions may be established by this socket.
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
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.
@Override
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.
protected @Override
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.

Field Details

KEYSTORE_ALGORITHM

public static String KEYSTORE_ALGORITHM
keystore algorithm name.

PROVIDER

public static String PROVIDER
provider name.

STORE_TYPE

public static String STORE_TYPE
truststore type.

TRUSTSTORE_ALGORITHM

public static String TRUSTSTORE_ALGORITHM
truststore algorithm name.

Constructor Details

FTPSClient

public FTPSClient()
            throws NoSuchAlgorithmException
Constructor for FTPSClient.

FTPSClient

public FTPSClient(String protocol)
            throws NoSuchAlgorithmException
Constructor for FTPSClient.
Parameters:
protocol - the protocol

FTPSClient

public FTPSClient(String protocol,
                  boolean isImplicit)
            throws NoSuchAlgorithmException
Constructor for FTPSClient.
Parameters:
protocol - the protocol
isImplicit - The secutiry mode(Implicit/Explicit).

FTPSClient

public FTPSClient(boolean isImplicit)
            throws NoSuchAlgorithmException
Constructor for FTPSClient.
Parameters:
isImplicit - The secutiry mode(Implicit/Explicit).

Method Details

Socket _openDataConnection_

protected @Override Socket _openDataConnection_(int command,
                                                String arg)
            throws IOException
Returns a socket of the data connection. Wrapped as an SSLSocket, which carries out handshake processing.
Parameters:
arg - The arguments to the FTP command. If this parameter is set to null, then the command is sent with no argument.
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.
See Also:
org.apache.commons.net.ftp.FTPClient._openDataConnection_(java.lang.String, int)

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.

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.

getAuthValue

public String getAuthValue()
Return AUTH command use value.
Returns:
AUTH command use value.

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.

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.

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.

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.

getTrustManager

public TrustManager getTrustManager()
Get the currently configured TrustManager.
Returns:
A TrustManager instance.

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.

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.

int sendCommand

public @Override 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.
Returns:
server reply.
See Also:
org.apache.commons.net.ftp.FTP.sendCommand(java.lang.String)

setAuthValue

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

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.

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.

setEnabledSessionCreation

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

setKeyManager

public void setKeyManager(KeyManager keyManager)
Set a KeyManager to use
Parameters:
keyManager - The KeyManager implementation to set.

setNeedClientAuth

public void setNeedClientAuth(boolean isNeedClientAuth)
Configures the socket to require client authentication.
Parameters:
isNeedClientAuth - The need client auth flag.

setTrustManager

public void setTrustManager(TrustManager trustManager)
Override the default TrustManager to use.
Parameters:
trustManager - The TrustManager implementation to set.

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.

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.

void _connectAction_

protected @Override 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.