|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.net.SocketClient org.apache.commons.net.ftp.FTP org.apache.commons.net.ftp.FTPClient org.apache.commons.net.ftp.FTPSClient
public class FTPSClient
FTP over SSL processing. If desired, the JVM property -Djavax.net.debug=all can be used to see wire-level SSL details.
Field Summary | |
---|---|
static int |
DEFAULT_FTPS_DATA_PORT
|
static int |
DEFAULT_FTPS_PORT
|
static String |
KEYSTORE_ALGORITHM
Deprecated. - not used - may be removed in a future release |
static String |
PROVIDER
Deprecated. - not used - may be removed in a future release |
static String |
STORE_TYPE
Deprecated. - not used - may be removed in a future release |
static String |
TRUSTSTORE_ALGORITHM
Deprecated. - not used - may be removed in a future release |
Fields inherited from class org.apache.commons.net.ftp.FTPClient |
---|
ACTIVE_LOCAL_DATA_CONNECTION_MODE, ACTIVE_REMOTE_DATA_CONNECTION_MODE, FTP_SYSTEM_TYPE, FTP_SYSTEM_TYPE_DEFAULT, PASSIVE_LOCAL_DATA_CONNECTION_MODE, PASSIVE_REMOTE_DATA_CONNECTION_MODE, SYSTEM_TYPE_PROPERTIES |
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, 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 explict mode, calls FTPSClient(String, boolean) . |
|
FTPSClient(String protocol,
boolean isImplicit)
Constructor for FTPSClient allowing specification of protocol and security mode. |
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. |
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)
Send the ADAT command with the specified authentication data. |
protected void |
execAUTH()
AUTH command. |
int |
execAUTH(String mechanism)
Send the AUTH command with the specified mechanism. |
int |
execCCC()
Send the CCC command to the server. |
int |
execCONF(byte[] data)
Send the CONF command with the specified data. |
int |
execENC(byte[] data)
Send the ENC command with the specified data. |
int |
execMIC(byte[] data)
Send the MIC command with the specified data. |
void |
execPBSZ(long pbsz)
PBSZ command. |
void |
execPROT(String prot)
PROT command. |
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. |
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)
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 a new 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; if set to null ,
the default TrustManager from the JVM will be used. |
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 void |
sslNegotiation()
SSL/TLS negotiation. |
Methods inherited from class org.apache.commons.net.ftp.FTP |
---|
__getReplyNoReport, __noop, abor, acct, allo, allo, appe, cdup, cwd, dele, eprt, epsv, feat, getCommandSupport, getControlEncoding, getReply, getReplyCode, getReplyString, getReplyStrings, help, help, isStrictMultilineParsing, list, list, mdtm, mfmt, mkd, mlsd, mlsd, mlst, mlst, mode, nlst, nlst, noop, pass, pasv, port, pwd, quit, rein, 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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_FTPS_DATA_PORT
public static final int DEFAULT_FTPS_PORT
@Deprecated public static String KEYSTORE_ALGORITHM
@Deprecated public static String TRUSTSTORE_ALGORITHM
@Deprecated public static String PROVIDER
@Deprecated public static String STORE_TYPE
Constructor Detail |
---|
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(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).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 ContextMethod Detail |
---|
public void setAuthValue(String auth)
auth
- AUTH command use value.public String getAuthValue()
protected void _connectAction_() throws IOException
_connectAction_
in class FTPClient
IOException
- If it throw by _connectAction_.SocketClient._connectAction_()
protected void execAUTH() throws SSLException, IOException
SSLException
- If it server reply code not equal "234" and "334".
IOException
- If an I/O error occurs while either sending
the command.protected void sslNegotiation() throws IOException
IOException
- If server negotiation failspublic void setKeyManager(KeyManager keyManager)
KeyManager
to use
keyManager
- The KeyManager implementation to set.KeyManagerUtils
public void setEnabledSessionCreation(boolean isCreation)
isCreation
- The established socket flag.public boolean getEnableSessionCreation()
Socket
instance is not SSL-enabled (i.e. an
instance of SSLSocket
with SSLSocket
getEnableSessionCreation()
) enabled,
this returns False.
public void setNeedClientAuth(boolean isNeedClientAuth)
isNeedClientAuth
- The need client auth flag.public boolean getNeedClientAuth()
Socket
is not an SSLSocket
instance, returns false.
public void setWantClientAuth(boolean isWantClientAuth)
isWantClientAuth
- The want client auth flag.public boolean getWantClientAuth()
Socket
is not an SSLSocket
instance, returns false.
public void setUseClientMode(boolean isClientMode)
isClientMode
- The use client mode flag.public boolean getUseClientMode()
Socket
is not an SSLSocket
instance, returns false.
public void setEnabledCipherSuites(String[] cipherSuites)
cipherSuites
- The cipher suites.public String[] getEnabledCipherSuites()
Socket
is not an SSLSocket
instance, returns null.
null
public void setEnabledProtocols(String[] protocolVersions)
protocolVersions
- The protocol versions.public String[] getEnabledProtocols()
Socket
is not an SSLSocket
instance, returns null.
null
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 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 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 int sendCommand(String command, String args) throws IOException
SSLSocket
instance to be assigned to a plain Socket
sendCommand
in class FTP
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.
IOException
- If an I/O error occurs while sending the command.
SSLException
- if a CCC command failsFTP.sendCommand(java.lang.String)
protected Socket _openDataConnection_(int command, String arg) throws IOException
SSLSocket
, which carries out handshake processing.
_openDataConnection_
in class FTPClient
command
- The int 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 Socket _openDataConnection_(String command, String arg) throws IOException
SSLSocket
, which carries out handshake processing.
_openDataConnection_
in class FTPClient
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.
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-op
IOException
public TrustManager getTrustManager()
TrustManager
.
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 null
TrustManagerUtils
public 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 FTPClient
IOException
- If an error occurs while disconnecting.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 execADAT(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 execCCC() throws IOException
SSLSocket
instance to be assigned
to a plain Socket
instances
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 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 byte[] parseADATReply(String reply)
reply
- The ADAT reply to parse.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |