private async void ButtonGenerate_Click(object sender, EventArgs e) { try { if (ListViewSubject.Items.Count < 1) { WinFormsUtils.ShowInfo(null, "Please specify subject first"); return; } DnEntry[] dnEntries = new DnEntry[ListViewSubject.Items.Count]; for (int i = 0; i < ListViewSubject.Items.Count; i++) { dnEntries[i] = (DnEntry)ListViewSubject.Items[i].Tag; } string fileName = null; byte[] fileContent = null; // TODO - Parametrize HashAlgorithm // TODO - Specify SAN await WaitDialog.Execute( this, () => _pkcs11Slot.GenerateCsr(_privKeyInfo, _pubKeyInfo, dnEntries, HashAlgorithm.SHA256, out fileName, out fileContent) ); using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.FileName = fileName; saveFileDialog.Filter = "All files (*.*)|*.*|DER encoded certificate signing request (*.csr)|*.csr"; saveFileDialog.FilterIndex = 2; saveFileDialog.AddExtension = true; saveFileDialog.CreatePrompt = false; saveFileDialog.OverwritePrompt = true; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, fileContent); WinFormsUtils.ShowInfo(this, "CSR successfully saved"); DialogResult = DialogResult.OK; } } } catch (Exception ex) { WinFormsUtils.ShowError(this, ex); } }
private async void ButtonOk_Click(object sender, EventArgs e) { if (TextBoxPin.Text != TextBoxConfirmPin.Text) { WinFormsUtils.ShowInfo(this, "New PIN entries do not match"); return; } try { await WaitDialog.Execute(this, () => _slot.InitToken(TextBoxPin.Text, TextBoxTokenLabel.Text)); DialogResult = DialogResult.OK; } catch (Exception ex) { WinFormsUtils.ShowError(this, ex); } }
private void ButtonOk_Click(object sender, EventArgs e) { if (TextBoxNewPin.Text != TextBoxConfirmNewPin.Text) { WinFormsUtils.ShowInfo(this, "New PIN entries do not match"); return; } try { _slot.InitPin(TextBoxNewPin.Text); WinFormsUtils.ShowInfo(this, "User PIN successfuly initialized"); DialogResult = DialogResult.OK; } catch (Exception ex) { WinFormsUtils.ShowError(this, ex); } }
private void ButtonOk_Click(object sender, EventArgs e) { if (TextBoxNewPin.Text != TextBoxConfirmNewPin.Text) { WinFormsUtils.ShowInfo(this, "New PIN entries do not match"); return; } try { _slot.ChangePin(TextBoxCurrentPin.Text, TextBoxNewPin.Text); WinFormsUtils.ShowInfo(this, (_userType == CKU.CKU_SO) ? "SO PIN successfuly changed" : "PIN successfuly changed"); DialogResult = DialogResult.OK; } catch (Exception ex) { WinFormsUtils.ShowError(this, ex); } }
private void ButtonSave_Click(object sender, EventArgs e) { using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.FileName = _name; saveFileDialog.Filter = "All files (*.*)|*.*"; saveFileDialog.FilterIndex = 1; saveFileDialog.CreatePrompt = false; saveFileDialog.OverwritePrompt = true; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, _content); WinFormsUtils.ShowInfo(this, "Data object successfully exported"); } } }
private void ButtonSave_Click(object sender, EventArgs e) { using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.FileName = TextBoxName.Text; saveFileDialog.Filter = "All files (*.*)|*.*"; saveFileDialog.FilterIndex = 1; saveFileDialog.CreatePrompt = false; saveFileDialog.OverwritePrompt = true; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, Bytes); WinFormsUtils.ShowInfo(this, "Attribute value was successfully saved"); } } }
private void ButtonSave_Click(object sender, EventArgs e) { using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.FileName = "certificate.cer"; saveFileDialog.Filter = "All files (*.*)|*.*|DER encoded X.509 certificate (*.cer)|*.cer"; saveFileDialog.FilterIndex = 2; saveFileDialog.AddExtension = true; saveFileDialog.CreatePrompt = false; saveFileDialog.OverwritePrompt = true; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, _bytes); WinFormsUtils.ShowInfo(this, "Certificate successfully exported"); } } }
private int?GetSingleSelectedItemIndex(ListView listView) { if (listView == null) { throw new ArgumentNullException("listBox"); } if (listView.SelectedItems.Count < 1) { WinFormsUtils.ShowInfo(null, "Please select item first"); return(null); } if (listView.SelectedItems.Count > 1) { WinFormsUtils.ShowInfo(null, "Please select only one item"); return(null); } return(listView.SelectedItems[0].Index); }