Пример #1
0
        internal SessionOptions GetSessionOptions()
        {
            SessionOptions sessionOptions = new SessionOptions
            {
                Protocol   = (Protocol)Enum.Parse(typeof(Protocol), Protocol.ToString(), true),
                HostName   = HostName,
                UserName   = UserName,
                Password   = SecurityService.DecyptValue(Password),
                PortNumber = PortNumber
            };

            if (Protocol == WinSCPProtocol.Ftp)
            {
                sessionOptions.FtpSecure = (FtpSecure)Enum.Parse(typeof(FtpSecure), FtpSecure.ToString(), true);
                sessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate = AcceptAnyTlsHostCertificate;
            }
            else if (Protocol == WinSCPProtocol.SFtp)
            {
                sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey = AcceptAnySshHostKey;
                sessionOptions.SshHostKeyFingerprint = string.IsNullOrEmpty(SshHostKeyFingerprint) ? null : SshHostKeyFingerprint;
                sessionOptions.PrivateKeyPassphrase  = string.IsNullOrEmpty(SshPrivateKeyPassphrase) ? null : SecurityService.DecyptValue(SshPrivateKeyPassphrase);
                sessionOptions.SshPrivateKeyPath     = string.IsNullOrEmpty(SshPrivateKeyPath) ? null : SshPrivateKeyPath;
            }

            return(sessionOptions);
        }
Пример #2
0
 public override List <ProviderParameter> GetInitializationParameters()
 {
     return(new List <ProviderParameter>
     {
         new ProviderParameter("Path", Path, GetConfigKey("Path")),
         new ProviderParameter("FilterPattern", FilterPattern, GetConfigKey("FilterPattern")),
         new ProviderParameter("ModifiedSinceUTC", ModifiedSinceUTC, GetConfigKey("ModifiedSinceUTC")),
         new ProviderParameter("RecuirseFolders", RecuirseFolders.ToString(), GetConfigKey("RecuirseFolders")),
         new ProviderParameter("WebFriendlyPaths", WebFriendlyPaths.ToString(), GetConfigKey("WebFriendlyPaths")),
         new ProviderParameter("Protocol", Protocol.ToString(), GetConfigKey("Protocol")),
         new ProviderParameter("HostName", HostName, GetConfigKey("HostName")),
         new ProviderParameter("PortNumber", PortNumber.ToString(CultureInfo.InvariantCulture), GetConfigKey("HostName")),
         new ProviderParameter("UserName", UserName, GetConfigKey("UserName")),
         new ProviderParameter("Password", SecurityService.EncryptValue(Password), GetConfigKey("Password")),
         new ProviderParameter("FtpSecure", FtpSecure.ToString(), GetConfigKey("FtpSecure")),
         new ProviderParameter("AcceptAnyTlsHostCertificate", AcceptAnyTlsHostCertificate.ToString(CultureInfo.InvariantCulture), GetConfigKey("AcceptAnyTlsHostCertificate")),
         new ProviderParameter("AcceptAnySshHostKey", AcceptAnySshHostKey.ToString(CultureInfo.InvariantCulture), GetConfigKey("AcceptAnySshHostKey")),
         new ProviderParameter("SshHostKeyFingerprint", SshHostKeyFingerprint, GetConfigKey("SshHostKeyFingerprint")),
         new ProviderParameter("SshPrivateKeyPassphrase", SecurityService.EncryptValue(SshPrivateKeyPassphrase), GetConfigKey("SshPrivateKeyPassphrase")),
         new ProviderParameter("SshPrivateKeyPath", SshPrivateKeyPath, GetConfigKey("SshPrivateKeyPath"))
     });
 }