|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.glub.secureftp.bean.FTP
com.glub.secureftp.bean.SSLFTP
public class SSLFTP
The SSLFTP
class is responsible for handling the SSL
extensions of the File Transfer Protocol.
Field Summary | |
---|---|
static short |
EXPLICIT_CONNECTION
Used to set the connection type to explicit . |
static short |
IMPLICIT_CONNECTION
Used to set the connection type to implicit . |
Fields inherited from class com.glub.secureftp.bean.FTP |
---|
ACTIVE_CONNECTION_TYPE, ASCII_TRANSFER_MODE, AUTO_TRANSFER_MODE, BINARY_TRANSFER_MODE, command, EBCDIC_TRANSFER_MODE, isConnected, isLoggedIn, lastPortFromRange, maxPortInRange, minPortInRange, modeZEnabled, PASSIVE_CONNECTION_TYPE, PASV_CONNECTION_TYPE, recvCmdStream, sendCmdStream |
Constructor Summary | |
---|---|
SSLFTP(SSLSessionManager sslSessionManager,
HostInfo hostInfo,
File keyStoreFile,
String keyStorePass,
SecureRandom random,
short connectionType,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new SSLFTP object with a key store, response
notification, and an overridden SecureRandom object. |
|
SSLFTP(SSLSessionManager sslSessionManager,
HostInfo hostInfo,
File keyStoreFile,
String keyStorePass,
short connectionType)
Create a new SSLFTP object with a key store but without
response notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
HostInfo hostInfo,
File keyStoreFile,
String keyStorePass,
short connectionType,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new SSLFTP object with a key store and response
notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
HostInfo hostInfo,
short connectionType)
Create a new SSLFTP object without a key store nor response
notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
HostInfo hostInfo,
short connectionType,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new SSLFTP object without a key store but with
response notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
String host,
int port,
File keyStoreFile,
String keyStorePass,
SecureRandom random,
short connectionType,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new SSLFTP object with a key store, response
notification, and an overridden SecureRandom object. |
|
SSLFTP(SSLSessionManager sslSessionManager,
String host,
int port,
File keyStoreFile,
String keyStorePass,
short connectionType)
Create a new SSLFTP object with a key store but without
response notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
String host,
int port,
File keyStoreFile,
String keyStorePass,
short connectionType,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new SSLFTP object with a key store and response
notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
String host,
int port,
short connectionType)
Create a new SSLFTP object without a key store nor response
notification. |
|
SSLFTP(SSLSessionManager sslSessionManager,
String host,
int port,
short connectionType,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new SSLFTP object without a key store but with
response notification. |
Method Summary | |
---|---|
protected void |
aboutToTransferData()
Called before data transfers begin. |
void |
clearClientAuthentication()
Clear the client key from the keystore (if it exists) |
void |
connect()
Connect to the FTP host and port with data encyption off by default. |
void |
connect(boolean encryptData)
Connect to the FTP host and port. |
protected void |
doExplicitHandshake()
This handles an explicit SSL connection by sending the AUTH command to the FTP server and converting the plaintext control socket into an SSL control socket. |
void |
forceDataEncryptionOn(boolean on)
Forces the encryption of the data channel on or off. |
String |
getAuthType()
Get the AUTH type we are sending during the AUTH command. |
static ArrayList |
getCertificates(File keyStoreFile,
String keyStorePass)
This allows the list of SSLCertificate objects to be returned
from the KeyStore . |
boolean |
isDataEncryptionOn()
Whether or not data encryption is being done. |
void |
logout()
Logout from the FTP server. |
protected Socket |
makeControlSocket(HostInfo hostInfo)
Make a new control socket. |
protected ServerSocket |
makeDataServerSocket(HostInfo hostInfo)
Make a new data server socket. |
protected Socket |
makeDataSocket(HostInfo hostInfo)
Make a new data socket. |
protected FTPCommand |
makeFTPCommand(BufferedReader inputReader,
PrintWriter outputWriter)
Set the FTPCommand object. |
static void |
preSeed()
This allows the SecureRandom object to be generated prior
to being used. |
void |
setAuthType(String authType)
This allows the default AUTH type to be set from SSL to
some other type (such as TLS). |
void |
setClearCommandChannel()
Revert a secure connection back to a clear control connection. |
void |
setClientAuthentication(File privateKey,
File[] certList)
Specify a private key and public certificate chain to use for client authentication. |
void |
setClientAuthentication(File privateKey,
File[] certList,
String password)
Specify a private key and public certificate chain to use for client authentication. |
void |
setClientAuthentication(PrivateKey privateKey,
X509Certificate[] certList)
Specify a private key and public certificate chain to use for client authentication. |
protected void |
setControlSocket(Socket controlSocket,
boolean saveInsecureSocket)
Set the control socket. |
void |
setDataEncryptionOn(boolean on)
Set the encryption of the data channel on or off. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short IMPLICIT_CONNECTION
implicit
.
public static final short EXPLICIT_CONNECTION
explicit
.
Constructor Detail |
---|
public SSLFTP(SSLSessionManager sslSessionManager, HostInfo hostInfo, short connectionType)
SSLFTP
object without a key store nor response
notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.hostInfo
- the HostInfo to connect to.connectionType
- the type of connection to make (implicit or
explicit).IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, String host, int port, short connectionType)
SSLFTP
object without a key store nor response
notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.host
- the hostname to connect to.port
- the port to connect to.connectionType
- the type of connection to make (implicit or
explicit).IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, HostInfo hostInfo, short connectionType, OutputStream sendCmdStream, OutputStream recvCmdStream)
SSLFTP
object without a key store but with
response notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.hostInfo
- the HostInfo to connect to.connectionType
- the type of connection to make (implicit or
explicit).sendCmdStream
- the commands sent to the server.
Pass null
if not interested
in this data.recvCmdStream
- the responses returned from the server.
Pass null
if not interested
in this data.IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, String host, int port, short connectionType, OutputStream sendCmdStream, OutputStream recvCmdStream)
SSLFTP
object without a key store but with
response notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.host
- the hostname to connect to.port
- the port to connect to.connectionType
- the type of connection to make (implicit or
explicit).sendCmdStream
- the commands sent to the server.
Pass null
if not interested
in this data.recvCmdStream
- the responses returned from the server.
Pass null
if not interested
in this data.IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, HostInfo hostInfo, File keyStoreFile, String keyStorePass, short connectionType)
SSLFTP
object with a key store but without
response notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.hostInfo
- the HostInfo to connect to.keyStoreFile
- the file that acts as the key store.keyStorePass
- the key store's password.connectionType
- the type of connection to make (implicit or
explicit).IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, String host, int port, File keyStoreFile, String keyStorePass, short connectionType)
SSLFTP
object with a key store but without
response notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.host
- the hostname to connect to.port
- the port to connect to.keyStoreFile
- the file that acts as the key store.keyStorePass
- the key store's password.connectionType
- the type of connection to make (implicit or
explicit).IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, HostInfo hostInfo, File keyStoreFile, String keyStorePass, short connectionType, OutputStream sendCmdStream, OutputStream recvCmdStream)
SSLFTP
object with a key store and response
notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.hostInfo
- the HostInfo to connect to.keyStoreFile
- the file that acts as the key store.keyStorePass
- the key store's password.connectionType
- the type of connection to make (implicit or
explicit).sendCmdStream
- the commands sent to the server.
Pass null
if not interested
in this data.recvCmdStream
- the responses returned from the server.
Pass null
if not interested
in this data.IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, String host, int port, File keyStoreFile, String keyStorePass, short connectionType, OutputStream sendCmdStream, OutputStream recvCmdStream)
SSLFTP
object with a key store and response
notification.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.host
- the hostname to connect to.port
- the port to connect to.keyStoreFile
- the file that acts as the key store.keyStorePass
- the key store's password.connectionType
- the type of connection to make (implicit or
explicit).sendCmdStream
- the commands sent to the server.
Pass null
if not interested
in this data.recvCmdStream
- the responses returned from the server.
Pass null
if not interested
in this data.IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, HostInfo hostInfo, File keyStoreFile, String keyStorePass, SecureRandom random, short connectionType, OutputStream sendCmdStream, OutputStream recvCmdStream)
SSLFTP
object with a key store, response
notification, and an overridden SecureRandom
object.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.hostInfo
- the HostInfo to connect to.keyStoreFile
- the file that acts as the key store.keyStorePass
- the key store's password.random
- you can override our randomizer with your own.connectionType
- the type of connection to make (implicit or
explicit).sendCmdStream
- the commands sent to the server.
Pass null
if not interested
in this data.recvCmdStream
- the responses returned from the server.
Pass null
if not interested
in this data.IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
public SSLFTP(SSLSessionManager sslSessionManager, String host, int port, File keyStoreFile, String keyStorePass, SecureRandom random, short connectionType, OutputStream sendCmdStream, OutputStream recvCmdStream)
SSLFTP
object with a key store, response
notification, and an overridden SecureRandom
object.
sslSessionManager
- the Object that handles certificate information
and decisions that are made based on these
certificates.host
- the hostname to connect to.port
- the port to connect to.keyStoreFile
- the file that acts as the key store.keyStorePass
- the key store's password.random
- you can override our randomizer with your own.connectionType
- the type of connection to make (implicit or
explicit).sendCmdStream
- the commands sent to the server.
Pass null
if not interested
in this data.recvCmdStream
- the responses returned from the server.
Pass null
if not interested
in this data.IMPLICIT_CONNECTION
,
EXPLICIT_CONNECTION
Method Detail |
---|
public void setClientAuthentication(File privateKey, File[] certList) throws FileNotFoundException, IOException, InvalidKeySpecException, CertificateException, KeyStoreException
privateKey
- The private key for the clientcertList
- The public certificates for the client
FileNotFoundException
IOException
InvalidKeySpecException
CertificateException
KeyStoreException
public void setClientAuthentication(File privateKey, File[] certList, String password) throws FileNotFoundException, IOException, InvalidKeySpecException, CertificateException, KeyStoreException
privateKey
- The private key for the clientcertList
- The public certificates for the clientpassword
- The password to access the key/certifificate
FileNotFoundException
IOException
InvalidKeySpecException
CertificateException
KeyStoreException
public void setClientAuthentication(PrivateKey privateKey, X509Certificate[] certList) throws KeyStoreException
privateKey
- The private key for the clientcertList
- The public certificates for the client
KeyStoreException
public void clearClientAuthentication() throws KeyStoreException
KeyStoreException
public void connect() throws FTPConnectException, FTPException, IOException, UnknownHostException, IllegalArgumentException
AUTH
command is sent here.
By default we attempt an implicit connection.
connect
in class FTP
FTPConnectException
- if the connection fails.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
UnknownHostException
- if the host could not be found.
IllegalArgumentException
- if hostName
is
null
.doExplicitHandshake()
,
SSLFTPCommand.auth(String)
public void connect(boolean encryptData) throws FTPConnectException, FTPException, IOException, UnknownHostException, IllegalArgumentException
AUTH
command is sent here. By default we attempt an implicit connection.
encryptData
- the default encryption state of the
data channel
FTPConnectException
- if the connection fails.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
UnknownHostException
- if the host could not be found.
IllegalArgumentException
- if hostName
is
null
.doExplicitHandshake()
,
SSLFTPCommand.auth(String)
protected void doExplicitHandshake() throws FTPAuthNotSupportedException, FTPException, IOException, IllegalArgumentException
FTPAuthNotSupportedException
- if the auth command is not supported.
FTPException
- if the FTP server returns an error code.
IOException
- if there are socket problems.
IllegalArgumentException
- if the auth type is null
.public void setClearCommandChannel() throws FTPException, IOException
FTPException
- if the FTP server returns an error code.
IOException
protected void aboutToTransferData()
aboutToTransferData
in class FTP
protected void setControlSocket(Socket controlSocket, boolean saveInsecureSocket) throws IOException
controlSocket
- the control socket.saveInsecureSocket
- allow the old socket to be saved so CCC can
be used.
IOException
protected Socket makeControlSocket(HostInfo hostInfo) throws IOException
makeControlSocket
in class FTP
hostInfo
- a HostInfo
object that
describes where to make the socket.
IOException
- if there is a socket problem.protected Socket makeDataSocket(HostInfo hostInfo) throws IOException
makeDataSocket
in class FTP
hostInfo
- a HostInfo
object that
describes where to make the socket.
IOException
- if there is a socket problem.protected ServerSocket makeDataServerSocket(HostInfo hostInfo) throws IOException
makeDataServerSocket
in class FTP
hostInfo
- a HostInfo
object that
describes where to make the socket.
IOException
- if there is a socket problem.protected FTPCommand makeFTPCommand(BufferedReader inputReader, PrintWriter outputWriter)
FTPCommand
object.
makeFTPCommand
in class FTP
inputReader
- the BufferedReader
comes from
the input stream of the control socket.outputWriter
- the PrintWriter
comes from
the output stream of the control socket.
FTPCommand
object.public void logout() throws IOException, FTPException
logout
in class FTP
IOException
- if there is a socket problem.
FTPException
- if the FTP server returns an error code.public boolean isDataEncryptionOn()
public void forceDataEncryptionOn(boolean on) throws FTPException
on
- true if data encrytion is to be on, false if off.
FTPException
- if the FTP server returns an error code.public void setDataEncryptionOn(boolean on) throws FTPException
on
- true if data encrytion is to be on, false if off.
FTPException
- if the FTP server returns an error code.public String getAuthType()
AUTH
type we are sending during the AUTH command.
AUTH
type (e.g. SSL).SSLFTPCommand.auth(String)
public void setAuthType(String authType)
AUTH
type to be set from SSL to
some other type (such as TLS).
authType
- the AUTH
type to send during the AUTH command.SSLFTPCommand.auth(String)
public static void preSeed()
SecureRandom
object to be generated prior
to being used. This object takes a significant amount of time to be
generated and it is advised that this call be done on program
initialization. It is threaded for performance.
SecureRandom
public static ArrayList getCertificates(File keyStoreFile, String keyStorePass)
SSLCertificate
objects to be returned
from the KeyStore
.
SSLCertificate
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |