/// <summary>Creates a <see cref="PrimaryKeyItem"/> to represent the <see cref="PrimaryKey"/> from the search /// result. /// </summary> protected virtual PrimaryKeyItem CreateResultItem(PrimaryKey key) { PrimaryKeyItem item = new PrimaryKeyItem(key, PGPUI.GetKeyName(key)); item.SubItems.Add(key.CreationTime.ToShortDateString()); item.SubItems.Add(key.ShortKeyId); item.SubItems.Add(key.Revoked ? "Revoked" : key.Expired ? "Expired" : "Valid"); if(key.Revoked || key.Expired) item.ForeColor = SystemColors.GrayText; return item; }
/// <summary>Initializes this form with the subkeys to revoke.</summary> public void Initialize(Subkey[] subkeys) { if(subkeys == null) throw new ArgumentNullException(); keyList.Items.Clear(); foreach(Subkey key in subkeys) keyList.Items.Add(PGPUI.GetKeyName(key)); btnOK.Enabled = rbDirect.Enabled = subkeys.Length != 0; if(rbDirect.Enabled) rbDirect.Checked = true; rbIndirect.Enabled = revokingKeys.Enabled = false; }
void btnBrowse_Click(object sender, EventArgs e) { string defaultFilename = PGPUI.MakeSafeFilename("revoke " + PGPUI.GetKeyName(keyToRevoke) + ".txt"); SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = ".txt"; sfd.FileName = defaultFilename; sfd.Filter = "Text Files (*.txt)|*.txt|ASCII Files (*.asc)|*.asc|All Files (*.*)|*.*"; sfd.OverwritePrompt = true; sfd.Title = "Save Revocation Certificate"; sfd.SupportMultiDottedExtensions = true; if(sfd.ShowDialog() == DialogResult.OK) txtFile.Text = sfd.FileName; }
/// <summary>Initializes this form with the given designated revoker key, and a list of keys owned by the user that /// can be selected to be revocable by the revoker key. /// </summary> public void Initialize(PrimaryKey revokerKey, PrimaryKey[] ownedKeys) { if(revokerKey == null || ownedKeys == null) throw new ArgumentNullException(); lblRevokingKey.Text = "You are making this key a designated revoker:\n" + PGPUI.GetKeyName(revokerKey); this.ownedKeys.Items.Clear(); foreach(PrimaryKey key in ownedKeys) { if(key == null) throw new ArgumentException("A key was null."); this.ownedKeys.Items.Add(new KeyItem(key)); } btnOK.Enabled = this.ownedKeys.Items.Count != 0; if(this.ownedKeys.Items.Count != 0) this.ownedKeys.SelectedIndex = 0; }
/// <summary>Initializes a new <see cref="KeyItem"/> with the given key.</summary> public KeyItem(PrimaryKey key) : base(key, PGPUI.GetKeyName(key)) { }
/// <summary>Creates the <see cref="PrimaryKeyItem"/> used to display the given key.</summary> protected virtual PrimaryKeyItem CreatePrimaryKeyItem(PrimaryKey key) { if(key == null) throw new ArgumentNullException(); return new PrimaryKeyItem(key, PGPUI.GetKeyName(key)); }
/// <summary>Initializes this form with the public key whose signatures will be displayed.</summary> public void Initialize(PrimaryKey publicKey) { if(publicKey == null) throw new ArgumentNullException(); Text = lblDescription.Text = "Key Signatures for " + PGPUI.GetKeyName(publicKey); sigList.Initialize(publicKey); }
/// <summary>Initializes this form with the key for which the revocation certificate will be generated, and a list of /// keys for which the user has the secret key, which could possibly serve as designated revokers. /// </summary> public void Initialize(PrimaryKey keyToRevoke, PrimaryKey[] ownedKeys) { if(keyToRevoke == null || ownedKeys == null) throw new ArgumentNullException(); rbDirect.Enabled = Array.IndexOf(ownedKeys, keyToRevoke) != -1; revokingKeys.Items.Clear(); foreach(PrimaryKey key in ownedKeys) { if(key == null) throw new ArgumentException("A key was null."); if(keyToRevoke.DesignatedRevokers.Contains(key.Fingerprint)) { revokingKeys.Items.Add(new KeyItem(key)); } } rbIndirect.Enabled = revokingKeys.Items.Count != 0; if(revokingKeys.Items.Count != 0) revokingKeys.SelectedIndex = 0; if(rbDirect.Enabled) rbDirect.Checked = true; else if(rbIndirect.Enabled) rbIndirect.Checked = true; else rbDirect.Checked = rbIndirect.Checked = false; btnOK.Enabled = rbDirect.Enabled || rbIndirect.Enabled; lblRevokedKey.Text = btnOK.Enabled ? "The certificate will be generated for:\n" + PGPUI.GetKeyName(keyToRevoke) : "You cannot generate the certificate because you do not have its secret key or the secret key of a "+ "designated revoker."; this.keyToRevoke = keyToRevoke; }