Secure iNet Factory

com.jscape.inet.ftps
Class FtpsClient

java.lang.Object
  extended by com.jscape.inet.ftps.FtpsClient

public class FtpsClient
extends java.lang.Object

The FTP client. Provides protocol-level services hiding the exact FTP request/response exchange implementation.


Field Summary
static char DATA_CLEAR
           
static char DATA_CONFIDENTIAL
           
static char DATA_PRIVATE
           
static char DATA_SAFE
           
static int DEFAULT_DATA_PORT
          The FTP data default port
static int DEFAULT_PORT
          The FTP default port
static java.lang.String EOL
          The FTP end-of-line symbols
 
Method Summary
 void abort()
          The FTP ABOR command.
 void account(java.lang.String account)
          The FTP ACCT command.
 void allocate(int size)
          The FTP ALLO command.
 void allocate(int size, int optionsSize)
          The FTP ALLO command.
 java.net.Socket append(java.lang.String fileName)
          The FTP APPE command.
 void authorize(java.lang.String method)
          The FTP AUTH TLS command.
 void bufferSize()
          The FTP PBSZ 0 command.
 void changeToParentDirectory()
          The FTP CDUPcommand.
 void changeWorkingDirectory(java.lang.String directory)
          The FTP CWD command.
 void clear()
          The FTP CCC command.
 void close()
          Closes the current client.
static FtpsClient createProtected(Ftps source, ConnectionParameters parameters, javax.net.ssl.SSLContext context, java.lang.String[] enabledCiphers, Logger logger)
           
static FtpsClient createUnprotected(Ftps source, ConnectionParameters parameters, javax.net.ssl.SSLContext context, java.lang.String[] enabledCiphers, Logger logger)
           
 void dataPort(int dataPortStart, int dataPortEnd)
          The FTP PORT command.
 void delete(java.lang.String fileName)
          The FTP DELE command.
 void fileStructure(char fileStructure)
          The FTP STRU command.
 boolean getAutoDetectIpv6()
          Get auto detect Ipv6 detection mode.
 boolean getConnectBeforeCommand()
          Gets the connectBefore indicator
 FtpsCertificateVerifier getFtpsCertificateVerifier()
           
 Response getLastResponse()
          Obtains the last server response.
 java.lang.String getNATAddress()
          Get NAT address.
 java.lang.String getPortAddress()
          Gets the external address to use when using active connections using the PORT command.
 boolean getUseEPRT()
          Gets use EPRT value.
 boolean getUseEPSV()
          Gets use EPSV value.
 java.lang.String help(java.lang.String option)
          The FTP HELP command.
 boolean isClosed()
          Checks if the current client is closed.
 boolean isShutdownCCC()
          Gets whether SSL connection should be shutdown after successfully issuing CCC command.
 java.net.Socket list(java.lang.String path)
          The FTP LIST command.
 void makeDirectory(java.lang.String directoryName)
          The FTP MKD command.
 java.net.Socket mlsd(java.lang.String dirname)
           
 java.net.Socket nameList(java.lang.String path)
          The FTP NLST command.
 Response noop()
          The FTP NOOP command.
 void passive(boolean firewall)
          The FTP PASV command.
 Response password(java.lang.String password)
          The FTP PASS command.
 java.lang.String printWorkingDirectory()
          The FTP PWD command.
 void protectionLevel(char level)
          The FTP PROT command.
 void quit()
          The FTP QUIT command.
 Response readResponse()
          Reads the server response skipping all preliminary responses.
 void reinitialize()
          The FTP REIN command.
 void removeDirectory(java.lang.String directoryName)
          The FTP RMD command.
 void rename(java.lang.String oldName, java.lang.String newName)
          The FTP RNFR and RNTO commands.
 void representationType(java.lang.String type)
          The FTP TYPE command.
 void restart(java.lang.String serverMarker)
          The FTP REST command.
 java.net.Socket retrieve(java.lang.String fileName)
          The FTP RETR command.
 void sendCommand(java.lang.String command)
          Sends command to the server.
 Response sendRequest(java.lang.String command)
          Sends the request to the server.
 void setAutoDetectIpv6(boolean value)
          Set auto detect Ipv6 detection mode.
 void setConnectBeforeCommand(boolean connect)
          Sets the connectBefore property value
 void setFtpsCertificateVerifier(FtpsCertificateVerifier certificateVerifier)
           
 void setNATAddress(java.lang.String ipAddress)
          Sets a NAT address which will be used after PASV command.
 void setPortAddress(java.lang.String string)
          Sets the external address to use when using active connections using the PORT command.
 void setReceiveBufferSize(int receiveBufferSize)
          Sets the receive buffer size option of the ftps connection.
 void setSendBufferSize(int sendBufferSize)
          Sets the send buffer size option of the ftps connection.
 void setShutdownCCC(boolean shutdownCCC)
          Sets whether SSL connection should be shutdown after successfully issuing CCC command.
 void setUseEPRT(boolean useEPRT)
          Sets use EPRT indicator.
 void setUseEPSV(boolean useEPSV)
          Sets use EPSV indicator.
 java.lang.String siteParameters()
          The FTP SITE command.
 java.lang.String status(java.lang.String path)
          The FTP STAT command.
 java.net.Socket store(java.lang.String fileName)
          The FTP STOR command.
 java.net.Socket storeUnique(java.lang.String fileName)
          The FTP STOU command.
 void structureMount(java.lang.String structure)
          The FTP SMNT command.
 java.lang.String system()
          The FTP SYST command.
 void transferMode(java.lang.String mode)
          The FTP TYPE command.
 Response userName(java.lang.String name)
          The FTP USER command.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The FTP default port

See Also:
Constant Field Values

DEFAULT_DATA_PORT

public static final int DEFAULT_DATA_PORT
The FTP data default port

See Also:
Constant Field Values

DATA_CLEAR

public static final char DATA_CLEAR
See Also:
Constant Field Values

DATA_SAFE

public static final char DATA_SAFE
See Also:
Constant Field Values

DATA_CONFIDENTIAL

public static final char DATA_CONFIDENTIAL
See Also:
Constant Field Values

DATA_PRIVATE

public static final char DATA_PRIVATE
See Also:
Constant Field Values

EOL

public static final java.lang.String EOL
The FTP end-of-line symbols

See Also:
Constant Field Values
Method Detail

createUnprotected

public static FtpsClient createUnprotected(Ftps source,
                                           ConnectionParameters parameters,
                                           javax.net.ssl.SSLContext context,
                                           java.lang.String[] enabledCiphers,
                                           Logger logger)
                                    throws FtpException
Parameters:
parameters -
context -
logger -
Returns:
Throws:
FtpException

createProtected

public static FtpsClient createProtected(Ftps source,
                                         ConnectionParameters parameters,
                                         javax.net.ssl.SSLContext context,
                                         java.lang.String[] enabledCiphers,
                                         Logger logger)
                                  throws FtpException
Parameters:
parameters -
context -
logger -
Returns:
Throws:
FtpException

close

public void close()
Closes the current client.


setAutoDetectIpv6

public void setAutoDetectIpv6(boolean value)
Set auto detect Ipv6 detection mode.

Parameters:
value -

getAutoDetectIpv6

public boolean getAutoDetectIpv6()
Get auto detect Ipv6 detection mode.

Returns:
value

isClosed

public boolean isClosed()
Checks if the current client is closed.

Returns:
true if the client is closed; false otherwise

getPortAddress

public java.lang.String getPortAddress()
Gets the external address to use when using active connections using the PORT command.

Returns:
the external ip address

setPortAddress

public void setPortAddress(java.lang.String string)
Sets the external address to use when using active connections using the PORT command.

Parameters:
string - an ip address

setConnectBeforeCommand

public void setConnectBeforeCommand(boolean connect)
Sets the connectBefore property value

Parameters:
connect - It indicates if the connection will be established before send the command

setNATAddress

public void setNATAddress(java.lang.String ipAddress)
                   throws FtpException
Sets a NAT address which will be used after PASV command.

Parameters:
ipAddress - The NAT IP address.
Throws:
FtpException - If an error occurs.

getNATAddress

public java.lang.String getNATAddress()
Get NAT address.

Returns:
NAT address

getConnectBeforeCommand

public boolean getConnectBeforeCommand()
Gets the connectBefore indicator

Returns:
true the connection will be establiched before send the command

sendRequest

public Response sendRequest(java.lang.String command)
                     throws FtpException
Sends the request to the server.

Parameters:
command - a FTP command
Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

getLastResponse

public Response getLastResponse()
Obtains the last server response.

Returns:
the last server response

sendCommand

public void sendCommand(java.lang.String command)
                 throws FtpException
Sends command to the server.

Parameters:
command - a FTP command
Throws:
FtpException - if an I/O or protocol error occurs

readResponse

public Response readResponse()
                      throws FtpException
Reads the server response skipping all preliminary responses.

Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

isShutdownCCC

public boolean isShutdownCCC()
Gets whether SSL connection should be shutdown after successfully issuing CCC command. Default is true.

Returns:
true to shutdown, false otherwise

setShutdownCCC

public void setShutdownCCC(boolean shutdownCCC)
Sets whether SSL connection should be shutdown after successfully issuing CCC command. Default is true.

Parameters:
shutdownCCC - true to shutdown, false otherwise

setUseEPSV

public void setUseEPSV(boolean useEPSV)
Sets use EPSV indicator. When it is true then will be sent EPSV.

Parameters:
useEPSV - The use EPSV value

getUseEPSV

public boolean getUseEPSV()
Gets use EPSV value.

Returns:
true the pasive mode will be sent EPSV command

setUseEPRT

public void setUseEPRT(boolean useEPRT)
Sets use EPRT indicator. When it is true then will be sent EPRT.

Parameters:
useEPRT - The use EPRT value

getUseEPRT

public boolean getUseEPRT()
Gets use EPRT value.

Returns:
true the active mode will be sent EPRT command

userName

public Response userName(java.lang.String name)
                  throws FtpException
The FTP USER command.

Parameters:
name - user name
Returns:
the server response which may be used for additional authentication
Throws:
FtpException - if an I/O or protocol error occurs

password

public Response password(java.lang.String password)
                  throws FtpException
The FTP PASS command.

Parameters:
password - the password
Returns:
the server response which may be used for additional authentication
Throws:
FtpException - if an I/O or protocol error occurs

account

public void account(java.lang.String account)
             throws FtpException
The FTP ACCT command.

Parameters:
account - the user account
Throws:
FtpException - if an I/O or protocol error occurs

changeWorkingDirectory

public void changeWorkingDirectory(java.lang.String directory)
                            throws FtpException
The FTP CWD command.

Parameters:
directory - the target directory.
Throws:
FtpException - if an I/O or protocol error occurs

changeToParentDirectory

public void changeToParentDirectory()
                             throws FtpException
The FTP CDUPcommand.

Throws:
FtpException - if an I/O or protocol error occurs

structureMount

public void structureMount(java.lang.String structure)
                    throws FtpException
The FTP SMNT command.

Parameters:
structure - the structure
Throws:
FtpException - if an I/O or protocol error occurs

reinitialize

public void reinitialize()
                  throws FtpException
The FTP REIN command.

Throws:
FtpException - if an I/O or protocol error occurs

quit

public void quit()
          throws FtpException
The FTP QUIT command.

Throws:
FtpException - if an I/O or protocol error occurs

dataPort

public void dataPort(int dataPortStart,
                     int dataPortEnd)
              throws FtpException
The FTP PORT command.

Parameters:
dataPortStart - The start data port range.
dataPortEnd - The end data port range.
Throws:
FtpException - if an I/O or protocol error occurs

passive

public void passive(boolean firewall)
             throws FtpException
The FTP PASV command.

Throws:
FtpException - if an I/O or protocol error occurs

transferMode

public void transferMode(java.lang.String mode)
                  throws FtpException
The FTP TYPE command.

Parameters:
mode - the transfer mode
Throws:
FtpException - if an I/O or protocol error occurs

representationType

public void representationType(java.lang.String type)
                        throws FtpException
The FTP TYPE command.

Parameters:
type - the representation type
Throws:
FtpException - if an I/O or protocol error occurs

fileStructure

public void fileStructure(char fileStructure)
                   throws FtpException
The FTP STRU command.

Parameters:
fileStructure - the file structure
Throws:
FtpException - if an I/O or protocol error occurs

allocate

public void allocate(int size)
              throws FtpException
The FTP ALLO command.

Parameters:
size - the size
Throws:
FtpException - if an I/O or protocol error occurs

allocate

public void allocate(int size,
                     int optionsSize)
              throws FtpException
The FTP ALLO command.

Parameters:
size - the size
optionsSize - the options size
Throws:
FtpException - if an I/O or protocol error occurs

restart

public void restart(java.lang.String serverMarker)
             throws FtpException
The FTP REST command.

Parameters:
serverMarker - the server marker string
Throws:
FtpException - if an I/O or protocol error occurs

retrieve

public java.net.Socket retrieve(java.lang.String fileName)
                         throws FtpException
The FTP RETR command. This command needs to read final response after reading the data.

Parameters:
fileName - the target file path
Returns:
the opened data socket
Throws:
FtpException - if an I/O or protocol error occurs

store

public java.net.Socket store(java.lang.String fileName)
                      throws FtpException
The FTP STOR command. This command needs to read final response after reading the data.

Parameters:
fileName - the target file path
Returns:
the opened data socket
Throws:
FtpException - if an I/O or protocol error occurs

storeUnique

public java.net.Socket storeUnique(java.lang.String fileName)
                            throws FtpException
The FTP STOU command. This command needs to read final response after reading the data.

Returns:
the opened data socket
Throws:
FtpException - if an I/O or protocol error occurs

append

public java.net.Socket append(java.lang.String fileName)
                       throws FtpException
The FTP APPE command. This command needs to read final response after reading the data.

Parameters:
fileName - the target file path
Returns:
the opened data socket
Throws:
FtpException - if an I/O or protocol error occurs

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws FtpException
The FTP RNFR and RNTO commands.

Parameters:
oldName - the old file name
newName - the new file name
Throws:
FtpException - if an I/O or protocol error occurs

abort

public void abort()
           throws FtpException
The FTP ABOR command.

Throws:
FtpException - if an I/O or protocol error occurs

delete

public void delete(java.lang.String fileName)
            throws FtpException
The FTP DELE command.

Parameters:
fileName - the target file name
Throws:
FtpException - if an I/O or protocol error occurs

removeDirectory

public void removeDirectory(java.lang.String directoryName)
                     throws FtpException
The FTP RMD command.

Parameters:
directoryName - the target directory name
Throws:
FtpException - if an I/O or protocol error occurs

makeDirectory

public void makeDirectory(java.lang.String directoryName)
                   throws FtpException
The FTP MKD command.

Parameters:
directoryName - the target directory name
Throws:
FtpException - if an I/O or protocol error occurs

printWorkingDirectory

public java.lang.String printWorkingDirectory()
                                       throws FtpException
The FTP PWD command.

Returns:
the server resopnse
Throws:
FtpException - if an I/O or protocol error occurs

list

public java.net.Socket list(java.lang.String path)
                     throws FtpException
The FTP LIST command. This command needs to read final response after reading the data.

Parameters:
path - the directory path
Returns:
the opened data socket
Throws:
FtpException - if an I/O or protocol error occurs

nameList

public java.net.Socket nameList(java.lang.String path)
                         throws FtpException
The FTP NLST command. This command needs to read final response after reading the data.

Parameters:
path - the directory path
Returns:
the opened data connection
Throws:
FtpException - if an I/O or protocol error occurs

siteParameters

public java.lang.String siteParameters()
                                throws FtpException
The FTP SITE command.

Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

system

public java.lang.String system()
                        throws FtpException
The FTP SYST command.

Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

status

public java.lang.String status(java.lang.String path)
                        throws FtpException
The FTP STAT command.

Parameters:
path - the file path
Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

help

public java.lang.String help(java.lang.String option)
                      throws FtpException
The FTP HELP command.

Parameters:
option - the command option
Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

noop

public Response noop()
              throws FtpException
The FTP NOOP command.

Returns:
the server response
Throws:
FtpException - if an I/O or protocol error occurs

authorize

public void authorize(java.lang.String method)
               throws FtpException
The FTP AUTH TLS command.

Throws:
FtpException - if an I/O or protocol error occurs

clear

public void clear()
           throws FtpException
The FTP CCC command.

Throws:
FtpException - if an I/O or protocol error occurs

bufferSize

public void bufferSize()
                throws FtpException
The FTP PBSZ 0 command.

Throws:
FtpException - if an I/O or protocol error occurs

protectionLevel

public void protectionLevel(char level)
                     throws FtpException
The FTP PROT command.

Parameters:
level - the protection level
Throws:
FtpException - if an I/O or protocol error occurs

setSendBufferSize

public void setSendBufferSize(int sendBufferSize)
Sets the send buffer size option of the ftps connection.

Parameters:
sendBufferSize - Send buffer size.

setReceiveBufferSize

public void setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size option of the ftps connection.

Parameters:
receiveBufferSize - Receive buffer size.

mlsd

public java.net.Socket mlsd(java.lang.String dirname)
                     throws FtpException
Throws:
FtpException

getFtpsCertificateVerifier

public FtpsCertificateVerifier getFtpsCertificateVerifier()

setFtpsCertificateVerifier

public void setFtpsCertificateVerifier(FtpsCertificateVerifier certificateVerifier)

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved