Decrypt() public method

public Decrypt ( string ciphertextBase64, SecureString password ) : string
ciphertextBase64 string
password System.Security.SecureString
return string
示例#1
0
        public override void LoadSettings()
        {
            base.SaveSettings();

            chkUseSQLServer.Checked = Settings.Default.UseSQLServer;
            txtSQLServer.Text = Settings.Default.SQLHost;
            txtSQLDatabaseName.Text = Settings.Default.SQLDatabaseName;
            txtSQLUsername.Text = Settings.Default.SQLUser;
            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
            txtSQLPassword.Text = cryptographyProvider.Decrypt(Settings.Default.SQLPass, Runtime.EncryptionKey);
        }
示例#2
0
        public override void LoadSettings()
        {
            base.SaveSettings();

            chkCheckForUpdatesOnStartup.Checked = Convert.ToBoolean(Settings.Default.CheckForUpdatesOnStartup);
            cboUpdateCheckFrequency.Enabled = chkCheckForUpdatesOnStartup.Checked;
            cboUpdateCheckFrequency.Items.Clear();
            var nDaily = cboUpdateCheckFrequency.Items.Add(Language.strUpdateFrequencyDaily);
            var nWeekly = cboUpdateCheckFrequency.Items.Add(Language.strUpdateFrequencyWeekly);
            var nMonthly = cboUpdateCheckFrequency.Items.Add(Language.strUpdateFrequencyMonthly);
            if (Settings.Default.CheckForUpdatesFrequencyDays < 1)
            {
                chkCheckForUpdatesOnStartup.Checked = false;
                cboUpdateCheckFrequency.SelectedIndex = nDaily;
            } // Daily
            else switch (Settings.Default.CheckForUpdatesFrequencyDays)
            {
                case 1:
                    cboUpdateCheckFrequency.SelectedIndex = nDaily;
                    break;
                case 7:
                    cboUpdateCheckFrequency.SelectedIndex = nWeekly;
                    break;
                case 31:
                    cboUpdateCheckFrequency.SelectedIndex = nMonthly;
                    break;
                default:
                    var nCustom =
                        cboUpdateCheckFrequency.Items.Add(string.Format(Language.strUpdateFrequencyCustom,
                            Settings.Default.CheckForUpdatesFrequencyDays));
                    cboUpdateCheckFrequency.SelectedIndex = nCustom;
                    break;
            }

            chkUseProxyForAutomaticUpdates.Checked = Convert.ToBoolean(Settings.Default.UpdateUseProxy);
            pnlProxyBasic.Enabled = Convert.ToBoolean(Settings.Default.UpdateUseProxy);
            txtProxyAddress.Text = Convert.ToString(Settings.Default.UpdateProxyAddress);
            numProxyPort.Value = Convert.ToDecimal(Settings.Default.UpdateProxyPort);

            chkUseProxyAuthentication.Checked = Convert.ToBoolean(Settings.Default.UpdateProxyUseAuthentication);
            pnlProxyAuthentication.Enabled = Convert.ToBoolean(Settings.Default.UpdateProxyUseAuthentication);
            txtProxyUsername.Text = Convert.ToString(Settings.Default.UpdateProxyAuthUser);
            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
            txtProxyPassword.Text = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.UpdateProxyAuthPass), Runtime.EncryptionKey);

            btnTestProxy.Enabled = Convert.ToBoolean(Settings.Default.UpdateUseProxy);
        }
        private void SetCredentials()
        {
            try
            {
                if ((Force & ConnectionInfo.Force.NoCredentials) == ConnectionInfo.Force.NoCredentials)
                {
                    return;
                }

                var userName = _connectionInfo.Username;
                var password = _connectionInfo.Password;
                var domain = _connectionInfo.Domain;

                if (string.IsNullOrEmpty(userName))
                {
                    if (Settings.Default.EmptyCredentials == "windows")
                    {
                        _rdpClient.UserName = Environment.UserName;
                    }
                    else if (Settings.Default.EmptyCredentials == "custom")
                    {
                        _rdpClient.UserName = Convert.ToString(Settings.Default.DefaultUsername);
                    }
                }
                else
                {
                    _rdpClient.UserName = userName;
                }

                if (string.IsNullOrEmpty(password))
                {
                    if (Settings.Default.EmptyCredentials == "custom")
                    {
                        if (Settings.Default.DefaultPassword != "")
                        {
                            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                            _rdpClient.AdvancedSettings2.ClearTextPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.DefaultPassword), Runtime.EncryptionKey);
                        }
                    }
                }
                else
                {
                    _rdpClient.AdvancedSettings2.ClearTextPassword = password;
                }

                if (string.IsNullOrEmpty(domain))
                {
                    if (Settings.Default.EmptyCredentials == "windows")
                    {
                        _rdpClient.Domain = Environment.UserDomainName;
                    }
                    else if (Settings.Default.EmptyCredentials == "custom")
                    {
                        _rdpClient.Domain = Convert.ToString(Settings.Default.DefaultDomain);
                    }
                }
                else
                {
                    _rdpClient.Domain = domain;
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpSetCredentialsFailed, ex);
            }
        }
示例#4
0
        public override void LoadSettings()
        {
            base.SaveSettings();

            chkSingleClickOnConnectionOpensIt.Checked =
                Convert.ToBoolean(Settings.Default.SingleClickOnConnectionOpensIt);
            chkSingleClickOnOpenedConnectionSwitchesToIt.Checked =
                Convert.ToBoolean(Settings.Default.SingleClickSwitchesToOpenConnection);
            chkHostnameLikeDisplayName.Checked = Convert.ToBoolean(Settings.Default.SetHostnameLikeDisplayName);

            numRdpReconnectionCount.Value = Convert.ToDecimal(Settings.Default.RdpReconnectionCount);

            numRDPConTimeout.Value = Convert.ToDecimal(Settings.Default.ConRDPOverallConnectionTimeout);

            numAutoSave.Value = Convert.ToDecimal(Settings.Default.AutoSaveEveryMinutes);

            // ReSharper disable once StringLiteralTypo
            if (Settings.Default.EmptyCredentials == "noinfo")
            {
                radCredentialsNoInfo.Checked = true;
            }
            else if (Settings.Default.EmptyCredentials == "windows")
            {
                radCredentialsWindows.Checked = true;
            }
            else if (Settings.Default.EmptyCredentials == "custom")
            {
                radCredentialsCustom.Checked = true;
            }

            txtCredentialsUsername.Text = Convert.ToString(Settings.Default.DefaultUsername);
            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
            txtCredentialsPassword.Text = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.DefaultPassword), Runtime.EncryptionKey);
            txtCredentialsDomain.Text = Convert.ToString(Settings.Default.DefaultDomain);

            if (Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Never)
            {
                radCloseWarnNever.Checked = true;
            }
            else if (Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Exit)
            {
                radCloseWarnExit.Checked = true;
            }
            else if (Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Multiple)
            {
                radCloseWarnMultiple.Checked = true;
            }
            else
            {
                radCloseWarnAll.Checked = true;
            }
        }
        private void SetCredentials()
        {
            try
            {
                if (((int)Force & (int)ConnectionInfo.Force.NoCredentials) == (int)ConnectionInfo.Force.NoCredentials)
                {
                    return ;
                }

                string _user = _Info.Username;
                string _pass = _Info.Password;
                string _dom = _Info.Domain;

                if (string.IsNullOrEmpty(_user))
                {
                    if (Settings.Default.EmptyCredentials == "windows")
                    {
                        _ICAClient.Username = Environment.UserName;
                    }
                    else if (Settings.Default.EmptyCredentials == "custom")
                    {
                        _ICAClient.Username = Settings.Default.DefaultUsername;
                    }
                }
                else
                {
                    _ICAClient.Username = _user;
                }

                if (string.IsNullOrEmpty(_pass))
                {
                    if (Settings.Default.EmptyCredentials == "custom")
                    {
                        if (Settings.Default.DefaultPassword != "")
                        {
                            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                            _ICAClient.SetProp("ClearPassword", cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey));
                        }
                    }
                }
                else
                {
                    _ICAClient.SetProp("ClearPassword", _pass);
                }

                if (string.IsNullOrEmpty(_dom))
                {
                    if (Settings.Default.EmptyCredentials == "windows")
                    {
                        _ICAClient.Domain = Environment.UserDomainName;
                    }
                    else if (Settings.Default.EmptyCredentials == "custom")
                    {
                        _ICAClient.Domain = Settings.Default.DefaultDomain;
                    }
                }
                else
                {
                    _ICAClient.Domain = _dom;
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaSetCredentialsFailed + Environment.NewLine + ex.Message, true);
            }
        }
示例#6
0
        public static void SaveConnections()
        {
            if (ConnectionTreeModel == null) return;
            if (!IsConnectionsFileLoaded) return;

            try
            {
                RemoteConnectionsSyncronizer?.Disable();

                var connectionsSaver = new ConnectionsSaver();

                if (!Settings.Default.UseSQLServer)
                    connectionsSaver.ConnectionFileName = GetStartupConnectionFileName();

                connectionsSaver.Export = false;
                connectionsSaver.SaveFilter = new SaveFilter();
                connectionsSaver.ConnectionTreeModel = ConnectionTreeModel;

                if (Settings.Default.UseSQLServer)
                {
                    connectionsSaver.SaveFormat = ConnectionsSaver.Format.SQL;
                    connectionsSaver.SQLHost = Convert.ToString(Settings.Default.SQLHost);
                    connectionsSaver.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName);
                    connectionsSaver.SQLUsername = Convert.ToString(Settings.Default.SQLUser);
                    var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                    connectionsSaver.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), EncryptionKey);
                }

                connectionsSaver.SaveConnections();

                if (Settings.Default.UseSQLServer)
                    LastSqlUpdate = DateTime.Now;
            }
            catch (Exception ex)
            {
                MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionsFileCouldNotBeSaved + Environment.NewLine + ex.Message);
            }
            finally
            {
                RemoteConnectionsSyncronizer?.Enable();
            }
        }
示例#7
0
 private static void SetConDefaultPassword()
 {
     var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
     mRemoteNG.Settings.Default.ConDefaultPassword = cryptographyProvider.Decrypt(mRemoteNG.Settings.Default.ConDefaultPassword, Runtime.EncryptionKey);
 }
示例#8
0
        private void SetProxySettings()
        {
            var shouldWeUseProxy = Settings.Default.UpdateUseProxy;
            var proxyAddress = Settings.Default.UpdateProxyAddress;
            var port = Settings.Default.UpdateProxyPort;
            var useAuthentication = Settings.Default.UpdateProxyUseAuthentication;
            var username = Settings.Default.UpdateProxyAuthUser;
            var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
            var password = cryptographyProvider.Decrypt(Settings.Default.UpdateProxyAuthPass, Runtime.EncryptionKey);

            SetProxySettings(shouldWeUseProxy, proxyAddress, port, useAuthentication, username, password);
        }
示例#9
0
        public override bool Connect()
        {
            try
            {
                _isPuttyNg = PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.PuttyNg;

                PuttyProcess = new Process
                {
                    StartInfo =
                    {
                        UseShellExecute = false,
                        FileName = PuttyPath
                    }
                };

                var arguments = new CommandLineArguments {EscapeForShell = false};

                arguments.Add("-load", InterfaceControl.Info.PuttySession);

                if (!(InterfaceControl.Info is PuttySessionInfo))
                {
                    arguments.Add("-" + PuttyProtocol);

                    if (PuttyProtocol == Putty_Protocol.ssh)
                    {
                        var username = "";
                        var password = "";

                        if (!string.IsNullOrEmpty(InterfaceControl.Info.Username))
                        {
                            username = InterfaceControl.Info.Username;
                        }
                        else
                        {
                            if (Settings.Default.EmptyCredentials == "windows")
                            {
                                username = Environment.UserName;
                            }
                            else if (Settings.Default.EmptyCredentials == "custom")
                            {
                                username = Convert.ToString(Settings.Default.DefaultUsername);
                            }
                        }

                        if (!string.IsNullOrEmpty(InterfaceControl.Info.Password))
                        {
                            password = InterfaceControl.Info.Password;
                        }
                        else
                        {
                            if (Settings.Default.EmptyCredentials == "custom")
                            {
                                var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                                password = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.DefaultPassword), Runtime.EncryptionKey);
                            }
                        }

                        arguments.Add("-" + (int)PuttySSHVersion);

                        if (((int)Force & (int)ConnectionInfo.Force.NoCredentials) != (int)ConnectionInfo.Force.NoCredentials)
                        {
                            if (!string.IsNullOrEmpty(username))
                            {
                                arguments.Add("-l", username);
                            }
                            if (!string.IsNullOrEmpty(password))
                            {
                                arguments.Add("-pw", password);
                            }
                        }
                    }

                    arguments.Add("-P", InterfaceControl.Info.Port.ToString());
                    arguments.Add(InterfaceControl.Info.Hostname);
                }

                if (_isPuttyNg)
                {
                    arguments.Add("-hwndparent", InterfaceControl.Handle.ToString());
                }

                PuttyProcess.StartInfo.Arguments = arguments.ToString();

                PuttyProcess.EnableRaisingEvents = true;
                PuttyProcess.Exited += ProcessExited;

                PuttyProcess.Start();
                PuttyProcess.WaitForInputIdle(Convert.ToInt32(Settings.Default.MaxPuttyWaitTime * 1000));

                var startTicks = Environment.TickCount;
                while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000))
                {
                    if (_isPuttyNg)
                    {
                        PuttyHandle = NativeMethods.FindWindowEx(
                            InterfaceControl.Handle, new IntPtr(0), null, null);
                    }
                    else
                    {
                        PuttyProcess.Refresh();
                        PuttyHandle = PuttyProcess.MainWindowHandle;
                    }
                    if (PuttyHandle.ToInt32() == 0)
                    {
                        Thread.Sleep(0);
                    }
                }

                if (!_isPuttyNg)
                {
                    NativeMethods.SetParent(PuttyHandle, InterfaceControl.Handle);
                }

                Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strPuttyStuff, true);
                Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyHandle, PuttyHandle), true);
                Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyTitle, PuttyProcess.MainWindowTitle), true);
                Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyParentHandle, InterfaceControl.Parent.Handle), true);

                Resize(this, new EventArgs());
                base.Connect();
                return true;
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strPuttyConnectionFailed + Environment.NewLine + ex.Message);
                return false;
            }
        }