Beispiel #1
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;
                 }
             }
         }
     }
 }
Beispiel #2
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);
             }
         }
     }
 }
        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 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 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;
                 }
             }
         }
     }
 }