Exemplo n.º 1
0
        public void Display(CertificateAuthorityEntry entry, CertificateStorage storage, Certificate caCertificate)
        {
            Certificate certificate = entry.Certificate;
              SignatureRequest request = entry.RequestValue(caCertificate);

              this.idTextBox.Text = certificate.Id.ToString();
              this.typeTextBox.Text = certificate.TypeText;
              this.nameTextBox.Text = certificate.FullName;
              this.emailAddressTextBox.Text = request.EmailAddress;
              this.cantonTextBox.Text = certificate is VoterCertificate ? GroupList.GetGroupName(((VoterCertificate)certificate).GroupId) : "N/A";
              this.fingerprintTextBox.Text = certificate.Fingerprint;
              this.language = certificate.Language;
              this.certificate = entry.Certificate;

              LibraryResources.Culture = Language.English.ToCulture();
              this.reasonComboBox.Items.Add(LibraryResources.RevokedMoved);
              this.reasonComboBox.Items.Add(LibraryResources.RevokedStolen);
              this.reasonComboBox.Items.Add(LibraryResources.RevokedLost);
              this.reasonComboBox.Items.Add(LibraryResources.RevokedForgotten);
              this.reasonComboBox.Items.Add(LibraryResources.RevokedError);

              if (entry.Certificate is VoterCertificate)
              {
            this.reasonComboBox.Items.Add(LibraryResources.RevokedNoLonger);
              }
              else
              {
            this.reasonComboBox.Items.Add(LibraryResources.RevokedNoMoreFx);
              }
        }
Exemplo n.º 2
0
        public ListEntry(string fileName, CertificateAuthorityEntry entry, CACertificate caCertificate)
        {
            FileName = fileName;
              this.entry = entry;

              this.certificate = this.entry.Request.Certificate;
              this.request = this.entry.RequestValue(caCertificate);

              if (this.entry.Response != null)
              {
            this.response = this.entry.Response.Value;
              }
        }
Exemplo n.º 3
0
        public ListEntry(string fileName, CACertificate caCertificate)
        {
            FileName = fileName;
              this.entry = Serializable.Load<CertificateAuthorityEntry>(FileName);

              this.certificate = this.entry.Request.Certificate;
              this.request = this.entry.RequestValue(caCertificate);

              if (this.entry.Response != null)
              {
            this.response = this.entry.Response.Value;
              }
        }
Exemplo n.º 4
0
        private void importRequestsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
              dialog.Title = "Open Signature Requests";
              dialog.CheckPathExists = true;
              dialog.CheckFileExists = true;
              dialog.Multiselect = true;
              dialog.Filter = Files.SignatureRequestFileFilter;

              if (dialog.ShowDialog() == DialogResult.OK)
              {
            List<string> alreadyAddedList = new List<string>();
            List<string> invalidList = new List<string>();

            foreach (string fileName in dialog.FileNames)
            {
              Secure<SignatureRequest> secureSignatureRequest = Serializable.Load<Secure<SignatureRequest>>(fileName);

              if (secureSignatureRequest.VerifySimple())
              {
            if (Entries.Any(listEntry => listEntry.Certificate.Id == secureSignatureRequest.Certificate.Id))
            {
              alreadyAddedList.Add(fileName);
            }
            else
            {
              CertificateAuthorityEntry entry = new CertificateAuthorityEntry(secureSignatureRequest);
              string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry");
              entry.Save(DataPath(entryFileName));

              ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate);
              Entries.Add(listEntry);
              this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate));
            }
              }
              else
              {
            invalidList.Add(fileName);
              }
            }

            if (invalidList.Count > 0)
            {
              StringBuilder message = new StringBuilder();
              message.AppendLine("The following request are not valid:");
              invalidList.ForEach(invalidRequest => message.AppendLine(invalidRequest));
              MessageForm.Show(message.ToString(), "Pi-Vote CA GUI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (alreadyAddedList.Count > 0)
            {
              StringBuilder message = new StringBuilder();
              message.AppendLine("The following request are already in your list:");
              alreadyAddedList.ForEach(invalidRequest => message.AppendLine(invalidRequest));
              MessageForm.Show(message.ToString(), "Pi-Vote CA GUI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
              }
        }
Exemplo n.º 5
0
        private void createServerCertifiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateServerDialog dialog = new CreateServerDialog();

              if (dialog.ShowDialog() == DialogResult.OK)
              {
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.Title = "Save Server Certificate";
            saveDialog.CheckPathExists = true;
            saveDialog.Filter = Files.CertificateFileFilter;

            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
              ServerCertificate certificate = new ServerCertificate(dialog.FullName);
              certificate.CreateSelfSignature();

              SignatureRequest request = new SignatureRequest(dialog.FullName, string.Empty, string.Empty);
              Secure<SignatureRequest> signedRequest = new Secure<SignatureRequest>(request, CaCertificate, certificate);

              CertificateAuthorityEntry entry = new CertificateAuthorityEntry(signedRequest);
              entry.Sign(CaCertificate, DateTime.Now, dialog.ValidUntil);
              certificate.AddSignature(entry.Response.Value.Signature);

              string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry");
              entry.Save(DataPath(entryFileName));

              ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate);
              Entries.Add(listEntry);
              this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate));

              certificate.Save(saveDialog.FileName);
            }
              }
        }
Exemplo n.º 6
0
        private void createAdminCertificateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateAdminDialog dialog = new CreateAdminDialog();

              if (dialog.ShowDialog() == DialogResult.OK)
              {
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.Title = "Save Admin Certificate";
            saveDialog.CheckPathExists = true;
            saveDialog.Filter = Files.CertificateFileFilter;

            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
              string fullName = string.Format("{0} {1}, {2}", dialog.FirstName, dialog.FamilyName, dialog.Function);
              AdminCertificate certificate = new AdminCertificate(Language.English, dialog.Passphrase, fullName);
              certificate.CreateSelfSignature();

              SignatureRequest request = new SignatureRequest(dialog.FirstName, dialog.FamilyName, dialog.EmailAddress);
              Secure<SignatureRequest> signedRequest = new Secure<SignatureRequest>(request, CaCertificate, certificate);

              CertificateAuthorityEntry entry = new CertificateAuthorityEntry(signedRequest);
              entry.Sign(CaCertificate, DateTime.Now, dialog.ValidUntil);
              certificate.AddSignature(entry.Response.Value.Signature);

              string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry");
              entry.Save(DataPath(entryFileName));

              ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate);
              Entries.Add(listEntry);
              this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate));

              certificate.Save(saveDialog.FileName);
            }
              }
        }