private void btnImport_Click(object sender, EventArgs e)
        {
            // get file name
            OpenFileDialog open = new OpenFileDialog();

            open.Title    = "Choose an RSA Key Container File to Import";
            open.Filter   = "XML File (.xml)|*.xml";
            open.ShowHelp = false;
            if (open.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            string fileName = open.FileName;

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }

            // get container to import
            string container = GetStringForm.Prompt(this, "Enter RSA Key Container Name", "This must be the same name you used when creating the container.");

            if (String.IsNullOrEmpty(container))
            {
                return;
            }

            // import
            string output = Program.RunTask("-pi \"{0}\" \"{1}\"", container, fileName);

            Program.ShowMessageBox(this, output);
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string name = GetStringForm.Prompt(this, "Create RSA Key Container", "Enter a name for the new key container.");

            if (!String.IsNullOrEmpty(name))
            {
                string output = Program.RunTask("-pc \"{0}\" -exp", name);
                Program.ShowMessageBox(this, output);
            }
        }
Beispiel #3
0
        public static string Prompt(IWin32Window owner, string title, string prompt, string defaultText = "", string nullVal = "")
        {
            GetStringForm form = new GetStringForm();

            form.Text         = title;
            form.label1.Text  = prompt;
            form.textBox.Text = defaultText;
            if (form.ShowDialog(owner) == DialogResult.OK)
            {
                return(form.textBox.Text);
            }
            return(nullVal);
        }
        private void btnPermission_Click(object sender, EventArgs e)
        {
            // get container to grant on
            string container = ChooseKeyProviderForm.GetKeyProvider(this, "Choose an RSA Key Container to Grant Permissions For", CryptoAPI.GetKeyContainerNames());

            if (String.IsNullOrEmpty(container))
            {
                return;
            }

            // get user name to grant to
            string user = GetStringForm.Prompt(this, "Enter User Name", "Enter the Windows user to grant access to. (Usually 'NT AUTHORITY\\NETWORK SERVICE' in IIS versions before 7.5 and 'APPPOOL\\YourAppPoolName' in IIS versions 7.5 and later.)");

            if (String.IsNullOrEmpty(user))
            {
                return;
            }

            // grant
            string output = Program.RunTask("-pa \"{0}\" \"{1}\"", container, user);

            Program.ShowMessageBox(this, output);
        }