public class FTPSClient extends FTPClient
setHostnameVerifier(HostnameVerifier) or
setEndpointCheckingEnabled(boolean) (on Java 1.7+) to enable verification. Verification is only performed on client mode connections.FTPClient.HostnameResolver, FTPClient.NatServerResolverImpl| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_FTPS_DATA_PORT
Default FTPS data port.
|
static int |
DEFAULT_FTPS_PORT
Default FTPS port.
|
ACTIVE_LOCAL_DATA_CONNECTION_MODE, ACTIVE_REMOTE_DATA_CONNECTION_MODE, FTP_IP_ADDRESS_FROM_PASV_RESPONSE, FTP_SYSTEM_TYPE, FTP_SYSTEM_TYPE_DEFAULT, PASSIVE_LOCAL_DATA_CONNECTION_MODE, PASSIVE_REMOTE_DATA_CONNECTION_MODE, SYSTEM_TYPE_PROPERTIES_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, DEFLATE_TRANSFER_MODE, EBCDIC_FILE_TYPE, FILE_STRUCTURE, LOCAL_FILE_TYPE, NON_PRINT_TEXT_FORMAT, PAGE_STRUCTURE, RECORD_STRUCTURE, REPLY_CODE_LEN, STREAM_TRANSFER_MODE, strictMultilineParsing, TELNET_TEXT_FORMAT_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL, remoteInetSocketAddress| Constructor and Description |
|---|
FTPSClient()
Constructor for FTPSClient, calls
FTPSClient(String, boolean). |
FTPSClient(boolean isImplicit)
Constructor for FTPSClient, using
DEFAULT_PROTOCOL - i.e. |
FTPSClient(boolean isImplicit,
SSLContext context)
Constructor for FTPSClient, using
DEFAULT_PROTOCOL - i.e. |
FTPSClient(SSLContext context)
Constructor for FTPSClient, using
DEFAULT_PROTOCOL - i.e. |
FTPSClient(String protocol)
Constructor for FTPSClient, using explicit mode, calls
FTPSClient(String, boolean). |
FTPSClient(String protocol,
boolean isImplicit)
Constructor for FTPSClient allowing specification of protocol and security mode.
|
| Modifier and Type | Method and Description |
|---|---|
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 the connect() methods.
|
protected Socket |
_openDataConnection_(String command,
String arg)
Returns a socket of the data connection.
|
protected void |
_prepareDataSocket_(Socket socket)
Performs any custom initialization for a newly created SSLSocket (before the SSL handshake happens).
|
void |
disconnect()
Closes the connection to the FTP server and restores connection parameters to the default values.
|
int |
execADAT(byte[] data)
Sends the ADAT command with the specified authentication data.
|
protected void |
execAUTH()
Sends the AUTH command.
|
int |
execAUTH(String mechanism)
Sends the AUTH command with the specified mechanism.
|
int |
execCCC()
Sends the CCC command to the server.
|
int |
execCONF(byte[] data)
Sends the CONF command with the specified data.
|
int |
execENC(byte[] data)
Sends the ENC command with the specified data.
|
int |
execMIC(byte[] data)
Sends the MIC command with the specified data.
|
void |
execPBSZ(long pbsz)
PBSZ command.
|
void |
execPROT(String prot)
PROT command.
|
String |
getAuthValue()
Gets AUTH command use value.
|
String[] |
getEnabledCipherSuites()
Gets the names of the cipher suites which could be enabled for use on this connection.
|
String[] |
getEnabledProtocols()
Gets the names of the protocol versions which are currently enabled for use on this connection.
|
boolean |
getEnableSessionCreation()
Gets true if new SSL sessions may be established by this socket.
|
HostnameVerifier |
getHostnameVerifier()
Gets the currently configured
HostnameVerifier. |
boolean |
getNeedClientAuth()
Gets true if the socket will require client authentication.
|
protected String |
getProtocol()
Gets the secure socket protocol to be used, e.g.
|
protected String[] |
getProtocols()
Gets the protocol versions.
|
protected String[] |
getSuites()
Gets the cipher suites.
|
TrustManager |
getTrustManager()
Gets the currently configured
TrustManager. |
boolean |
getUseClientMode()
Gets whether the socket is set to use client mode in its first handshake.
|
boolean |
getWantClientAuth()
Gets whether the socket will request client authentication.
|
protected boolean |
isClientMode()
Tests the use client mode flag.
|
protected boolean |
isCreation()
Tests whether a new SSL session may be established by this socket.
|
boolean |
isEndpointCheckingEnabled()
Tests whether or not endpoint identification using the HTTPS algorithm on Java 1.7+ is enabled.
|
protected boolean |
isImplicit()
Tests the security mode.
|
protected boolean |
isNeedClientAuth()
Tests the need client auth flag.
|
protected boolean |
isWantClientAuth()
Tests the want client auth flag.
|
byte[] |
parseADATReply(String reply)
Parses the given ADAT response line and base64-decodes the data.
|
long |
parsePBSZ(long pbsz)
PBSZ command.
|
int |
sendCommand(String command,
String args)
Send an FTP command.
|
void |
setAuthValue(String auth)
Sets AUTH command use value.
|
void |
setEnabledCipherSuites(String[] cipherSuites)
Sets which particular cipher suites are enabled for use on this connection.
|
void |
setEnabledProtocols(String[] protocolVersions)
Sets which particular protocol versions are enabled for use on this connection.
|
void |
setEnabledSessionCreation(boolean isCreation)
Sets whether a new SSL session may be established by this socket.
|
void |
setEndpointCheckingEnabled(boolean enable)
Sets automatic endpoint identification checking using the HTTPS algorithm is supported on Java 1.7+.
|
void |
setHostnameVerifier(HostnameVerifier newHostnameVerifier)
Sets to override the default
HostnameVerifier to use. |
void |
setKeyManager(KeyManager keyManager)
Sets a
KeyManager to use |
void |
setNeedClientAuth(boolean isNeedClientAuth)
Sets the socket to require client authentication.
|
void |
setTrustManager(TrustManager trustManager)
Sets to override the default
TrustManager to use; if set to null, the default TrustManager from the JVM will be used. |
void |
setUseClientMode(boolean isClientMode)
Sets the socket to use client (or server) mode in its first handshake.
|
void |
setWantClientAuth(boolean isWantClientAuth)
Sets the socket to request client authentication, but only if such a request is appropriate to the cipher suite negotiated.
|
protected void |
sslNegotiation()
SSL/TLS negotiation.
|
_connectAction_, _openDataConnection_, _parseExtendedPassiveModeReply, _parsePassiveModeReply, _retrieveFile, _retrieveFileStream, _storeFile, _storeFileStream, abort, allocate, allocate, allocate, allocate, appendFile, appendFileStream, changeToParentDirectory, changeWorkingDirectory, completePendingCommand, configure, createParser, deleteFile, doCommand, doCommandAsStrings, enterLocalActiveMode, enterLocalPassiveMode, enterRemoteActiveMode, enterRemotePassiveMode, features, featureValue, featureValues, getActivePort, getAutodetectUTF8, getBufferSize, getControlKeepAliveReplyTimeoutDuration, getControlKeepAliveTimeoutDuration, getCopyStreamListener, getDataConnectionMode, getDataTimeout, getEntryParser, getHostAddress, getListArguments, getListHiddenFiles, getModificationTime, getPassiveHost, getPassiveLocalIPAddress, getPassivePort, getReceiveDataSocketBufferSize, getReportHostAddress, getRestartOffset, getSendDataSocketBufferSize, getSize, getStatus, getStatus, getSystemType, getSystemTypeOverride, hasFeature, hasFeature, hasFeature, initiateListParsing, initiateListParsing, initiateListParsing, initiateMListParsing, initiateMListParsing, isIpAddressFromPasvResponse, isRemoteVerificationEnabled, isUseEPSVwithIPv4, listDirectories, listDirectories, listFiles, listFiles, listFiles, listHelp, listHelp, listNames, listNames, loadResourceProperties, login, login, logout, makeDirectory, mdtmCalendar, mdtmFile, mdtmInstant, mlistDir, mlistDir, mlistDir, mlistFile, parsePathname, printWorkingDirectory, reinitialize, remoteAppend, remoteRetrieve, remoteStore, remoteStoreUnique, remoteStoreUnique, removeDirectory, rename, restart, retrieveFile, retrieveFileStream, sendNoOp, sendSiteCommand, setActiveExternalIPAddress, setActivePortRange, setAutodetectUTF8, setBufferSize, setControlKeepAliveReplyTimeout, setControlKeepAliveTimeout, setCopyStreamListener, setDataTimeout, setFileStructure, setFileTransferMode, setFileType, setFileType, setIpAddressFromPasvResponse, setListHiddenFiles, setModificationTime, setParserFactory, setPassiveLocalIPAddress, setPassiveLocalIPAddress, setPassiveNatWorkaroundStrategy, setReceieveDataSocketBufferSize, setRemoteVerificationEnabled, setReportActiveExternalIPAddress, setRestartOffset, setSendDataSocketBufferSize, setUseEPSVwithIPv4, storeFile, storeFileStream, storeUniqueFile, storeUniqueFile, storeUniqueFileStream, storeUniqueFileStream, structureMount__getReplyNoReport, __noop, abor, acct, allo, allo, allo, allo, appe, cdup, cwd, dele, eprt, epsv, feat, getCommandSupport, getControlEncoding, getReply, getReplyCode, getReplyString, getReplyString, getReplyStrings, help, help, isStrictMultilineParsing, isStrictReplyParsing, list, list, mdtm, mfmt, mkd, mlsd, mlsd, mlst, mlst, mode, nlst, nlst, noop, opts, opts, pass, pasv, port, pwd, quit, rein, rest, retr, rmd, rnfr, rnto, sendCommand, sendCommand, sendCommand, sendCommand, setControlEncoding, setControlEncoding, setStrictMultilineParsing, setStrictReplyParsing, site, size, smnt, stat, stat, stor, stou, stou, stru, syst, type, type, useraddProtocolCommandListener, applySocketAttributes, checkOpenOutputStream, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getConnectTimeout, getDefaultPort, getDefaultTimeout, getHostAddress, getHostAddress, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemoteInetSocketAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemotepublic static final int DEFAULT_FTPS_DATA_PORT
public static final int DEFAULT_FTPS_PORT
public FTPSClient()
FTPSClient(String, boolean).
Sets protocol to DEFAULT_PROTOCOL - i.e. TLS - and security mode to explicit (isImplicit = false)public FTPSClient(boolean isImplicit)
DEFAULT_PROTOCOL - i.e. TLS Calls FTPSClient(String, boolean)isImplicit - The security mode (Implicit/Explicit).public FTPSClient(boolean isImplicit,
SSLContext context)
DEFAULT_PROTOCOL - i.e. TLS The default TrustManager is set from
TrustManagerUtils.getValidateServerCertificateTrustManager()isImplicit - The security mode(Implicit/Explicit).context - A pre-configured SSL Contextpublic FTPSClient(SSLContext context)
DEFAULT_PROTOCOL - i.e. TLS and isImplicit false Calls FTPSClient(boolean, SSLContext)context - A pre-configured SSL Contextpublic FTPSClient(String protocol)
FTPSClient(String, boolean).protocol - the protocol to usepublic FTPSClient(String protocol, boolean isImplicit)
DEFAULT_FTPS_PORT
i.e. 990. The default TrustManager is set from TrustManagerUtils.getValidateServerCertificateTrustManager()protocol - the protocolisImplicit - The security mode(Implicit/Explicit).protected void _connectAction_()
throws IOException
_connectAction_ in class FTPClientIOException - If there is any problem with establishing the connection.SocketClient._connectAction_()protected Socket _openDataConnection_(String command, String arg) throws IOException
SSLSocket, which carries out handshake processing._openDataConnection_ in class FTPClientcommand - 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.IOException - If there is any problem with the connection.FTPClient._openDataConnection_(int, String)protected void _prepareDataSocket_(Socket socket) throws IOException
_openDataConnection_(int, String)
immediately after creating the socket. The default implementation is a no-opsocket - the socket to set upIOException - on errorpublic void disconnect()
throws IOException
Calls setSocketFactory(null) and setServerSocketFactory(null) to reset the factories that may have been changed during the session, e.g.
by execPROT(String)
disconnect in class FTPClientIOException - If an error occurs while disconnecting.public int execADAT(byte[] data)
throws IOException
data - The data to send with the command.IOException - If an I/O error occurs while sending the command.protected void execAUTH()
throws SSLException,
IOException
SSLException - If the server reply code equals neither "234" nor "334".IOException - If an I/O error occurs while either sending the command.public int execAUTH(String mechanism) throws IOException
mechanism - The mechanism name to send with the command.IOException - If an I/O error occurs while sending the command.public int execCCC()
throws IOException
SSLSocket instance to be assigned to a plain
Socket instancesIOException - If an I/O error occurs while sending the command.public int execCONF(byte[] data)
throws IOException
data - The data to send with the command.IOException - If an I/O error occurs while sending the command.public int execENC(byte[] data)
throws IOException
data - The data to send with the command.IOException - If an I/O error occurs while sending the command.public int execMIC(byte[] data)
throws IOException
data - The data to send with the command.IOException - If an I/O error occurs while sending the command.public void execPBSZ(long pbsz)
throws SSLException,
IOException
pbsz - Protection Buffer Size.SSLException - If the server reply code does not equal "200".IOException - If an I/O error occurs while sending the command.parsePBSZ(long)public void execPROT(String prot) throws SSLException, IOException
SocketClient.setSocketFactory(javax.net.SocketFactory) and
SocketClient.setServerSocketFactory(javax.net.ServerSocketFactory)prot - Data Channel Protection Level, if null, use DEFAULT_PROT.SSLException - If the server reply code does not equal 200.IOException - If an I/O error occurs while sending the command.public String getAuthValue()
public String[] getEnabledCipherSuites()
Socket is not an SSLSocket
instance, returns null.nullpublic String[] getEnabledProtocols()
Socket is not an
SSLSocket instance, returns null.nullpublic boolean getEnableSessionCreation()
Socket instance is not SSL-enabled (i.e. an instance of
SSLSocket with SSLSocketgetEnableSessionCreation()) enabled, this returns False.public HostnameVerifier getHostnameVerifier()
HostnameVerifier. The verifier is only used on client mode connections.public boolean getNeedClientAuth()
Socket is not an SSLSocket instance, returns false.protected String getProtocol()
protected String[] getProtocols()
getEnabledProtocols() method gets the value from the socket while
this method gets its value from this instance's config.protected String[] getSuites()
getEnabledCipherSuites() method gets the value from the socket while
this method gets its value from this instance's config.public TrustManager getTrustManager()
TrustManager.public boolean getUseClientMode()
Socket is not an SSLSocket instance,
returns false.public boolean getWantClientAuth()
Socket is not an SSLSocket instance, returns false.protected boolean isClientMode()
getUseClientMode() method gets the value from the socket while
this method gets its value from this instance's config.protected boolean isCreation()
public boolean isEndpointCheckingEnabled()
protected boolean isImplicit()
protected boolean isNeedClientAuth()
getNeedClientAuth() method gets the value from the socket while
this method gets its value from this instance's config.protected boolean isWantClientAuth()
getWantClientAuth() method gets the value from the socket while
this method gets its value from this instance's config.public byte[] parseADATReply(String reply)
reply - The ADAT reply to parse.public long parsePBSZ(long pbsz)
throws SSLException,
IOException
pbsz - Protection Buffer Size.SSLException - If the server reply code does not equal "200".IOException - If an I/O error occurs while sending the command.execPBSZ(long)public int sendCommand(String command, String args) throws IOException
SSLSocket instance to be assigned to a plain
SocketsendCommand in class FTPcommand - 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.IOException - If an I/O error occurs while sending the command.SSLException - if a CCC command failsFTP.sendCommand(String)public void setAuthValue(String auth)
auth - AUTH command use value.public void setEnabledCipherSuites(String[] cipherSuites)
cipherSuites - The cipher suites.public void setEnabledProtocols(String[] protocolVersions)
protocolVersions - The protocol versions.public void setEnabledSessionCreation(boolean isCreation)
isCreation - The established socket flag.public void setEndpointCheckingEnabled(boolean enable)
enable - Enable automatic endpoint identification checking using the HTTPS algorithm on Java 1.7+.public void setHostnameVerifier(HostnameVerifier newHostnameVerifier)
HostnameVerifier to use. The verifier is only used on client mode connections.newHostnameVerifier - The HostnameVerifier implementation to set or null to disable.public void setKeyManager(KeyManager keyManager)
KeyManager to usekeyManager - The KeyManager implementation to set.KeyManagerUtilspublic void setNeedClientAuth(boolean isNeedClientAuth)
isNeedClientAuth - The need client auth flag.public void setTrustManager(TrustManager trustManager)
TrustManager to use; if set to null, the default TrustManager from the JVM will be used.trustManager - The TrustManager implementation to set, may be nullTrustManagerUtilspublic void setUseClientMode(boolean isClientMode)
isClientMode - The use client mode flag.public void setWantClientAuth(boolean isWantClientAuth)
isWantClientAuth - The want client auth flag.protected void sslNegotiation()
throws IOException
IOException - If server negotiation fails