示例#1
0
        public static ConnectionInfo CreateConnectionInfo(this ISftpConnectionInfo info)
        {
            var authenticationMethods = new List <AuthenticationMethod>();

            if (!string.IsNullOrWhiteSpace(info.Password))
            {
                authenticationMethods.Add(new PasswordAuthenticationMethod(info.Login, info.Password));
            }
            if (!string.IsNullOrWhiteSpace(info.PrivateKey))
            {
                var privateKeyStream = info.PrivateKey.ToStream();
                if (string.IsNullOrWhiteSpace(info.PrivateKeyPassPhrase))
                {
                    authenticationMethods.Add(new PrivateKeyAuthenticationMethod(info.Login, new PrivateKeyFile(privateKeyStream)));
                }
                else
                {
                    authenticationMethods.Add(new PrivateKeyAuthenticationMethod(info.Login, new PrivateKeyFile(privateKeyStream, info.PrivateKeyPassPhrase)));
                }
            }
            return(new ConnectionInfo(
                       info.Server,
                       info.PortNumber,
                       info.Login,
                       authenticationMethods.ToArray()
                       ));
        }
示例#2
0
 public SftpFileValue(ISftpConnectionInfo connectionInfo, string folder, string fileName, string connectorCode, string connectionName, string connectorName)
     : base(new SftpFileValueMetadata
 {
     Server         = connectionInfo.Server,
     Folder         = folder,
     Name           = fileName,
     ConnectorCode  = connectorCode,
     ConnectionName = connectionName,
     ConnectorName  = connectorName
 }) => (Name, _folder, _connectionInfo) = (fileName, folder, connectionInfo);
示例#3
0
 public SftpFileValue(ISftpConnectionInfo connectionInfo, string folder, string fileName)
     : this(connectionInfo, folder, fileName, null, null, null)
 {
 }