using System.Windows.Forms;
using System.Collections;
using nsoftware.SecureBlackbox;
namespace PKCS11CertificateStorage
{
///
/// Summary description for ValidationResultForm.
///
public class ValidationResultForm : System.Windows.Forms.Form
{
private ArrayList objects;
private System.Windows.Forms.Button btnClose;
private ComboBox cbSignatures;
private Panel pSignatureInfo;
private Label lTimestamp;
private TextBox tbReason;
private Label lReason;
private TextBox tbAuthorName;
private Label lAuthorName;
private Label lTitle;
private Label lChainValidationResult;
private Label lSignatureValidationResult;
private SaveFileDialog saveDialog;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public ValidationResultForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
objects = new ArrayList();
}
public void Init(PDFVerifier verifier)
{
cbSignatures.Items.Clear();
objects.Clear();
pSignatureInfo.Visible = false;
for (int i = 0; i < verifier.Signatures.Count; i++)
{
cbSignatures.Items.Add(verifier.Signatures[i].SignatureName);
objects.Add(verifier.Signatures[i]);
}
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.btnClose = new System.Windows.Forms.Button();
this.cbSignatures = new System.Windows.Forms.ComboBox();
this.pSignatureInfo = new System.Windows.Forms.Panel();
this.lChainValidationResult = new System.Windows.Forms.Label();
this.lSignatureValidationResult = new System.Windows.Forms.Label();
this.lTimestamp = new System.Windows.Forms.Label();
this.tbReason = new System.Windows.Forms.TextBox();
this.lReason = new System.Windows.Forms.Label();
this.tbAuthorName = new System.Windows.Forms.TextBox();
this.lAuthorName = new System.Windows.Forms.Label();
this.lTitle = new System.Windows.Forms.Label();
this.saveDialog = new System.Windows.Forms.SaveFileDialog();
this.pSignatureInfo.SuspendLayout();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnClose.Location = new System.Drawing.Point(253, 266);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 25);
this.btnClose.TabIndex = 4;
this.btnClose.Text = "Close";
//
// cbSignatures
//
this.cbSignatures.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbSignatures.Location = new System.Drawing.Point(12, 25);
this.cbSignatures.Name = "cbSignatures";
this.cbSignatures.Size = new System.Drawing.Size(312, 21);
this.cbSignatures.TabIndex = 7;
this.cbSignatures.SelectedIndexChanged += new System.EventHandler(this.cbSignatures_SelectedIndexChanged);
//
// pSignatureInfo
//
this.pSignatureInfo.Controls.Add(this.lChainValidationResult);
this.pSignatureInfo.Controls.Add(this.lSignatureValidationResult);
this.pSignatureInfo.Controls.Add(this.lTimestamp);
this.pSignatureInfo.Controls.Add(this.tbReason);
this.pSignatureInfo.Controls.Add(this.lReason);
this.pSignatureInfo.Controls.Add(this.tbAuthorName);
this.pSignatureInfo.Controls.Add(this.lAuthorName);
this.pSignatureInfo.Location = new System.Drawing.Point(12, 57);
this.pSignatureInfo.Name = "pSignatureInfo";
this.pSignatureInfo.Size = new System.Drawing.Size(312, 190);
this.pSignatureInfo.TabIndex = 6;
this.pSignatureInfo.Visible = false;
//
// lChainValidationResult
//
this.lChainValidationResult.Location = new System.Drawing.Point(0, 150);
this.lChainValidationResult.Name = "lChainValidationResult";
this.lChainValidationResult.Size = new System.Drawing.Size(288, 16);
this.lChainValidationResult.TabIndex = 10;
this.lChainValidationResult.Text = "Chain Validation Result:";
//
// lSignatureValidationResult
//
this.lSignatureValidationResult.Location = new System.Drawing.Point(0, 125);
this.lSignatureValidationResult.Name = "lSignatureValidationResult";
this.lSignatureValidationResult.Size = new System.Drawing.Size(288, 16);
this.lSignatureValidationResult.TabIndex = 9;
this.lSignatureValidationResult.Text = "Signature Validation Result:";
//
// lTimestamp
//
this.lTimestamp.Location = new System.Drawing.Point(0, 96);
this.lTimestamp.Name = "lTimestamp";
this.lTimestamp.Size = new System.Drawing.Size(288, 16);
this.lTimestamp.TabIndex = 7;
this.lTimestamp.Text = "Timestamp:";
//
// tbReason
//
this.tbReason.Location = new System.Drawing.Point(0, 64);
this.tbReason.Name = "tbReason";
this.tbReason.ReadOnly = true;
this.tbReason.Size = new System.Drawing.Size(312, 20);
this.tbReason.TabIndex = 4;
//
// lReason
//
this.lReason.Location = new System.Drawing.Point(0, 48);
this.lReason.Name = "lReason";
this.lReason.Size = new System.Drawing.Size(280, 16);
this.lReason.TabIndex = 3;
this.lReason.Text = "Reason for signing:";
//
// tbAuthorName
//
this.tbAuthorName.Location = new System.Drawing.Point(0, 16);
this.tbAuthorName.Name = "tbAuthorName";
this.tbAuthorName.ReadOnly = true;
this.tbAuthorName.Size = new System.Drawing.Size(312, 20);
this.tbAuthorName.TabIndex = 2;
//
// lAuthorName
//
this.lAuthorName.Location = new System.Drawing.Point(0, 0);
this.lAuthorName.Name = "lAuthorName";
this.lAuthorName.Size = new System.Drawing.Size(280, 16);
this.lAuthorName.TabIndex = 0;
this.lAuthorName.Text = "Author\'s name:";
//
// lTitle
//
this.lTitle.Location = new System.Drawing.Point(12, 9);
this.lTitle.Name = "lTitle";
this.lTitle.Size = new System.Drawing.Size(320, 16);
this.lTitle.TabIndex = 5;
this.lTitle.Text = "The document contains the following digital signatures:";
//
// saveDialog
//
this.saveDialog.Filter = "PDF documents (*.pdf)|*.pdf|All files (*.*)|*.*";
this.saveDialog.InitialDirectory = ".";
//
// ValidationResultForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(334, 301);
this.Controls.Add(this.cbSignatures);
this.Controls.Add(this.pSignatureInfo);
this.Controls.Add(this.lTitle);
this.Controls.Add(this.btnClose);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "ValidationResultForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Validation results";
this.pSignatureInfo.ResumeLayout(false);
this.pSignatureInfo.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private void cbSignatures_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (cbSignatures.SelectedIndex != -1)
{
PDFSignature sig = (PDFSignature)objects[cbSignatures.SelectedIndex];
if (sig.AuthorName.Length > 0)
tbAuthorName.Text = sig.AuthorName;
else
tbAuthorName.Text = "";
if (sig.Reason.Length > 0)
tbReason.Text = sig.Reason;
else
tbReason.Text = "";
lTimestamp.Text = "Timestamp: " + sig.ClaimedSigningTime.ToString() + " (local)";
switch (sig.SignatureValidationResult)
{
case SignatureValidities.svtValid: lSignatureValidationResult.Text = "Signature Validation Result: Valid"; break;
case SignatureValidities.svtCorrupted: lSignatureValidationResult.Text = "Signature Validation Result: Corrupted"; break;
case SignatureValidities.svtSignerNotFound: lSignatureValidationResult.Text = "Signature Validation Result: SignerNotFound"; break;
case SignatureValidities.svtFailure: lSignatureValidationResult.Text = "Signature Validation Result: Failure"; break;
default: lSignatureValidationResult.Text = "Signature Validation Result: Unknown"; break;
}
switch (sig.ChainValidationResult)
{
case ChainValidities.cvtValid: lChainValidationResult.Text = "Chain Validation Result: Valid"; break;
case ChainValidities.cvtValidButUntrusted: lChainValidationResult.Text = "Chain Validation Result: ValidButUntrusted"; break;
case ChainValidities.cvtInvalid: lChainValidationResult.Text = "Chain Validation Result: Invalid"; break;
case ChainValidities.cvtCantBeEstablished: lChainValidationResult.Text = "Chain Validation Result: CantBeEstablished"; break;
}
pSignatureInfo.Visible = true;
}
else
pSignatureInfo.Visible = false;
}
}
}