1 | // |
2 | // FTPSClientSession.h |
3 | // |
4 | // Library: Net |
5 | // Package: FTP |
6 | // Module: FTPSClientSession |
7 | // |
8 | // Definition of the FTPSClientSession class. |
9 | // |
10 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef NetSSL_FTPSClientSession_INCLUDED |
18 | #define NetSSL_FTPSClientSession_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Net/NetSSL.h" |
22 | #include "Poco/Net/FTPClientSession.h" |
23 | |
24 | |
25 | namespace Poco { |
26 | namespace Net { |
27 | |
28 | |
29 | class NetSSL_API FTPSClientSession : |
30 | public Poco::Net::FTPClientSession |
31 | { |
32 | public: |
33 | FTPSClientSession(); |
34 | /// Creates an FTPSClientSession. |
35 | /// |
36 | /// Passive mode will be used for data transfers. |
37 | |
38 | explicit FTPSClientSession(const StreamSocket& socket); |
39 | /// Creates an FTPSClientSession using the given |
40 | /// connected socket for the control connection. |
41 | /// |
42 | /// Passive mode will be used for data transfers. |
43 | |
44 | FTPSClientSession(const std::string& host, |
45 | Poco::UInt16 port = FTP_PORT, |
46 | const std::string& username = "" , |
47 | const std::string& password = "" ); |
48 | /// Creates an FTPSClientSession using a socket connected |
49 | /// to the given host and port. If username is supplied, |
50 | /// login is attempted. |
51 | /// |
52 | /// Passive mode will be used for data transfers. |
53 | |
54 | virtual ~FTPSClientSession(); |
55 | |
56 | void tryFTPSmode(bool bTryFTPS); |
57 | /// avoid or require TLS mode |
58 | |
59 | bool isSecure() const; |
60 | /// Returns true if the session is FTPS. |
61 | |
62 | protected: |
63 | virtual StreamSocket establishDataConnection(const std::string& command, const std::string& arg); |
64 | /// Create secure data connection |
65 | |
66 | virtual void receiveServerReadyReply(); |
67 | /// Function that read server welcome message after connetion and set and make secure socket |
68 | |
69 | private: |
70 | bool _bTryFTPS = true; |
71 | |
72 | void beforeCreateDataSocket(); |
73 | ///Send commands to check if we can encrypt data socket |
74 | |
75 | void afterCreateControlSocket(); |
76 | ///Send commands to make SSL negotiating of control channel |
77 | |
78 | bool _bSecureDataConnection = false; |
79 | }; |
80 | |
81 | |
82 | // |
83 | // inlines |
84 | // |
85 | |
86 | inline bool FTPSClientSession::isSecure() const |
87 | { |
88 | if (_pControlSocket != nullptr) |
89 | return _pControlSocket->secure(); |
90 | return false; |
91 | } |
92 | |
93 | |
94 | }} // namespace Poco::Net |
95 | |
96 | |
97 | #endif // #define NetSSL_FTPSClientSession_INCLUDED |
98 | |