Beispiel #1
0
        private void client_CertificateRequired(object sender, ComponentPro.Security.CertificateRequiredEventArgs e)
        {
            string cert = _loginSettings.Get <string>(FtpLoginInfo.Certificate);

            // If the client cert file is specified.
            if (!string.IsNullOrEmpty(cert))
            {
                // Load Certificate.
                PasswordPrompt passdlg = new PasswordPrompt("Please provide password for certificate");
                // Ask for cert's passpharse
                if (passdlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    X509Certificate2 clientCert = new X509Certificate2(cert, passdlg.Password);
                    e.Certificates = new X509Certificate2Collection(clientCert);
                    return;
                }

                // Password has not been provided.
            }
            CertProvider dlg = new CertProvider();

            dlg.ShowDialog();
            // Get the selected certificate.
            e.Certificates = new X509Certificate2Collection(dlg.SelectedCertificate);
        }
Beispiel #2
0
        static void Main()
        {
            string promptedPassword = "";

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HostSelect     Selector;
            PasswordPrompt Prompter;

            if (!Directory.Exists(APPDIR))
            {
                Directory.CreateDirectory(APPDIR);
                if (Directory.Exists(SYSTEMSDIR_Old))
                {
                    Directory.Move(SYSTEMSDIR_Old, SYSTEMSDIR);
                }

                if (File.Exists(CONFIGDIR_Old))
                {
                    File.Move(CONFIGDIR_Old, CONFIGFILE);
                }

                if (Directory.Exists(SOURCEDIR_Old))
                {
                    Directory.Move(SOURCEDIR_Old, SOURCEDIR);
                }
            }

            Directory.CreateDirectory(SYSTEMSDIR);
            Directory.CreateDirectory(SOURCEDIR);
            Directory.CreateDirectory(PROJDIR);

            Config = new Config(CONFIGFILE);
            Config.DoEditorDefaults();

            bool Connected = false;

            while (Connected == false)
            {
                Selector = new HostSelect();
                Application.Run(Selector);

                if (Selector.SystemSelected)
                {
                    if (IBMi.CurrentSystem.GetValue("password") == "")
                    {
                        Prompter = new PasswordPrompt(IBMi.CurrentSystem.GetValue("alias"), IBMi.CurrentSystem.GetValue("username"));
                        Prompter.ShowDialog();
                        if (Prompter.Success)
                        {
                            promptedPassword = Prompter.GetResult();
                        }
                    }

                    Connected = IBMi.Connect(Selector.OfflineModeSelected(), promptedPassword);

                    if (Connected)
                    {
                        Application.Run(new Editor());
                        IBMi.Disconnect();
                    }
                    else
                    {
                        //Basically, if it failed to connect when they're using FTPES - offer them a FTP connection
                        if (IBMi.CurrentSystem.GetValue("useFTPES") == "true")
                        {
                            DialogResult Result = MessageBox.Show("Would you like to try and connect again using a plain FTP connection? This will change the systems settings.", "Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                            if (Result == DialogResult.Yes)
                            {
                                IBMi.CurrentSystem.SetValue("useFTPES", "false");
                                Connected = IBMi.Connect(false, promptedPassword);
                                if (Connected)
                                {
                                    Application.Run(new Editor());
                                    IBMi.Disconnect();
                                }
                            }
                        }
                    }
                }
                else
                {
                    Connected = true; //End loop and close
                }
            }
        }
Beispiel #3
0
 public static String GetSmartCardPin()
 {
     return(PasswordPrompt.ShowDialog("Please provide your smart card pin", "Smart Card Pin Window"));
 }
Beispiel #4
0
 public static String GetUserPassPhase()
 {
     return(PasswordPrompt.ShowDialog("Please provide your passphse:", "Passphase Window"));
 }
Beispiel #5
0
        static void Main()
        {
            string promptedPassword = "";

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HostSelect     Selector;
            PasswordPrompt Prompter;

            Directory.CreateDirectory(SYSTEMSDIR);
            Directory.CreateDirectory(SOURCEDIR);
            Directory.CreateDirectory(DUMPSDIR);

            Config = new Config(CONFIGFILE);
            Config.DoEditorDefaults();

            bool Connected = false;

            while (Connected == false)
            {
                Selector = new HostSelect();
                Application.Run(Selector);

                if (Selector.SystemSelected)
                {
                    if (IBMi.CurrentSystem.GetValue("password") == "")
                    {
                        Prompter = new PasswordPrompt(IBMi.CurrentSystem.GetValue("alias"), IBMi.CurrentSystem.GetValue("username"));
                        Prompter.ShowDialog();
                        if (Prompter.Success)
                        {
                            promptedPassword = Prompter.GetResult();
                        }
                    }

                    Connected = IBMi.Connect(Selector.OfflineModeSelected(), promptedPassword);

                    if (Connected)
                    {
                        if (Config.GetValue("srcdat_agreement") == "false")
                        {
                            MessageBox.Show("Thanks for using ILEditor. This is a notice to tell you that when editing source members, the SRCDAT value is not retained. This is due to a restriction in our connection method. By using ILEditor you agree to our LICENCE, found on the ILEditor GitHub repository. Please seek ILEditor GitHub issues for further information.", "ILEditor Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Config.SetValue("srcdat_agreement", "true");
                            Config.SaveConfig();
                        }

                        try
                        {
                            Application.Run(new Editor());
                        }
                        catch (Exception e)
                        {
                            File.WriteAllText(Path.Combine(DUMPSDIR, DateTime.Now.ToFileTime() + ".txt"), e.ToString());
                            MessageBox.Show("There was an error. Crash dump created: " + DUMPSDIR);
                        }
                        IBMi.Disconnect();
                    }
                    else
                    {
                        //Basically, if it failed to connect when they're using FTPES - offer them a FTP connection
                        if (IBMi.CurrentSystem.GetValue("useFTPES") == "true")
                        {
                            MessageBox.Show("Failed to connect. Perhaps try disabling FTPES and then connecting again.", "Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    Connected = true; //End loop and close
                }
            }
        }
 public static string RetrievePassword()
 {
     var prompt = new PasswordPrompt();
     prompt.ShowDialog();
     return prompt.textBox1.Password;
 }
 private string GetPassword(string messageText, bool isNewPassword = false)
 {
     var dlg = new PasswordPrompt(messageText, isNewPassword);
     dlg.ShowDialog();
     return dlg.Password;
 }
Beispiel #8
0
        static void Main()
        {
            string promptedPassword = "";

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HostSelect     Selector;
            PasswordPrompt Prompter;

            Directory.CreateDirectory(SYSTEMSDIR);
            Directory.CreateDirectory(SOURCEDIR);
            Directory.CreateDirectory(DUMPSDIR);

            Config = new Config(CONFIGFILE);
            Config.DoEditorDefaults();

            bool Connected = false;

            while (Connected == false)
            {
                Selector = new HostSelect();
                Application.Run(Selector);

                if (Selector.SystemSelected)
                {
                    if (IBMi.CurrentSystem.GetValue("password") == "")
                    {
                        Prompter = new PasswordPrompt(IBMi.CurrentSystem.GetValue("alias"), IBMi.CurrentSystem.GetValue("username"));
                        Prompter.ShowDialog();
                        if (Prompter.Success)
                        {
                            promptedPassword = Prompter.GetResult();
                        }
                    }

                    Connected = IBMi.Connect(Selector.OfflineModeSelected(), promptedPassword);

                    if (Connected)
                    {
                        try
                        {
                            Application.Run(new Editor());
                        }
                        catch (Exception e)
                        {
                            File.WriteAllText(Path.Combine(DUMPSDIR, DateTime.Now.ToFileTime() + ".txt"), e.ToString());
                            MessageBox.Show("There was an error. Crash dump created.");
                        }
                        IBMi.Disconnect();
                    }
                    else
                    {
                        //Basically, if it failed to connect when they're using FTPES - offer them a FTP connection
                        if (IBMi.CurrentSystem.GetValue("useFTPES") == "true")
                        {
                            MessageBox.Show("Failed to connect. Perhaps try disabling FTPES and then connecting again.", "Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    Connected = true; //End loop and close
                }
            }
        }
        /// <summary>
        /// Peforms the cloud deployment.
        /// </summary>
        /// <returns>
        /// true if successful else false
        /// </returns>
        private bool PerformCloudDeployment()
        {
            bool isSuccessful = true;
            int stepNumber = 20;

            // Get storage primary key in either case
            string storagePrimaryKey = string.Empty;

            try
            {
                using (CloudDeploymentTasks cloudTasks = new CloudDeploymentTasks(this.cloudArgs))
                {
                    // If its upgrade donot create hosted serviceand storage primary keys
                    if (!cloudTasks.IsUpgrade)
                    {
                        if (this.isNewStorage)
                        {
                            this.backgroundWorker.ReportProgress(++stepNumber, "Creating storage account in cloud....");
                            storagePrimaryKey = cloudTasks.InitStorageAccount();
                        }
                        else
                        {
                            this.backgroundWorker.ReportProgress(++stepNumber, "Updating storage account in cloud....");
                            storagePrimaryKey = cloudTasks.GetStoragePrimaryKey();
                        }

                        this.backgroundWorker.ReportProgress(++stepNumber, "Creating hosted service in cloud....");
                        cloudTasks.InitHostedService();
                    }
                    else
                    {
                        this.backgroundWorker.ReportProgress(++stepNumber, "Receiving storage account primary key from cloud....");
                        storagePrimaryKey = cloudTasks.GetStoragePrimaryKey();

                        // If storage primary key is not found implies need to create a storage account
                        if (string.IsNullOrEmpty(storagePrimaryKey))
                        {
                            storagePrimaryKey = cloudTasks.InitStorageAccount();
                        }

                        this.backgroundWorker.ReportProgress(++stepNumber, "Creating hosted service in cloud....");
                    }

                    this.backgroundWorker.ReportProgress(++stepNumber, "Copying package to cloud....");
                    cloudTasks.CopyCspkg(storagePrimaryKey);
                    this.backgroundWorker.ReportProgress(++stepNumber, "Deploying package in cloud....");
                    cloudTasks.DeployPackageInCloud();

                    this.backgroundWorker.ReportProgress(++stepNumber, "Creating service certificates. User action required....");

                    if (cloudTasks.CertificatePaths != null && cloudTasks.CertificatePaths.Any())
                    {
                        foreach (var item in cloudTasks.CertificatePaths)
                        {
                            // doit variable is to bypass STA
                            bool doit = false;
                            string fileName = Path.GetFileName(item);
                            PasswordPrompt prompt = new PasswordPrompt(fileName);
                            this.Invoke((MethodInvoker)delegate
                            {
                                prompt.TopMost = true;
                                prompt.StartPosition = FormStartPosition.CenterParent;
                                if (prompt.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                                {
                                    doit = true;
                                }
                            });

                            if (doit)
                            {
                                cloudTasks.AddCertificateToCloud(item, prompt.GivenPassword);
                            }
                            else
                            {
                                string.Format("Cannot install certificate : {0}. Cancelled by User", fileName).WriteToLog();
                                string.Format("Cannot install certificate : {0}. Cancelled by User", fileName).ShowUIInformation(FormStartPosition.CenterScreen);
                            }
                        }
                    }

                    this.backgroundWorker.ReportProgress(++stepNumber, "Cloud deployment completed successfully....");
                }
            }
            catch (WebException exception)
            {
                isSuccessful = false;
                this.backgroundWorker.ReportProgress(stepNumber, ReportStatus.Fail);
                exception.WriteToLog();
                this.Invoke((MethodInvoker)(() => exception.ShowGenericException("Deployment to Cloud failed.")));
            }
            catch (Exception exception)
            {
                isSuccessful = false;
                this.backgroundWorker.ReportProgress(stepNumber, ReportStatus.Fail);
                exception.WriteToLog();
                this.Invoke((MethodInvoker)(() => exception.ShowGenericException("Deployment to Cloud failed.")));
            }

            return isSuccessful;
        }