Example #1
0
        public void Display(CircleController controller, VoterCertificate voterCertificate, VotingDescriptor2 voting)
        {
            this.controller = controller;
              this.voterCertificate = voterCertificate;
              this.voting = voting;

              this.votingControl.Display(voting);

              if (this.voterCertificate == null)
              {
            this.voteButton.Text = Resources.VotingDialogConfirm;
              }
              else
              {
            this.voteButton.Text = Resources.VotingDialogVote;
              }

              this.cancelButton.Enabled = true;
              this.nextButton.Enabled = this.votingControl.CanNext;
              this.previousButton.Enabled = this.votingControl.CanPrevious;
              this.voteButton.Enabled = this.voterCertificate == null || this.votingControl.Valid;
        }
Example #2
0
        public void Download(VotingDescriptor2 voting)
        {
            Begin();
              Status.VotingClient.ActivateVoter();
              Status.VotingClient.DownloadVoting(voting.Id, Status.DataPath, DownloadVotingComplete);

              if (!WaitForCompletion())
              {
            throw this.exception;
              }
        }
Example #3
0
        public void Delete(VotingDescriptor2 voting, AdminCertificate adminCertificate)
        {
            var command = new DeleteVotingRequest.Command(voting.Id);
              var signedCommand = new Signed<DeleteVotingRequest.Command>(command, adminCertificate);

              Begin();
              Status.VotingClient.DeleteVoting(signedCommand, DeleteVotingComplete);

              if (!WaitForCompletion())
              {
            throw this.exception;
              }
        }
Example #4
0
        public VotingDescriptor Decipher(Certificate certificate, VotingDescriptor2 voting)
        {
            string fileName = string.Format("{0}@{1}.pi-auth", certificate.Id.ToString(), voting.Id.ToString());
              string filePath = Path.Combine(Status.DataPath, fileName);

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionAuthorityDecipher))
              {
            try
            {
              this.userCanceled = false;
              Begin();
              Status.VotingClient.CreateDeciphers(voting.Id, (AuthorityCertificate)certificate, filePath, AskForPartiallyDecipher, CreateDeciphersComplete);

              if (!WaitForCompletion() && !this.userCanceled)
              {
            throw this.exception;
              }
            }
            finally
            {
              certificate.Lock();
            }

            return this.votingDescriptor;
              }
              else
              {
            return voting;
              }
        }
Example #5
0
        public VotingResult Tally(VotingDescriptor2 voting, out IDictionary<Guid, VoteReceiptStatus> voteReceiptsStatus)
        {
            Begin();
              Status.VotingClient.ActivateVoter();
              Status.VotingClient.GetResult(voting.Id, LoadVoteReceipts(voting.Id), Config.InitialCheckProofCount, GetResultComplete);

              if (!WaitForCompletion())
              {
            throw this.exception;
              }

              voteReceiptsStatus = this.voteReceiptsStatus;
              return this.votingResult;
        }
Example #6
0
 private void Control_VotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     OnVotingAction(type, voting);
 }
Example #7
0
        private void GoVote(VotingDescriptor2 voting)
        {
            var certificate = Controller.GetVoterCertificateThatCanVote(voting);

              if (certificate != null)
              {
            Vote.VotingDialog.ShowVoting(Controller, certificate, voting);

            RefreshVotings();
              }
        }
Example #8
0
 public IEnumerable<VoterCertificate> GetVoterCertificates(VotingDescriptor2 voting)
 {
     return this.certificates.Keys
     .Where(certificate => certificate is VoterCertificate &&
       ((VoterCertificate)certificate).GroupId == voting.GroupId)
       .Select(certificate => certificate as VoterCertificate);
 }
Example #9
0
        private void GoShare(VotingDescriptor2 voting)
        {
            var certificate = Controller.GetAuthorityCertificate(voting);

              if (certificate != null)
              {
            Status.TextStatusDialog.ShowInfo(Controller, this);

            try
            {
              Controller.CreateShares(certificate, voting);
              var votings = Controller.GetVotingList();
              this.votingListsControl.Set(Controller, votings);
            }
            catch (Exception exception)
            {
              Error.ErrorDialog.ShowError(exception);
            }

            Status.TextStatusDialog.HideInfo();
              }
        }
Example #10
0
        private void GoTally(VotingDescriptor2 voting)
        {
            Status.TextStatusDialog.ShowInfo(Controller, this);

              try
              {
            IDictionary<Guid, VoteReceiptStatus> voteReceiptStatus;
            var votingResult = Controller.Tally(voting, out voteReceiptStatus);
            Result.ResultDisplayDialog.ShowResult(votingResult, voteReceiptStatus);
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }

              Status.TextStatusDialog.HideInfo();
        }
Example #11
0
        private void GoDownload(VotingDescriptor2 voting)
        {
            Status.TextStatusDialog.ShowInfo(Controller, this);

              try
              {
            Controller.Download(voting);

            var votings = Controller.GetVotingList();
            this.votingListsControl.Set(Controller, votings);
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }

              Status.TextStatusDialog.HideInfo();
        }
Example #12
0
        private void GoDeleteStored(VotingDescriptor2 voting)
        {
            try
              {
            if (!voting.OfflinePath.IsNullOrEmpty() &&
            Directory.Exists(voting.OfflinePath))
            {
              Directory.Delete(voting.OfflinePath, true);

              RefreshVotings();
            }
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }
        }
Example #13
0
        private void GoDelete(VotingDescriptor2 voting)
        {
            Status.TextStatusDialog.ShowInfo(Controller, this);

              var adminCertificate = Controller.GetAdminCertificate();

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(adminCertificate, GuiResources.UnlockActionDelete))
              {
            try
            {
              if (adminCertificate != null)
              {
            Controller.Delete(voting, adminCertificate);

            var votings = Controller.GetVotingList();
            this.votingListsControl.Set(Controller, votings);
              }
            }
            catch (Exception exception)
            {
              Error.ErrorDialog.ShowError(exception);
            }
            finally
            {
              adminCertificate.Lock();
              Status.TextStatusDialog.HideInfo();
            }
              }
        }
Example #14
0
        public AuthorityCertificate GetAuthorityCertificate(VotingDescriptor2 voting)
        {
            var certificates = GetAuthorityCertificates(voting.VoteFrom);

              return certificates.Where(certificate => voting.Authorities.Any(authority => authority.IsIdentic(certificate)) &&
                          !voting.AuthoritiesDone.Contains(certificate.Id))
                          .FirstOrDefault();
        }
Example #15
0
 private void VotingListsControl_VotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     switch (type)
       {
     case VotingActionType.Type1:
       switch (voting.Status)
       {
     case VotingStatus.New:
       GoShare(voting);
       break;
     case VotingStatus.Sharing:
       GoCheck(voting);
       break;
     case VotingStatus.Voting:
       GoVote(voting);
       break;
     case VotingStatus.Deciphering:
       GoDecipher(voting);
       break;
     case VotingStatus.Finished:
     case VotingStatus.Offline:
       GoTally(voting);
       break;
       }
       break;
     case VotingActionType.Type2:
       switch (voting.Status)
       {
     case VotingStatus.New:
     case VotingStatus.Sharing:
     case VotingStatus.Ready:
       GoDelete(voting);
       break;
     case VotingStatus.Offline:
       GoDeleteStored(voting);
       break;
     case VotingStatus.Finished:
       GoDownload(voting);
       break;
       }
       break;
       }
 }
Example #16
0
 public VoterCertificate GetVoterCertificate(VotingDescriptor2 voting)
 {
     return this.certificates.Keys
     .Where(certificate => certificate is VoterCertificate &&
       ((VoterCertificate)certificate).GroupId == voting.GroupId)
       .FirstOrDefault() as VoterCertificate;
 }
Example #17
0
 private void ScheduledVotingListControl_VotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     OnVotingAction(type, voting);
 }
Example #18
0
        public VoterCertificate GetVoterCertificateThatCanVote(VotingDescriptor2 voting)
        {
            var receipts = LoadVoteReceipts(voting.Id);

              return this.certificates.Keys
            .Where(certificate => certificate is VoterCertificate &&
              certificate.Validate(Status.CertificateStorage) == CertificateValidationResult.Valid &&
              ((VoterCertificate)certificate).GroupId == voting.GroupId &&
              !receipts.Any(receipt => receipt.Value.VoterId.Equals(certificate.Id)))
              .FirstOrDefault() as VoterCertificate;
        }
Example #19
0
        public VotingDescriptor CheckShares(Certificate certificate, VotingDescriptor2 voting)
        {
            string fileName = string.Format("{0}@{1}.pi-auth", certificate.Id.ToString(), voting.Id.ToString());
              string filePath = Path.Combine(Status.DataPath, fileName);

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionAuthorityCheckShares))
              {
            try
            {
              Begin();
              Status.VotingClient.CheckShares(voting.Id, (AuthorityCertificate)certificate, filePath, CheckSharesComplete);

              if (WaitForCompletion())
              {
            if (this.acceptShares)
            {
              MessageForm.Show(Resources.ControllerCheckSharesOk, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
              MessageForm.Show(Resources.ControllerCheckSharesFailed, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
              }
              else
              {
            throw this.exception;
              }
            }
            finally
            {
              certificate.Lock();
            }

            return this.votingDescriptor;
              }
              else
              {
            return voting;
              }
        }
Example #20
0
        public void Vote(VoterCertificate voterCertificate, VotingDescriptor2 voting, IEnumerable<IEnumerable<bool>> vota)
        {
            Begin();
              Status.VotingClient.ActivateVoter();
              Status.VotingClient.Vote(this.votings[voting.Id].Material, voterCertificate, vota, VoteComplete);

              if (WaitForCompletion())
              {
            this.voteReceipt.Save(
              Path.Combine(Status.DataPath,
              Files.VoteReceiptFileName(voterCertificate.Id, voting.Id)));
            MessageForm.Show(Resources.ControllerVoteCast, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
              }
              else
              {
            throw this.exception;
              }
        }
Example #21
0
        public VotingDescriptor CreateShares(Certificate certificate, VotingDescriptor2 voting)
        {
            string fileName = string.Format("{0}@{1}.pi-auth", certificate.Id.ToString(), voting.Id.ToString());
              string filePath = Path.Combine(Status.DataPath, fileName);

              if (Circle.Vote.VotingDialog.ShowVoting(this, null, voting) == DialogResult.OK)
              {
            if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionAuthorityCreateShares))
            {
              try
              {
            Begin();
            Status.VotingClient.CreateSharePart(voting.Id, (AuthorityCertificate)certificate, filePath, CreateSharesCompleteCallBack);

            if (!WaitForCompletion())
            {
              throw this.exception;
            }
              }
              finally
              {
            certificate.Lock();
              }

              return this.votingDescriptor;
            }
              }

              return voting;
        }
Example #22
0
 private void OnVotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     if (VotingAction != null)
       {
     VotingAction(type, voting);
       }
 }
Example #23
0
 public static DialogResult ShowVoting(CircleController controller, VoterCertificate voterCertificate, VotingDescriptor2 voting)
 {
     VotingDialog dialog = new VotingDialog();
       dialog.Display(controller, voterCertificate, voting);
       return dialog.ShowDialog();
 }