FTPClientSession read welcome message with external socket (#2335)

* FTPClientSession read welcome message with external socket

Add method to configure if the FTPClientSession should read welcome message from FTP server when you use external socket. Otherwise you could end up in a desyncronization of FTP commands

* FTPSClientSession constructor FTPS behavior

Add variable in constructor to let you enable or disable FTPS connection

* Get FTPSClientSession back from master

* Support UTF8 filename

Using UTF8 filename cause image loading funtion fail without a transcoding function

* FTP Add function to get welcome message

Add a function to get at application level the FTP Server welcome message

* removed FTPPasswordProvider from FTPSStreamFactory

Removed duplicate FTPPasswordProvider  class from FTPSStreamFactory

* Code Style corrections

No hungarian style
no indent nested namespace
rename mutex
This commit is contained in:
micheleselea
2018-07-10 15:58:16 +02:00
committed by Aleksandar Fabijanic
parent 3f1f6fa8e6
commit 9887e78b5e
9 changed files with 152 additions and 123 deletions

View File

@@ -23,75 +23,76 @@
namespace Poco {
namespace Net {
namespace Net {
class NetSSL_API FTPSClientSession :
public Poco::Net::FTPClientSession
{
public:
FTPSClientSession();
/// Creates an FTPSClientSession.
///
/// Passive mode will be used for data transfers.
class NetSSL_API FTPSClientSession :
public Poco::Net::FTPClientSession
{
public:
FTPSClientSession();
/// Creates an FTPSClientSession.
///
/// Passive mode will be used for data transfers.
explicit FTPSClientSession(const StreamSocket& socket);
/// Creates an FTPSClientSession using the given
/// connected socket for the control connection.
///
/// Passive mode will be used for data transfers.
explicit FTPSClientSession(const StreamSocket& socket, bool readWelcomeMessage = true, bool tryUseFTPS = true);
/// Creates an FTPSClientSession using the given
/// connected socket for the control connection.
///
/// Passive mode will be used for data transfers.
FTPSClientSession(const std::string& host,
Poco::UInt16 port = FTP_PORT,
const std::string& username = "",
const std::string& password = "");
/// Creates an FTPSClientSession using a socket connected
/// to the given host and port. If username is supplied,
/// login is attempted.
///
/// Passive mode will be used for data transfers.
FTPSClientSession(const std::string& host,
Poco::UInt16 port = FTP_PORT,
const std::string& username = "",
const std::string& password = "");
/// Creates an FTPSClientSession using a socket connected
/// to the given host and port. If username is supplied,
/// login is attempted.
///
/// Passive mode will be used for data transfers.
virtual ~FTPSClientSession();
virtual ~FTPSClientSession();
void tryFTPSmode(bool bTryFTPS);
/// avoid or require TLS mode
void tryFTPSmode(bool bTryFTPS);
/// avoid or require TLS mode
bool isSecure() const;
/// Returns true if the session is FTPS.
bool isSecure() const;
/// Returns true if the session is FTPS.
protected:
virtual StreamSocket establishDataConnection(const std::string& command, const std::string& arg);
/// Create secure data connection
protected:
virtual StreamSocket establishDataConnection(const std::string& command, const std::string& arg);
/// Create secure data connection
virtual void receiveServerReadyReply();
/// Function that read server welcome message after connetion and set and make secure socket
virtual void receiveServerReadyReply();
/// Function that read server welcome message after connetion and set and make secure socket
private:
bool _bTryFTPS = true;
private:
bool _tryFTPS = true;
void beforeCreateDataSocket();
///Send commands to check if we can encrypt data socket
void beforeCreateDataSocket();
///Send commands to check if we can encrypt data socket
void afterCreateControlSocket();
///Send commands to make SSL negotiating of control channel
void afterCreateControlSocket();
///Send commands to make SSL negotiating of control channel
bool _bSecureDataConnection = false;
};
bool _secureDataConnection = false;
};
//
// inlines
//
//
// inlines
//
inline bool FTPSClientSession::isSecure() const
{
if (_pControlSocket != nullptr)
return _pControlSocket->secure();
return false;
}
inline bool FTPSClientSession::isSecure() const
{
if (_pControlSocket != nullptr)
return _pControlSocket->secure();
return false;
}
}} // namespace Poco::Net
}
} // namespace Poco::Net
#endif // #define NetSSL_FTPSClientSession_INCLUDED
#endif // #define NetSSL_FTPSClientSession_INCLUDED