Inheritance: TCPParameter, ISSHLoginParameter
示例#1
0
 public void Serialize(SSHLoginParameter tp, StructuredText node)
 {
     base.Serialize(tp, node);
     if (tp.Method != SSHProtocol.SSH2)
     {
         node.Set("method", tp.Method.ToString());
     }
     if (tp.AuthenticationType != AuthenticationType.Password)
     {
         node.Set("authentication", tp.AuthenticationType.ToString());
     }
     node.Set("account", tp.Account);
     if (tp.IdentityFileName.Length > 0)
     {
         node.Set("identityFileName", tp.IdentityFileName);
     }
     if (tp.PasswordOrPassphrase != null)
     {
         if (ProtocolsPlugin.Instance.ProtocolOptions.SavePlainTextPassword)
         {
             node.Set("passphrase", tp.PasswordOrPassphrase);
         }
         else if (ProtocolsPlugin.Instance.ProtocolOptions.SavePassword)
         {
             string pw = new SimpleStringEncrypt().EncryptString(tp.PasswordOrPassphrase);
             if (pw != null)
             {
                 node.Set("password", pw);
             }
         }
     }
 }
示例#2
0
 public void Deserialize(SSHLoginParameter tp, StructuredText node)
 {
     base.Deserialize(tp, node);
     tp.Method             = "SSH1".Equals(node.Get("method")) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
     tp.AuthenticationType = ParseUtil.ParseEnum <AuthenticationType>(node.Get("authentication", ""), AuthenticationType.Password);
     tp.Account            = node.Get("account", "");
     tp.IdentityFileName   = node.Get("identityFileName", "");
     if (ProtocolsPlugin.Instance.ProtocolOptions.ReadSerializedPassword)
     {
         string pw = node.Get("passphrase", null);
         if (pw != null)
         {
             tp.PasswordOrPassphrase = pw;
             tp.LetUserInputPassword = false;
         }
         else
         {
             pw = node.Get("password", null);
             if (pw != null)
             {
                 pw = new SimpleStringEncrypt().DecryptString(pw);
                 if (pw != null)
                 {
                     tp.PasswordOrPassphrase = pw;
                     tp.LetUserInputPassword = false;
                 }
             }
         }
     }
 }
        public override object Deserialize(StructuredText node)
        {
            SSHLoginParameter t = new SSHLoginParameter();

            Deserialize(t, node);
            return(t);
        }
示例#4
0
 public SSHLoginParameter(SSHLoginParameter src)
     : base(src)
 {
     _method               = src._method;
     _authType             = src._authType;
     _account              = src._account;
     _identityFile         = src._identityFile;
     _passwordOrPassphrase = src._passwordOrPassphrase;
     _letUserInputPassword = src._letUserInputPassword;
     _agentForward         = src._agentForward;
 }
        public SSH2Session()
        {
            _SSHParms = new SSHLoginParameter();
            _SSHParms.Account = "root";
            _SSHParms.PasswordOrPassphrase = "Pasw0rd";
            _SSHParms.Destination = "192.168.2.1";
            _SSHParms.Port = 22;
            _SSHParms.AuthenticationType = Granados.AuthenticationType.Password;

            _instance =new  InternalPoderosaInstance();
            _terminal =_instance.NewTerminal(ProtocolType.SSH2, _SSHParms);
        }
        public void Serialize(SSHLoginParameter tp, StructuredText node)
        {
            base.Serialize(tp, node);
            if (tp.Method != SSHProtocol.SSH2)
            {
                node.Set("method", tp.Method.ToString());
            }
            if (tp.AuthenticationType != AuthenticationType.Password)
            {
                node.Set("authentication", tp.AuthenticationType.ToString());
            }
            node.Set("account", tp.Account);
            if (tp.IdentityFileName.Length > 0)
            {
                node.Set("identityFileName", tp.IdentityFileName);
            }
            if (tp.PasswordOrPassphrase != null)
            {
                if (ProtocolsPlugin.Instance.ProtocolOptions.SavePlainTextPassword)
                {
                    node.Set("passphrase", tp.PasswordOrPassphrase);
                }
                else if (ProtocolsPlugin.Instance.ProtocolOptions.SavePassword)
                {
                    string pw = new SimpleStringEncrypt().EncryptString(tp.PasswordOrPassphrase);
                    if (pw != null)
                    {
                        node.Set("password", pw);
                    }
                }
            }

            node.Set("enableAgentForwarding", tp.EnableAgentForwarding.ToString());

            node.Set("enableX11Forwarding", tp.EnableX11Forwarding.ToString());

            if (tp.X11Forwarding != null)
            {
                StructuredText x11Node = node.AddChild("x11Forwarding");
                x11Node.Set("display", tp.X11Forwarding.Display.ToString(NumberFormatInfo.InvariantInfo));
                x11Node.Set("screen", tp.X11Forwarding.Screen.ToString(NumberFormatInfo.InvariantInfo));
                x11Node.Set("needAuth", tp.X11Forwarding.NeedAuth.ToString());
                if (tp.X11Forwarding.XauthorityFile != null)
                {
                    x11Node.Set("xauthorityFile", tp.X11Forwarding.XauthorityFile);
                }
                x11Node.Set("useCygwinUnixDomainSocket", tp.X11Forwarding.UseCygwinUnixDomainSocket.ToString());
                if (tp.X11Forwarding.X11UnixFolder != null)
                {
                    x11Node.Set("x11UnixFolder", tp.X11Forwarding.X11UnixFolder);
                }
            }
        }
        public void Deserialize(SSHLoginParameter tp, StructuredText node)
        {
            base.Deserialize(tp, node);
            tp.Method             = "SSH1".Equals(node.Get("method")) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
            tp.AuthenticationType = ParseUtil.ParseEnum <AuthenticationType>(node.Get("authentication", ""), AuthenticationType.Password);
            tp.Account            = node.Get("account", "");
            tp.IdentityFileName   = node.Get("identityFileName", "");
            if (ProtocolsPlugin.Instance.ProtocolOptions.ReadSerializedPassword)
            {
                string pw = node.Get("passphrase", null);
                if (pw != null)
                {
                    tp.PasswordOrPassphrase = pw;
                    tp.LetUserInputPassword = false;
                }
                else
                {
                    pw = node.Get("password", null);
                    if (pw != null)
                    {
                        pw = new SimpleStringEncrypt().DecryptString(pw);
                        if (pw != null)
                        {
                            tp.PasswordOrPassphrase = pw;
                            tp.LetUserInputPassword = false;
                        }
                    }
                }
            }

            tp.EnableAgentForwarding = GetBoolValue(node, "enableAgentForwarding", false);

            tp.EnableX11Forwarding = GetBoolValue(node, "enableX11Forwarding", false);

            StructuredText x11Node = node.FindChild("x11Forwarding");

            if (x11Node != null)
            {
                int display = GetIntValue(x11Node, "display", 0);
                X11ForwardingParams x11params = new X11ForwardingParams(display);
                x11params.Screen                    = GetIntValue(x11Node, "screen", 0);
                x11params.NeedAuth                  = GetBoolValue(x11Node, "needAuth", false);
                x11params.XauthorityFile            = x11Node.Get("xauthorityFile", null);
                x11params.UseCygwinUnixDomainSocket = GetBoolValue(x11Node, "useCygwinUnixDomainSocket", false);
                x11params.X11UnixFolder             = x11Node.Get("x11UnixFolder", null);
                tp.X11Forwarding                    = x11params;
            }
        }
        public void SSH1()
        {
            SSHLoginParameter p1 = new SSHLoginParameter();
            p1.Method = SSHProtocol.SSH1;
            p1.Account = "account";
            p1.IdentityFileName = "identity-file";
            p1.AuthenticationType = AuthenticationType.PublicKey;

            StructuredText t = _sshSerializer.Serialize(p1);
            UnitTestUtil.DumpStructuredText(t);
            //確認
            Debug.WriteLine(UnitTestUtil.DumpStructuredText(t));

            SSHLoginParameter p2 = (SSHLoginParameter)_sshSerializer.Deserialize(t);
            Assert.AreEqual(SSHProtocol.SSH1, p2.Method);
            Assert.AreEqual(AuthenticationType.PublicKey, p2.AuthenticationType);
            Assert.AreEqual("identity-file", p2.IdentityFileName);
            Assert.AreEqual("account", p2.Account);
        }
        public void SSH0()
        {
            SSHLoginParameter p1 = new SSHLoginParameter();
            StructuredText t = _sshSerializer.Serialize(p1);
            //確認
            StringWriter wr = new StringWriter();
            new TextStructuredTextWriter(wr).Write(t);
            wr.Close();
            Debug.WriteLine(wr.ToString());

            Assert.IsNull(t.Get("port"));
            Assert.IsNull(t.Get("method"));
            Assert.IsNull(t.Get("authentication"));
            Assert.IsNull(t.Get("identityFileName"));
            SSHLoginParameter p2 = (SSHLoginParameter)_sshSerializer.Deserialize(t);
            Assert.AreEqual(22, p2.Port);
            Assert.AreEqual(SSHProtocol.SSH2, p2.Method);
            Assert.AreEqual(AuthenticationType.Password, p2.AuthenticationType);
            Assert.AreEqual("", p2.IdentityFileName);
        }
示例#10
0
 public SSHLoginParameter(SSHLoginParameter src)
     : base(src) {
     _method = src._method;
     _authType = src._authType;
     _account = src._account;
     _identityFile = src._identityFile;
     _passwordOrPassphrase = src._passwordOrPassphrase;
     _letUserInputPassword = src._letUserInputPassword;
     _agentForward = src._agentForward;
 }
        public void SSH1()
        {
            SSHLoginParameter p1 = new SSHLoginParameter();
            p1.Method = SSHProtocol.SSH1;
            p1.Account = "account";
            p1.IdentityFileName = "identity-file";
            p1.AuthenticationType = AuthenticationType.PublicKey;

            StructuredText t = _sshSerializer.Serialize(p1);
            UnitTestUtil.DumpStructuredText(t);
            //確認
            Debug.WriteLine(UnitTestUtil.DumpStructuredText(t));

            SSHLoginParameter p2 = (SSHLoginParameter)_sshSerializer.Deserialize(t);
            Assert.AreEqual(SSHProtocol.SSH1, p2.Method);
            Assert.AreEqual(AuthenticationType.PublicKey, p2.AuthenticationType);
            Assert.AreEqual("identity-file", p2.IdentityFileName);
            Assert.AreEqual("account", p2.Account);
        }
        public void SSH0()
        {
            SSHLoginParameter p1 = new SSHLoginParameter();
            StructuredText t = _sshSerializer.Serialize(p1);
            //確認
            StringWriter wr = new StringWriter();
            new TextStructuredTextWriter(wr).Write(t);
            wr.Close();
            Debug.WriteLine(wr.ToString());

            Assert.IsNull(t.Get("port"));
            Assert.IsNull(t.Get("method"));
            Assert.IsNull(t.Get("authentication"));
            Assert.IsNull(t.Get("identityFileName"));
            SSHLoginParameter p2 = (SSHLoginParameter)_sshSerializer.Deserialize(t);
            Assert.AreEqual(22, p2.Port);
            Assert.AreEqual(SSHProtocol.SSH2, p2.Method);
            Assert.AreEqual(AuthenticationType.Password, p2.AuthenticationType);
            Assert.AreEqual("", p2.IdentityFileName);
        }
        public void Serialize(SSHLoginParameter tp, StructuredText node)
        {
            base.Serialize(tp, node);
            if (tp.Method != SSHProtocol.SSH2)
                node.Set("method", tp.Method.ToString());
            if (tp.AuthenticationType != AuthenticationType.Password)
                node.Set("authentication", tp.AuthenticationType.ToString());
            node.Set("account", tp.Account);
            if (tp.IdentityFileName.Length > 0)
                node.Set("identityFileName", tp.IdentityFileName);
            if (tp.PasswordOrPassphrase != null) {
                if (ProtocolsPlugin.Instance.ProtocolOptions.SavePlainTextPassword) {
                    node.Set("passphrase", tp.PasswordOrPassphrase);
                }
                else if (ProtocolsPlugin.Instance.ProtocolOptions.SavePassword) {
                    string pw = new SimpleStringEncrypt().EncryptString(tp.PasswordOrPassphrase);
                    if (pw != null) {
                        node.Set("password", pw);
                    }
                }
            }

            node.Set("enableAgentForwarding", tp.EnableAgentForwarding.ToString());

            node.Set("enableX11Forwarding", tp.EnableX11Forwarding.ToString());

            if (tp.X11Forwarding != null) {
                StructuredText x11Node = node.AddChild("x11Forwarding");
                x11Node.Set("display", tp.X11Forwarding.Display.ToString(NumberFormatInfo.InvariantInfo));
                x11Node.Set("screen", tp.X11Forwarding.Screen.ToString(NumberFormatInfo.InvariantInfo));
                x11Node.Set("needAuth", tp.X11Forwarding.NeedAuth.ToString());
                if (tp.X11Forwarding.XauthorityFile != null) {
                    x11Node.Set("xauthorityFile", tp.X11Forwarding.XauthorityFile);
                }
                x11Node.Set("useCygwinUnixDomainSocket", tp.X11Forwarding.UseCygwinUnixDomainSocket.ToString());
                if (tp.X11Forwarding.X11UnixFolder != null) {
                    x11Node.Set("x11UnixFolder", tp.X11Forwarding.X11UnixFolder);
                }
            }
        }
 public override object Deserialize(StructuredText node)
 {
     SSHLoginParameter t = new SSHLoginParameter();
     Deserialize(t, node);
     return t;
 }
        public void Deserialize(SSHLoginParameter tp, StructuredText node)
        {
            base.Deserialize(tp, node);
            tp.Method = "SSH1".Equals(node.Get("method")) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
            tp.AuthenticationType = ParseUtil.ParseEnum<AuthenticationType>(node.Get("authentication", ""), AuthenticationType.Password);
            tp.Account = node.Get("account", "");
            tp.IdentityFileName = node.Get("identityFileName", "");
            if (ProtocolsPlugin.Instance.ProtocolOptions.ReadSerializedPassword) {
                string pw = node.Get("passphrase", null);
                if (pw != null) {
                    tp.PasswordOrPassphrase = pw;
                    tp.LetUserInputPassword = false;
                }
                else {
                    pw = node.Get("password", null);
                    if (pw != null) {
                        pw = new SimpleStringEncrypt().DecryptString(pw);
                        if (pw != null) {
                            tp.PasswordOrPassphrase = pw;
                            tp.LetUserInputPassword = false;
                        }
                    }
                }
            }

            tp.EnableAgentForwarding = GetBoolValue(node, "enableAgentForwarding", false);

            tp.EnableX11Forwarding = GetBoolValue(node, "enableX11Forwarding", false);

            StructuredText x11Node = node.FindChild("x11Forwarding");
            if (x11Node != null) {
                int display = GetIntValue(x11Node, "display", 0);
                X11ForwardingParams x11params = new X11ForwardingParams(display);
                x11params.Screen = GetIntValue(x11Node, "screen", 0);
                x11params.NeedAuth = GetBoolValue(x11Node, "needAuth", false);
                x11params.XauthorityFile = x11Node.Get("xauthorityFile", null);
                x11params.UseCygwinUnixDomainSocket = GetBoolValue(x11Node, "useCygwinUnixDomainSocket", false);
                x11params.X11UnixFolder = x11Node.Get("x11UnixFolder", null);
                tp.X11Forwarding = x11params;
            }
        }
 public void Serialize(SSHLoginParameter tp, StructuredText node)
 {
     base.Serialize(tp, node);
     if (tp.Method != SSHProtocol.SSH2)
         node.Set("method", tp.Method.ToString());
     if (tp.AuthenticationType != AuthenticationType.Password)
         node.Set("authentication", tp.AuthenticationType.ToString());
     node.Set("account", tp.Account);
     if (tp.IdentityFileName.Length > 0)
         node.Set("identityFileName", tp.IdentityFileName);
     if (tp.PasswordOrPassphrase != null) {
         if (ProtocolsPlugin.Instance.ProtocolOptions.SavePlainTextPassword) {
             node.Set("passphrase", tp.PasswordOrPassphrase);
         }
         else if (ProtocolsPlugin.Instance.ProtocolOptions.SavePassword) {
             string pw = new SimpleStringEncrypt().EncryptString(tp.PasswordOrPassphrase);
             if (pw != null) {
                 node.Set("password", pw);
             }
         }
     }
 }
 public void Deserialize(SSHLoginParameter tp, StructuredText node)
 {
     base.Deserialize(tp, node);
     tp.Method = "SSH1".Equals(node.Get("method")) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
     tp.AuthenticationType = ParseUtil.ParseEnum<AuthenticationType>(node.Get("authentication", ""), AuthenticationType.Password);
     tp.Account = node.Get("account", "");
     tp.IdentityFileName = node.Get("identityFileName", "");
     if (ProtocolsPlugin.Instance.ProtocolOptions.ReadSerializedPassword) {
         string pw = node.Get("passphrase", null);
         if (pw != null) {
             tp.PasswordOrPassphrase = pw;
             tp.LetUserInputPassword = false;
         }
         else {
             pw = node.Get("password", null);
             if (pw != null) {
                 pw = new SimpleStringEncrypt().DecryptString(pw);
                 if (pw != null) {
                     tp.PasswordOrPassphrase = pw;
                     tp.LetUserInputPassword = false;
                 }
             }
         }
     }
 }