SessionData.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. //---------------------------------------------------------------------------
  2. #ifndef SessionDataH
  3. #define SessionDataH
  4. #include "Common.h"
  5. #include "Option.h"
  6. #include "FileBuffer.h"
  7. #include "NamedObjs.h"
  8. #include "HierarchicalStorage.h"
  9. #include "Configuration.h"
  10. #include <Xml.XMLIntf.hpp>
  11. //---------------------------------------------------------------------------
  12. #define SET_SESSION_PROPERTY(Property) \
  13. if (F##Property != value) { F##Property = value; Modify(); }
  14. //---------------------------------------------------------------------------
  15. enum TCipher { cipWarn, cip3DES, cipBlowfish, cipAES, cipDES, cipArcfour, cipChaCha20 };
  16. #define CIPHER_COUNT (cipChaCha20+1)
  17. // explicit values to skip obsoleted fsExternalSSH, fsExternalSFTP
  18. enum TFSProtocol { fsSCPonly = 0, fsSFTP = 1, fsSFTPonly = 2, fsFTP = 5, fsWebDAV = 6 };
  19. #define FSPROTOCOL_COUNT (fsWebDAV+1)
  20. extern const wchar_t * ProxyMethodNames;
  21. enum TProxyMethod { pmNone, pmSocks4, pmSocks5, pmHTTP, pmTelnet, pmCmd };
  22. enum TSshProt { ssh1only, ssh1, ssh2, ssh2only };
  23. enum TKex { kexWarn, kexDHGroup1, kexDHGroup14, kexDHGEx, kexRSA, kexECDH };
  24. #define KEX_COUNT (kexECDH+1)
  25. enum TSshBug { sbIgnore1, sbPlainPW1, sbRSA1, sbHMAC2, sbDeriveKey2, sbRSAPad2,
  26. sbPKSessID2, sbRekey2, sbMaxPkt2, sbIgnore2, sbOldGex2, sbWinAdj };
  27. #define BUG_COUNT (sbWinAdj+1)
  28. enum TSftpBug { sbSymlink, sbSignedTS };
  29. #define SFTP_BUG_COUNT (sbSignedTS+1)
  30. extern const wchar_t * PingTypeNames;
  31. enum TPingType { ptOff, ptNullPacket, ptDummyCommand };
  32. enum TAddressFamily { afAuto, afIPv4, afIPv6 };
  33. enum TFtps { ftpsNone, ftpsImplicit, ftpsExplicitSsl, ftpsExplicitTls };
  34. // has to match SSL_VERSION_XXX constants in AsyncSslSocketLayer.h
  35. enum TTlsVersion { ssl2 = 2, ssl3 = 3, tls10 = 10, tls11 = 11, tls12 = 12 };
  36. enum TSessionSource { ssNone, ssStored, ssStoredModified };
  37. enum TSessionUrlFlags
  38. {
  39. sufSpecific = 0x01,
  40. sufUserName = 0x02,
  41. sufPassword = 0x04,
  42. sufHostKey = 0x08,
  43. sufComplete = sufUserName | sufPassword | sufHostKey,
  44. sufOpen = sufUserName | sufPassword
  45. };
  46. //---------------------------------------------------------------------------
  47. extern const UnicodeString CipherNames[CIPHER_COUNT];
  48. extern const UnicodeString KexNames[KEX_COUNT];
  49. extern const wchar_t SshProtList[][10];
  50. extern const TCipher DefaultCipherList[CIPHER_COUNT];
  51. extern const TKex DefaultKexList[KEX_COUNT];
  52. extern const wchar_t FSProtocolNames[FSPROTOCOL_COUNT][16];
  53. extern const int DefaultSendBuf;
  54. extern const UnicodeString AnonymousUserName;
  55. extern const UnicodeString AnonymousPassword;
  56. extern const int SshPortNumber;
  57. extern const int FtpPortNumber;
  58. extern const int FtpsImplicitPortNumber;
  59. extern const int HTTPPortNumber;
  60. extern const int HTTPSPortNumber;
  61. extern const int TelnetPortNumber;
  62. extern const int ProxyPortNumber;
  63. extern const UnicodeString PuttySshProtocol;
  64. extern const UnicodeString PuttyTelnetProtocol;
  65. extern const UnicodeString SftpProtocol;
  66. extern const UnicodeString ScpProtocol;
  67. extern const UnicodeString FtpProtocol;
  68. extern const UnicodeString FtpsProtocol;
  69. extern const UnicodeString FtpesProtocol;
  70. #define WebDAVProtocol HttpProtocol
  71. #define WebDAVSProtocol HttpsProtocol
  72. extern const UnicodeString SshProtocol;
  73. extern const UnicodeString WinSCPProtocolPrefix;
  74. extern const wchar_t UrlParamSeparator;
  75. extern const wchar_t UrlParamValueSeparator;
  76. extern const UnicodeString UrlHostKeyParamName;
  77. extern const UnicodeString UrlSaveParamName;
  78. extern const UnicodeString PassphraseOption;
  79. //---------------------------------------------------------------------------
  80. class TStoredSessionList;
  81. //---------------------------------------------------------------------------
  82. class TSessionData : public TNamedObject
  83. {
  84. friend class TStoredSessionList;
  85. private:
  86. UnicodeString FHostName;
  87. int FPortNumber;
  88. UnicodeString FUserName;
  89. RawByteString FPassword;
  90. int FPingInterval;
  91. TPingType FPingType;
  92. bool FTryAgent;
  93. bool FAgentFwd;
  94. UnicodeString FListingCommand;
  95. bool FAuthTIS;
  96. bool FAuthKI;
  97. bool FAuthKIPassword;
  98. bool FAuthGSSAPI;
  99. bool FGSSAPIFwdTGT; // not supported anymore
  100. UnicodeString FGSSAPIServerRealm; // not supported anymore
  101. bool FChangeUsername;
  102. bool FCompression;
  103. TSshProt FSshProt;
  104. bool FSsh2DES;
  105. bool FSshNoUserAuth;
  106. TCipher FCiphers[CIPHER_COUNT];
  107. TKex FKex[KEX_COUNT];
  108. bool FClearAliases;
  109. TEOLType FEOLType;
  110. bool FTrimVMSVersions;
  111. UnicodeString FPublicKeyFile;
  112. UnicodeString FPassphrase;
  113. UnicodeString FPuttyProtocol;
  114. TFSProtocol FFSProtocol;
  115. bool FModified;
  116. UnicodeString FLocalDirectory;
  117. UnicodeString FRemoteDirectory;
  118. bool FLockInHome;
  119. bool FSpecial;
  120. bool FSynchronizeBrowsing;
  121. bool FUpdateDirectories;
  122. bool FCacheDirectories;
  123. bool FCacheDirectoryChanges;
  124. bool FPreserveDirectoryChanges;
  125. bool FSelected;
  126. TAutoSwitch FLookupUserGroups;
  127. UnicodeString FReturnVar;
  128. bool FScp1Compatibility;
  129. UnicodeString FShell;
  130. UnicodeString FSftpServer;
  131. int FTimeout;
  132. bool FUnsetNationalVars;
  133. bool FIgnoreLsWarnings;
  134. bool FTcpNoDelay;
  135. int FSendBuf;
  136. bool FSshSimple;
  137. TProxyMethod FProxyMethod;
  138. UnicodeString FProxyHost;
  139. int FProxyPort;
  140. UnicodeString FProxyUsername;
  141. RawByteString FProxyPassword;
  142. UnicodeString FProxyTelnetCommand;
  143. UnicodeString FProxyLocalCommand;
  144. TAutoSwitch FProxyDNS;
  145. bool FProxyLocalhost;
  146. int FFtpProxyLogonType;
  147. TAutoSwitch FBugs[BUG_COUNT];
  148. UnicodeString FCustomParam1;
  149. UnicodeString FCustomParam2;
  150. bool FResolveSymlinks;
  151. TDateTime FTimeDifference;
  152. bool FTimeDifferenceAuto;
  153. int FSFTPDownloadQueue;
  154. int FSFTPUploadQueue;
  155. int FSFTPListingQueue;
  156. int FSFTPMaxVersion;
  157. unsigned long FSFTPMaxPacketSize;
  158. TDSTMode FDSTMode;
  159. TAutoSwitch FSFTPBugs[SFTP_BUG_COUNT];
  160. bool FDeleteToRecycleBin;
  161. bool FOverwrittenToRecycleBin;
  162. UnicodeString FRecycleBinPath;
  163. UnicodeString FPostLoginCommands;
  164. TAutoSwitch FSCPLsFullTime;
  165. TAutoSwitch FFtpListAll;
  166. TAutoSwitch FFtpHost;
  167. bool FSslSessionReuse;
  168. UnicodeString FTlsCertificateFile;
  169. TAddressFamily FAddressFamily;
  170. UnicodeString FRekeyData;
  171. unsigned int FRekeyTime;
  172. int FColor;
  173. bool FTunnel;
  174. UnicodeString FTunnelHostName;
  175. int FTunnelPortNumber;
  176. UnicodeString FTunnelUserName;
  177. RawByteString FTunnelPassword;
  178. UnicodeString FTunnelPublicKeyFile;
  179. int FTunnelLocalPortNumber;
  180. UnicodeString FTunnelPortFwd;
  181. UnicodeString FTunnelHostKey;
  182. bool FFtpPasvMode;
  183. TAutoSwitch FFtpForcePasvIp;
  184. TAutoSwitch FFtpUseMlsd;
  185. UnicodeString FFtpAccount;
  186. int FFtpPingInterval;
  187. TPingType FFtpPingType;
  188. TAutoSwitch FFtpTransferActiveImmediately;
  189. TFtps FFtps;
  190. TTlsVersion FMinTlsVersion;
  191. TTlsVersion FMaxTlsVersion;
  192. TAutoSwitch FNotUtf;
  193. bool FIsWorkspace;
  194. UnicodeString FLink;
  195. UnicodeString FHostKey;
  196. bool FFingerprintScan;
  197. bool FOverrideCachedHostKey;
  198. UnicodeString FNote;
  199. UnicodeString FOrigHostName;
  200. int FOrigPortNumber;
  201. TProxyMethod FOrigProxyMethod;
  202. TSessionSource FSource;
  203. bool FSaveOnly;
  204. void __fastcall SetHostName(UnicodeString value);
  205. UnicodeString __fastcall GetHostNameExpanded();
  206. void __fastcall SetPortNumber(int value);
  207. void __fastcall SetUserName(UnicodeString value);
  208. UnicodeString __fastcall GetUserNameExpanded();
  209. void __fastcall SetPassword(UnicodeString value);
  210. UnicodeString __fastcall GetPassword() const;
  211. void __fastcall SetPingInterval(int value);
  212. void __fastcall SetTryAgent(bool value);
  213. void __fastcall SetAgentFwd(bool value);
  214. void __fastcall SetAuthTIS(bool value);
  215. void __fastcall SetAuthKI(bool value);
  216. void __fastcall SetAuthKIPassword(bool value);
  217. void __fastcall SetAuthGSSAPI(bool value);
  218. void __fastcall SetGSSAPIFwdTGT(bool value);
  219. void __fastcall SetGSSAPIServerRealm(UnicodeString value);
  220. void __fastcall SetChangeUsername(bool value);
  221. void __fastcall SetCompression(bool value);
  222. void __fastcall SetSshProt(TSshProt value);
  223. void __fastcall SetSsh2DES(bool value);
  224. void __fastcall SetSshNoUserAuth(bool value);
  225. void __fastcall SetCipher(int Index, TCipher value);
  226. TCipher __fastcall GetCipher(int Index) const;
  227. void __fastcall SetKex(int Index, TKex value);
  228. TKex __fastcall GetKex(int Index) const;
  229. void __fastcall SetPublicKeyFile(UnicodeString value);
  230. UnicodeString __fastcall GetPassphrase() const;
  231. void __fastcall SetPassphrase(UnicodeString value);
  232. void __fastcall SetPuttyProtocol(UnicodeString value);
  233. bool __fastcall GetCanLogin();
  234. void __fastcall SetPingIntervalDT(TDateTime value);
  235. TDateTime __fastcall GetPingIntervalDT();
  236. TDateTime __fastcall GetFtpPingIntervalDT();
  237. void __fastcall SetTimeDifference(TDateTime value);
  238. void __fastcall SetTimeDifferenceAuto(bool value);
  239. void __fastcall SetPingType(TPingType value);
  240. UnicodeString __fastcall GetSessionName();
  241. bool __fastcall HasSessionName();
  242. UnicodeString __fastcall GetDefaultSessionName();
  243. UnicodeString __fastcall GetProtocolUrl();
  244. void __fastcall SetFSProtocol(TFSProtocol value);
  245. UnicodeString __fastcall GetFSProtocolStr();
  246. void __fastcall SetLocalDirectory(UnicodeString value);
  247. void __fastcall SetRemoteDirectory(UnicodeString value);
  248. void __fastcall SetSynchronizeBrowsing(bool value);
  249. void __fastcall SetUpdateDirectories(bool value);
  250. void __fastcall SetCacheDirectories(bool value);
  251. void __fastcall SetCacheDirectoryChanges(bool value);
  252. void __fastcall SetPreserveDirectoryChanges(bool value);
  253. void __fastcall SetLockInHome(bool value);
  254. void __fastcall SetSpecial(bool value);
  255. UnicodeString __fastcall GetInfoTip();
  256. bool __fastcall GetDefaultShell();
  257. void __fastcall SetDetectReturnVar(bool value);
  258. bool __fastcall GetDetectReturnVar();
  259. void __fastcall SetListingCommand(UnicodeString value);
  260. void __fastcall SetClearAliases(bool value);
  261. void __fastcall SetDefaultShell(bool value);
  262. void __fastcall SetEOLType(TEOLType value);
  263. void __fastcall SetTrimVMSVersions(bool value);
  264. void __fastcall SetLookupUserGroups(TAutoSwitch value);
  265. void __fastcall SetReturnVar(UnicodeString value);
  266. void __fastcall SetScp1Compatibility(bool value);
  267. void __fastcall SetShell(UnicodeString value);
  268. void __fastcall SetSftpServer(UnicodeString value);
  269. void __fastcall SetTimeout(int value);
  270. void __fastcall SetUnsetNationalVars(bool value);
  271. void __fastcall SetIgnoreLsWarnings(bool value);
  272. void __fastcall SetTcpNoDelay(bool value);
  273. void __fastcall SetSendBuf(int value);
  274. void __fastcall SetSshSimple(bool value);
  275. UnicodeString __fastcall GetSshProtStr();
  276. bool __fastcall GetUsesSsh();
  277. void __fastcall SetCipherList(UnicodeString value);
  278. UnicodeString __fastcall GetCipherList() const;
  279. void __fastcall SetKexList(UnicodeString value);
  280. UnicodeString __fastcall GetKexList() const;
  281. void __fastcall SetProxyMethod(TProxyMethod value);
  282. void __fastcall SetProxyHost(UnicodeString value);
  283. void __fastcall SetProxyPort(int value);
  284. void __fastcall SetProxyUsername(UnicodeString value);
  285. void __fastcall SetProxyPassword(UnicodeString value);
  286. void __fastcall SetProxyTelnetCommand(UnicodeString value);
  287. void __fastcall SetProxyLocalCommand(UnicodeString value);
  288. void __fastcall SetProxyDNS(TAutoSwitch value);
  289. void __fastcall SetProxyLocalhost(bool value);
  290. UnicodeString __fastcall GetProxyPassword() const;
  291. void __fastcall SetFtpProxyLogonType(int value);
  292. void __fastcall SetBug(TSshBug Bug, TAutoSwitch value);
  293. TAutoSwitch __fastcall GetBug(TSshBug Bug) const;
  294. UnicodeString __fastcall GetSessionKey();
  295. void __fastcall SetCustomParam1(UnicodeString value);
  296. void __fastcall SetCustomParam2(UnicodeString value);
  297. void __fastcall SetResolveSymlinks(bool value);
  298. void __fastcall SetSFTPDownloadQueue(int value);
  299. void __fastcall SetSFTPUploadQueue(int value);
  300. void __fastcall SetSFTPListingQueue(int value);
  301. void __fastcall SetSFTPMaxVersion(int value);
  302. void __fastcall SetSFTPMaxPacketSize(unsigned long value);
  303. void __fastcall SetSFTPBug(TSftpBug Bug, TAutoSwitch value);
  304. TAutoSwitch __fastcall GetSFTPBug(TSftpBug Bug) const;
  305. void __fastcall SetSCPLsFullTime(TAutoSwitch value);
  306. void __fastcall SetFtpListAll(TAutoSwitch value);
  307. void __fastcall SetFtpHost(TAutoSwitch value);
  308. void __fastcall SetSslSessionReuse(bool value);
  309. void __fastcall SetTlsCertificateFile(UnicodeString value);
  310. UnicodeString __fastcall GetStorageKey();
  311. UnicodeString __fastcall GetInternalStorageKey();
  312. UnicodeString __fastcall GetSiteKey();
  313. void __fastcall SetDSTMode(TDSTMode value);
  314. void __fastcall SetDeleteToRecycleBin(bool value);
  315. void __fastcall SetOverwrittenToRecycleBin(bool value);
  316. void __fastcall SetRecycleBinPath(UnicodeString value);
  317. void __fastcall SetPostLoginCommands(UnicodeString value);
  318. void __fastcall SetAddressFamily(TAddressFamily value);
  319. void __fastcall SetRekeyData(UnicodeString value);
  320. void __fastcall SetRekeyTime(unsigned int value);
  321. void __fastcall SetColor(int value);
  322. void __fastcall SetTunnel(bool value);
  323. void __fastcall SetTunnelHostName(UnicodeString value);
  324. void __fastcall SetTunnelPortNumber(int value);
  325. void __fastcall SetTunnelUserName(UnicodeString value);
  326. void __fastcall SetTunnelPassword(UnicodeString value);
  327. UnicodeString __fastcall GetTunnelPassword() const;
  328. void __fastcall SetTunnelPublicKeyFile(UnicodeString value);
  329. void __fastcall SetTunnelPortFwd(UnicodeString value);
  330. void __fastcall SetTunnelLocalPortNumber(int value);
  331. bool __fastcall GetTunnelAutoassignLocalPortNumber();
  332. void __fastcall SetTunnelHostKey(UnicodeString value);
  333. void __fastcall SetFtpPasvMode(bool value);
  334. void __fastcall SetFtpForcePasvIp(TAutoSwitch value);
  335. void __fastcall SetFtpUseMlsd(TAutoSwitch value);
  336. void __fastcall SetFtpAccount(UnicodeString value);
  337. void __fastcall SetFtpPingInterval(int value);
  338. void __fastcall SetFtpPingType(TPingType value);
  339. void __fastcall SetFtpTransferActiveImmediately(TAutoSwitch value);
  340. void __fastcall SetFtps(TFtps value);
  341. void __fastcall SetMinTlsVersion(TTlsVersion value);
  342. void __fastcall SetMaxTlsVersion(TTlsVersion value);
  343. void __fastcall SetNotUtf(TAutoSwitch value);
  344. void __fastcall SetIsWorkspace(bool value);
  345. void __fastcall SetLink(UnicodeString value);
  346. void __fastcall SetHostKey(UnicodeString value);
  347. void __fastcall SetNote(UnicodeString value);
  348. TDateTime __fastcall GetTimeoutDT();
  349. void __fastcall SavePasswords(THierarchicalStorage * Storage, bool PuttyExport, bool DoNotEncryptPasswords);
  350. UnicodeString __fastcall GetLocalName();
  351. UnicodeString __fastcall GetFolderName();
  352. void __fastcall Modify();
  353. UnicodeString __fastcall GetSource();
  354. void __fastcall DoLoad(THierarchicalStorage * Storage, bool & RewritePassword);
  355. void __fastcall DoSave(THierarchicalStorage * Storage,
  356. bool PuttyExport, const TSessionData * Default, bool DoNotEncryptPasswords);
  357. UnicodeString __fastcall ReadXmlNode(_di_IXMLNode Node, const UnicodeString & Name, const UnicodeString & Default);
  358. int __fastcall ReadXmlNode(_di_IXMLNode Node, const UnicodeString & Name, int Default);
  359. bool __fastcall IsSame(const TSessionData * Default, bool AdvancedOnly, TStrings * DifferentProperties);
  360. UnicodeString __fastcall GetNameWithoutHiddenPrefix();
  361. bool __fastcall HasStateData();
  362. void __fastcall CopyStateData(TSessionData * SourceData);
  363. void __fastcall CopyNonCoreData(TSessionData * SourceData);
  364. UnicodeString __fastcall GetNormalizedPuttyProtocol() const;
  365. static RawByteString __fastcall EncryptPassword(const UnicodeString & Password, UnicodeString Key);
  366. static UnicodeString __fastcall DecryptPassword(const RawByteString & Password, UnicodeString Key);
  367. static RawByteString __fastcall StronglyRecryptPassword(const RawByteString & Password, UnicodeString Key);
  368. static bool __fastcall DoIsProtocolUrl(const UnicodeString & Url, const UnicodeString & Protocol, int & ProtocolLen);
  369. static bool __fastcall IsProtocolUrl(const UnicodeString & Url, const UnicodeString & Protocol, int & ProtocolLen);
  370. static void __fastcall AddSwitch(UnicodeString & Result, const UnicodeString & Name);
  371. static void __fastcall AddSwitch(UnicodeString & Result, const UnicodeString & Name, const UnicodeString & Value);
  372. static void __fastcall AddSwitch(UnicodeString & Result, const UnicodeString & Name, int Value);
  373. static void __fastcall AddAssemblyProperty(
  374. UnicodeString & Result, TAssemblyLanguage Language,
  375. const UnicodeString & Name, const UnicodeString & Value);
  376. static void __fastcall AddAssemblyProperty(
  377. UnicodeString & Result, TAssemblyLanguage Language,
  378. const UnicodeString & Name, const UnicodeString & Type,
  379. const UnicodeString & Member);
  380. static void __fastcall AddAssemblyProperty(
  381. UnicodeString & Result, TAssemblyLanguage Language,
  382. const UnicodeString & Name, int Value);
  383. void __fastcall AddAssemblyProperty(
  384. UnicodeString & Result, TAssemblyLanguage Language,
  385. const UnicodeString & Name, bool Value);
  386. TStrings * __fastcall SaveToOptions(const TSessionData * Default);
  387. template<class AlgoT>
  388. void __fastcall SetAlgoList(AlgoT * List, const AlgoT * DefaultList, const UnicodeString * Names,
  389. int Count, AlgoT WarnAlgo, UnicodeString value);
  390. __property UnicodeString InternalStorageKey = { read = GetInternalStorageKey };
  391. public:
  392. __fastcall TSessionData(UnicodeString aName);
  393. virtual __fastcall ~TSessionData();
  394. TSessionData * __fastcall Clone();
  395. void __fastcall Default();
  396. void __fastcall NonPersistant();
  397. void __fastcall Load(THierarchicalStorage * Storage);
  398. void __fastcall ApplyRawSettings(THierarchicalStorage * Storage);
  399. void __fastcall ImportFromFilezilla(_di_IXMLNode Node, const UnicodeString & Path);
  400. void __fastcall Save(THierarchicalStorage * Storage, bool PuttyExport,
  401. const TSessionData * Default = NULL);
  402. void __fastcall SaveRecryptedPasswords(THierarchicalStorage * Storage);
  403. void __fastcall RecryptPasswords();
  404. bool __fastcall HasPassword();
  405. bool __fastcall HasAnySessionPassword();
  406. bool __fastcall HasAnyPassword();
  407. void __fastcall ClearSessionPasswords();
  408. void __fastcall Remove();
  409. void __fastcall CacheHostKeyIfNotCached();
  410. virtual void __fastcall Assign(TPersistent * Source);
  411. virtual int __fastcall Compare(TNamedObject * Other);
  412. void __fastcall CopyData(TSessionData * Source);
  413. void __fastcall CopyDirectoriesStateData(TSessionData * SourceData);
  414. bool __fastcall ParseUrl(UnicodeString Url, TOptions * Options,
  415. TStoredSessionList * StoredSessions, bool & DefaultsOnly,
  416. UnicodeString * FileName, bool * AProtocolDefined, UnicodeString * MaskedUrl);
  417. bool __fastcall ParseOptions(TOptions * Options);
  418. void __fastcall ConfigureTunnel(int PortNumber);
  419. void __fastcall RollbackTunnel();
  420. void __fastcall ExpandEnvironmentVariables();
  421. bool __fastcall IsSame(const TSessionData * Default, bool AdvancedOnly);
  422. bool __fastcall IsSameSite(const TSessionData * Default);
  423. bool __fastcall IsInFolderOrWorkspace(UnicodeString Name);
  424. UnicodeString __fastcall GenerateSessionUrl(unsigned int Flags);
  425. UnicodeString __fastcall GenerateOpenCommandArgs();
  426. void __fastcall GenerateAssemblyCode(TAssemblyLanguage Language, UnicodeString & Head, UnicodeString & Tail, int & Indent);
  427. void __fastcall LookupLastFingerprint();
  428. bool __fastcall IsSecure();
  429. static void __fastcall ValidatePath(const UnicodeString Path);
  430. static void __fastcall ValidateName(const UnicodeString Name);
  431. static UnicodeString __fastcall MakeValidName(const UnicodeString & Name);
  432. static UnicodeString __fastcall ExtractLocalName(const UnicodeString & Name);
  433. static UnicodeString __fastcall ExtractFolderName(const UnicodeString & Name);
  434. static UnicodeString __fastcall ComposePath(const UnicodeString & Path, const UnicodeString & Name);
  435. static bool __fastcall IsSensitiveOption(const UnicodeString & Option);
  436. static UnicodeString __fastcall FormatSiteKey(const UnicodeString & HostName, int PortNumber);
  437. __property UnicodeString HostName = { read=FHostName, write=SetHostName };
  438. __property UnicodeString HostNameExpanded = { read=GetHostNameExpanded };
  439. __property int PortNumber = { read=FPortNumber, write=SetPortNumber };
  440. __property UnicodeString UserName = { read=FUserName, write=SetUserName };
  441. __property UnicodeString UserNameExpanded = { read=GetUserNameExpanded };
  442. __property UnicodeString Password = { read=GetPassword, write=SetPassword };
  443. __property int PingInterval = { read=FPingInterval, write=SetPingInterval };
  444. __property bool TryAgent = { read=FTryAgent, write=SetTryAgent };
  445. __property bool AgentFwd = { read=FAgentFwd, write=SetAgentFwd };
  446. __property UnicodeString ListingCommand = { read = FListingCommand, write = SetListingCommand };
  447. __property bool AuthTIS = { read=FAuthTIS, write=SetAuthTIS };
  448. __property bool AuthKI = { read=FAuthKI, write=SetAuthKI };
  449. __property bool AuthKIPassword = { read=FAuthKIPassword, write=SetAuthKIPassword };
  450. __property bool AuthGSSAPI = { read=FAuthGSSAPI, write=SetAuthGSSAPI };
  451. __property bool GSSAPIFwdTGT = { read=FGSSAPIFwdTGT, write=SetGSSAPIFwdTGT };
  452. __property UnicodeString GSSAPIServerRealm = { read=FGSSAPIServerRealm, write=SetGSSAPIServerRealm };
  453. __property bool ChangeUsername = { read=FChangeUsername, write=SetChangeUsername };
  454. __property bool Compression = { read=FCompression, write=SetCompression };
  455. __property TSshProt SshProt = { read=FSshProt, write=SetSshProt };
  456. __property bool UsesSsh = { read = GetUsesSsh };
  457. __property bool Ssh2DES = { read=FSsh2DES, write=SetSsh2DES };
  458. __property bool SshNoUserAuth = { read=FSshNoUserAuth, write=SetSshNoUserAuth };
  459. __property TCipher Cipher[int Index] = { read=GetCipher, write=SetCipher };
  460. __property TKex Kex[int Index] = { read=GetKex, write=SetKex };
  461. __property UnicodeString PublicKeyFile = { read=FPublicKeyFile, write=SetPublicKeyFile };
  462. __property UnicodeString Passphrase = { read=GetPassphrase, write=SetPassphrase };
  463. __property UnicodeString PuttyProtocol = { read=FPuttyProtocol, write=SetPuttyProtocol };
  464. __property TFSProtocol FSProtocol = { read=FFSProtocol, write=SetFSProtocol };
  465. __property UnicodeString FSProtocolStr = { read=GetFSProtocolStr };
  466. __property bool Modified = { read=FModified, write=FModified };
  467. __property bool CanLogin = { read=GetCanLogin };
  468. __property bool ClearAliases = { read = FClearAliases, write = SetClearAliases };
  469. __property TDateTime PingIntervalDT = { read = GetPingIntervalDT, write = SetPingIntervalDT };
  470. __property TDateTime TimeDifference = { read = FTimeDifference, write = SetTimeDifference };
  471. __property bool TimeDifferenceAuto = { read = FTimeDifferenceAuto, write = SetTimeDifferenceAuto };
  472. __property TPingType PingType = { read = FPingType, write = SetPingType };
  473. __property UnicodeString SessionName = { read=GetSessionName };
  474. __property UnicodeString DefaultSessionName = { read=GetDefaultSessionName };
  475. __property UnicodeString LocalDirectory = { read=FLocalDirectory, write=SetLocalDirectory };
  476. __property UnicodeString RemoteDirectory = { read=FRemoteDirectory, write=SetRemoteDirectory };
  477. __property bool SynchronizeBrowsing = { read=FSynchronizeBrowsing, write=SetSynchronizeBrowsing };
  478. __property bool UpdateDirectories = { read=FUpdateDirectories, write=SetUpdateDirectories };
  479. __property bool CacheDirectories = { read=FCacheDirectories, write=SetCacheDirectories };
  480. __property bool CacheDirectoryChanges = { read=FCacheDirectoryChanges, write=SetCacheDirectoryChanges };
  481. __property bool PreserveDirectoryChanges = { read=FPreserveDirectoryChanges, write=SetPreserveDirectoryChanges };
  482. __property bool LockInHome = { read=FLockInHome, write=SetLockInHome };
  483. __property bool Special = { read=FSpecial, write=SetSpecial };
  484. __property bool Selected = { read=FSelected, write=FSelected };
  485. __property UnicodeString InfoTip = { read=GetInfoTip };
  486. __property bool DefaultShell = { read = GetDefaultShell, write = SetDefaultShell };
  487. __property bool DetectReturnVar = { read = GetDetectReturnVar, write = SetDetectReturnVar };
  488. __property TEOLType EOLType = { read = FEOLType, write = SetEOLType };
  489. __property bool TrimVMSVersions = { read = FTrimVMSVersions, write = SetTrimVMSVersions };
  490. __property TAutoSwitch LookupUserGroups = { read = FLookupUserGroups, write = SetLookupUserGroups };
  491. __property UnicodeString ReturnVar = { read = FReturnVar, write = SetReturnVar };
  492. __property bool Scp1Compatibility = { read = FScp1Compatibility, write = SetScp1Compatibility };
  493. __property UnicodeString Shell = { read = FShell, write = SetShell };
  494. __property UnicodeString SftpServer = { read = FSftpServer, write = SetSftpServer };
  495. __property int Timeout = { read = FTimeout, write = SetTimeout };
  496. __property TDateTime TimeoutDT = { read = GetTimeoutDT };
  497. __property bool UnsetNationalVars = { read = FUnsetNationalVars, write = SetUnsetNationalVars };
  498. __property bool IgnoreLsWarnings = { read=FIgnoreLsWarnings, write=SetIgnoreLsWarnings };
  499. __property bool TcpNoDelay = { read=FTcpNoDelay, write=SetTcpNoDelay };
  500. __property int SendBuf = { read=FSendBuf, write=SetSendBuf };
  501. __property bool SshSimple = { read=FSshSimple, write=SetSshSimple };
  502. __property UnicodeString SshProtStr = { read=GetSshProtStr };
  503. __property UnicodeString CipherList = { read=GetCipherList, write=SetCipherList };
  504. __property UnicodeString KexList = { read=GetKexList, write=SetKexList };
  505. __property TProxyMethod ProxyMethod = { read=FProxyMethod, write=SetProxyMethod };
  506. __property UnicodeString ProxyHost = { read=FProxyHost, write=SetProxyHost };
  507. __property int ProxyPort = { read=FProxyPort, write=SetProxyPort };
  508. __property UnicodeString ProxyUsername = { read=FProxyUsername, write=SetProxyUsername };
  509. __property UnicodeString ProxyPassword = { read=GetProxyPassword, write=SetProxyPassword };
  510. __property UnicodeString ProxyTelnetCommand = { read=FProxyTelnetCommand, write=SetProxyTelnetCommand };
  511. __property UnicodeString ProxyLocalCommand = { read=FProxyLocalCommand, write=SetProxyLocalCommand };
  512. __property TAutoSwitch ProxyDNS = { read=FProxyDNS, write=SetProxyDNS };
  513. __property bool ProxyLocalhost = { read=FProxyLocalhost, write=SetProxyLocalhost };
  514. __property int FtpProxyLogonType = { read=FFtpProxyLogonType, write=SetFtpProxyLogonType };
  515. __property TAutoSwitch Bug[TSshBug Bug] = { read=GetBug, write=SetBug };
  516. __property UnicodeString CustomParam1 = { read = FCustomParam1, write = SetCustomParam1 };
  517. __property UnicodeString CustomParam2 = { read = FCustomParam2, write = SetCustomParam2 };
  518. __property UnicodeString SessionKey = { read = GetSessionKey };
  519. __property bool ResolveSymlinks = { read = FResolveSymlinks, write = SetResolveSymlinks };
  520. __property int SFTPDownloadQueue = { read = FSFTPDownloadQueue, write = SetSFTPDownloadQueue };
  521. __property int SFTPUploadQueue = { read = FSFTPUploadQueue, write = SetSFTPUploadQueue };
  522. __property int SFTPListingQueue = { read = FSFTPListingQueue, write = SetSFTPListingQueue };
  523. __property int SFTPMaxVersion = { read = FSFTPMaxVersion, write = SetSFTPMaxVersion };
  524. __property unsigned long SFTPMaxPacketSize = { read = FSFTPMaxPacketSize, write = SetSFTPMaxPacketSize };
  525. __property TAutoSwitch SFTPBug[TSftpBug Bug] = { read=GetSFTPBug, write=SetSFTPBug };
  526. __property TAutoSwitch SCPLsFullTime = { read = FSCPLsFullTime, write = SetSCPLsFullTime };
  527. __property TAutoSwitch FtpListAll = { read = FFtpListAll, write = SetFtpListAll };
  528. __property TAutoSwitch FtpHost = { read = FFtpHost, write = SetFtpHost };
  529. __property bool SslSessionReuse = { read = FSslSessionReuse, write = SetSslSessionReuse };
  530. __property UnicodeString TlsCertificateFile = { read=FTlsCertificateFile, write=SetTlsCertificateFile };
  531. __property TDSTMode DSTMode = { read = FDSTMode, write = SetDSTMode };
  532. __property bool DeleteToRecycleBin = { read = FDeleteToRecycleBin, write = SetDeleteToRecycleBin };
  533. __property bool OverwrittenToRecycleBin = { read = FOverwrittenToRecycleBin, write = SetOverwrittenToRecycleBin };
  534. __property UnicodeString RecycleBinPath = { read = FRecycleBinPath, write = SetRecycleBinPath };
  535. __property UnicodeString PostLoginCommands = { read = FPostLoginCommands, write = SetPostLoginCommands };
  536. __property TAddressFamily AddressFamily = { read = FAddressFamily, write = SetAddressFamily };
  537. __property UnicodeString RekeyData = { read = FRekeyData, write = SetRekeyData };
  538. __property unsigned int RekeyTime = { read = FRekeyTime, write = SetRekeyTime };
  539. __property int Color = { read = FColor, write = SetColor };
  540. __property bool Tunnel = { read = FTunnel, write = SetTunnel };
  541. __property UnicodeString TunnelHostName = { read = FTunnelHostName, write = SetTunnelHostName };
  542. __property int TunnelPortNumber = { read = FTunnelPortNumber, write = SetTunnelPortNumber };
  543. __property UnicodeString TunnelUserName = { read = FTunnelUserName, write = SetTunnelUserName };
  544. __property UnicodeString TunnelPassword = { read = GetTunnelPassword, write = SetTunnelPassword };
  545. __property UnicodeString TunnelPublicKeyFile = { read = FTunnelPublicKeyFile, write = SetTunnelPublicKeyFile };
  546. __property bool TunnelAutoassignLocalPortNumber = { read = GetTunnelAutoassignLocalPortNumber };
  547. __property int TunnelLocalPortNumber = { read = FTunnelLocalPortNumber, write = SetTunnelLocalPortNumber };
  548. __property UnicodeString TunnelPortFwd = { read = FTunnelPortFwd, write = SetTunnelPortFwd };
  549. __property UnicodeString TunnelHostKey = { read = FTunnelHostKey, write = SetTunnelHostKey };
  550. __property bool FtpPasvMode = { read = FFtpPasvMode, write = SetFtpPasvMode };
  551. __property TAutoSwitch FtpForcePasvIp = { read = FFtpForcePasvIp, write = SetFtpForcePasvIp };
  552. __property TAutoSwitch FtpUseMlsd = { read = FFtpUseMlsd, write = SetFtpUseMlsd };
  553. __property UnicodeString FtpAccount = { read = FFtpAccount, write = SetFtpAccount };
  554. __property int FtpPingInterval = { read=FFtpPingInterval, write=SetFtpPingInterval };
  555. __property TDateTime FtpPingIntervalDT = { read=GetFtpPingIntervalDT };
  556. __property TPingType FtpPingType = { read = FFtpPingType, write = SetFtpPingType };
  557. __property TAutoSwitch FtpTransferActiveImmediately = { read = FFtpTransferActiveImmediately, write = SetFtpTransferActiveImmediately };
  558. __property TFtps Ftps = { read = FFtps, write = SetFtps };
  559. __property TTlsVersion MinTlsVersion = { read = FMinTlsVersion, write = SetMinTlsVersion };
  560. __property TTlsVersion MaxTlsVersion = { read = FMaxTlsVersion, write = SetMaxTlsVersion };
  561. __property TAutoSwitch NotUtf = { read = FNotUtf, write = SetNotUtf };
  562. __property bool IsWorkspace = { read = FIsWorkspace, write = SetIsWorkspace };
  563. __property UnicodeString Link = { read = FLink, write = SetLink };
  564. __property UnicodeString HostKey = { read = FHostKey, write = SetHostKey };
  565. __property bool FingerprintScan = { read = FFingerprintScan, write = FFingerprintScan };
  566. __property bool OverrideCachedHostKey = { read = FOverrideCachedHostKey };
  567. __property UnicodeString Note = { read = FNote, write = SetNote };
  568. __property UnicodeString StorageKey = { read = GetStorageKey };
  569. __property UnicodeString SiteKey = { read = GetSiteKey };
  570. __property UnicodeString OrigHostName = { read = FOrigHostName };
  571. __property int OrigPortNumber = { read = FOrigPortNumber };
  572. __property UnicodeString LocalName = { read = GetLocalName };
  573. __property UnicodeString FolderName = { read = GetFolderName };
  574. __property UnicodeString Source = { read = GetSource };
  575. __property bool SaveOnly = { read = FSaveOnly };
  576. };
  577. //---------------------------------------------------------------------------
  578. class TStoredSessionList : public TNamedObjectList
  579. {
  580. public:
  581. __fastcall TStoredSessionList(bool aReadOnly = false);
  582. void __fastcall Load();
  583. void __fastcall Save(bool All, bool Explicit);
  584. void __fastcall Saved();
  585. void __fastcall ImportFromFilezilla(const UnicodeString FileName);
  586. void __fastcall Export(const UnicodeString FileName);
  587. void __fastcall Load(THierarchicalStorage * Storage, bool AsModified = false,
  588. bool UseDefaults = false);
  589. void __fastcall Save(THierarchicalStorage * Storage, bool All = false);
  590. void __fastcall SelectAll(bool Select);
  591. void __fastcall Import(TStoredSessionList * From, bool OnlySelected, TList * Imported);
  592. void __fastcall RecryptPasswords(TStrings * RecryptPasswordErrors);
  593. TSessionData * __fastcall AtSession(int Index)
  594. { return (TSessionData*)AtObject(Index); }
  595. void __fastcall SelectSessionsToImport(TStoredSessionList * Dest, bool SSHOnly);
  596. void __fastcall Cleanup();
  597. void __fastcall UpdateStaticUsage();
  598. int __fastcall IndexOf(TSessionData * Data);
  599. TSessionData * __fastcall FindSame(TSessionData * Data);
  600. TSessionData * __fastcall NewSession(UnicodeString SessionName, TSessionData * Session);
  601. void __fastcall NewWorkspace(UnicodeString Name, TList * DataList);
  602. bool __fastcall IsFolder(const UnicodeString & Name);
  603. bool __fastcall IsWorkspace(const UnicodeString & Name);
  604. TSessionData * __fastcall ParseUrl(UnicodeString Url, TOptions * Options, bool & DefaultsOnly,
  605. UnicodeString * FileName = NULL, bool * ProtocolDefined = NULL, UnicodeString * MaskedUrl = NULL);
  606. bool __fastcall IsUrl(UnicodeString Url);
  607. bool __fastcall CanLogin(TSessionData * Data);
  608. void __fastcall GetFolderOrWorkspace(const UnicodeString & Name, TList * List);
  609. TStrings * __fastcall GetFolderOrWorkspaceList(const UnicodeString & Name);
  610. TStrings * __fastcall GetWorkspaces();
  611. bool __fastcall HasAnyWorkspace();
  612. TSessionData * __fastcall SaveWorkspaceData(TSessionData * Data);
  613. virtual __fastcall ~TStoredSessionList();
  614. __property TSessionData * Sessions[int Index] = { read=AtSession };
  615. __property TSessionData * DefaultSettings = { read=FDefaultSettings, write=SetDefaultSettings };
  616. static void __fastcall ImportHostKeys(const UnicodeString TargetKey,
  617. const UnicodeString SourceKey, TStoredSessionList * Sessions,
  618. bool OnlySelected);
  619. private:
  620. TSessionData * FDefaultSettings;
  621. bool FReadOnly;
  622. void __fastcall SetDefaultSettings(TSessionData * value);
  623. void __fastcall DoSave(THierarchicalStorage * Storage, bool All,
  624. bool RecryptPasswordOnly, TStrings * RecryptPasswordErrors);
  625. void __fastcall DoSave(bool All, bool Explicit, bool RecryptPasswordOnly,
  626. TStrings * RecryptPasswordErrors);
  627. void __fastcall DoSave(THierarchicalStorage * Storage,
  628. TSessionData * Data, bool All, bool RecryptPasswordOnly,
  629. TSessionData * FactoryDefaults);
  630. TSessionData * __fastcall ResolveWorkspaceData(TSessionData * Data);
  631. bool __fastcall IsFolderOrWorkspace(const UnicodeString & Name, bool Workspace);
  632. TSessionData * __fastcall CheckIsInFolderOrWorkspaceAndResolve(
  633. TSessionData * Data, const UnicodeString & Name);
  634. void __fastcall ImportLevelFromFilezilla(_di_IXMLNode Node, const UnicodeString & Path);
  635. };
  636. //---------------------------------------------------------------------------
  637. UnicodeString GetExpandedLogFileName(UnicodeString LogFileName, TSessionData * SessionData);
  638. bool __fastcall IsSshProtocol(TFSProtocol FSProtocol);
  639. int __fastcall DefaultPort(TFSProtocol FSProtocol, TFtps Ftps);
  640. //---------------------------------------------------------------------------
  641. #endif