Exemplo n.º 1
0
        private void PrintRevoke(XRect bounds)
        {
            var font = GetFont();

              Table table = new Table(font);
              table.AddColumn(bounds.Width);
              table.AddRow(GuiResources.SigningRequestDocumentRevokedForgotten);
              table.AddRow(GuiResources.SigningRequestDocumentRevokedLost);
              table.AddRow(GuiResources.SigningRequestDocumentRevokedStolen);

              if (this.certificate is VoterCertificate)
              {
            table.AddRow(GuiResources.SigningRequestDocumentRevokedNoLonger);
              }
              else
              {
            table.AddRow(GuiResources.SigningRequestDocumentRevokedNoMoreFx);
              }

              table.AddRow(GuiResources.SigningRequestDocumentRevokedError);
              table.Draw(new XPoint(bounds.Left, bounds.Top), this.graphics);

              SignObject caSign = new SignObject(this.graphics, GuiResources.SigningRequestDocumentSignCA, GuiResources.SigningRequestDocumentSignSignature, GuiResources.SigningRequestDocumentSignDate, font);
              caSign.SetCenterTop(bounds.Left + bounds.Width / 8f * 7f, bounds.Top);
              caSign.Draw();
        }
Exemplo n.º 2
0
        private void PrintResponse(XRect bounds)
        {
            var font = GetFont();

              Table table = new Table(font);
              table.AddColumn(bounds.Width);
              table.AddRow(GuiResources.SigningRequestDocumentAccepted);
              table.AddRow(GuiResources.SigningRequestDocumentRefusedFingerprintMismatch);
              table.AddRow(GuiResources.SigningRequestDocumentRefusedLost);
              table.AddRow(GuiResources.SigningRequestDocumentRefusedForgotten);
              table.AddRow(GuiResources.SigningRequestDocumentRefusedSignatureInvalid);

              if (this.certificate is VoterCertificate)
              {
            table.AddRow(GuiResources.SigningRequestDocumentRefusedNoMember);
              }
              else
              {
            table.AddRow(GuiResources.SigningRequestDocumentRefusedNotFx);
              }

              table.AddRow(GuiResources.SigningRequestDocumentRefusedHasCertificate);
              table.Draw(new XPoint(bounds.Left, bounds.Top), this.graphics);

              SignObject caSign = new SignObject(this.graphics, GuiResources.SigningRequestDocumentSignCA, GuiResources.SigningRequestDocumentSignSignature, GuiResources.SigningRequestDocumentSignDate, font);
              caSign.SetCenterTop(bounds.Left + bounds.Width / 8f * 7f, bounds.Top);
              caSign.Draw();
        }
Exemplo n.º 3
0
        private void PrintInfo(XRect bounds)
        {
            var font = GetFont();

              var textFormatter0 = new XTextFormatter(this.graphics);
              textFormatter0.Alignment = XParagraphAlignment.Left;
              textFormatter0.DrawString(
            GuiResources.SigningRequestDocumentInfo,
            font,
            XBrushes.Black,
            new XRect(bounds.Left, bounds.Top, bounds.Width, 100d));

              Table table = new Table(font);
              table.AddColumn(FirstColumnWidth);
              table.AddColumn(bounds.Width - FirstColumnWidth);
              table.AddRow(GuiResources.SigningRequestDocumentSendTo, GuiResources.SigningRequestDocumentPpsAddress1);
              table.AddRow(string.Empty, GuiResources.SigningRequestDocumentPpsAddress2);
              table.Draw(new XPoint(bounds.Left, bounds.Top + 40f), this.graphics);

              var textFormatter1 = new XTextFormatter(this.graphics);
              textFormatter0.Alignment = XParagraphAlignment.Left;
              textFormatter1.DrawString(
            GuiResources.SigningRequestDocumentLeave,
            font,
            XBrushes.Black,
            new XRect(bounds.Left, bounds.Top + 90d, bounds.Width, 100d));
        }
Exemplo n.º 4
0
        private void PrintParentData(XRect bounds)
        {
            if (!(this.signatureRequest is SignatureRequest2))
            throw new InvalidOperationException("Must be a SignatureRequest2");

              SignatureRequest2 signatureRequest2 = (SignatureRequest2)this.signatureRequest;
              Certificate signingCertificate = signatureRequest2.SigningCertificate;

              var font = GetFont();
              Table table = new Table(font);
              table.AddColumn(FirstColumnWidth);
              table.AddColumn(bounds.Width - FirstColumnWidth);

              table.AddRow(GuiResources.SigningRequestDocumentParent, 2, XFontStyle.Regular);
              table.AddRow(" ", 2);

              string certificateId = signingCertificate.Id.ToString();
              int idLength = certificateId.Length / 2;
              table.AddRow(GuiResources.SigningRequestDocumentCertificateId, certificateId.Substring(0, idLength));
              table.AddRow(string.Empty, certificateId.Substring(idLength));

              string fingerprint = signingCertificate.Fingerprint.Replace(" ", string.Empty);
              int fingerprintLength = fingerprint.Length / 4;
              table.AddRow(GuiResources.SigningRequestDocumentFingerprint, FourBlocks(fingerprint.Substring(0, fingerprintLength)));
              table.AddRow(string.Empty, FourBlocks(fingerprint.Substring(fingerprintLength, fingerprintLength)));
              table.AddRow(string.Empty, FourBlocks(fingerprint.Substring(fingerprintLength * 2, fingerprintLength)));
              table.AddRow(string.Empty, FourBlocks(fingerprint.Substring(fingerprintLength * 3, fingerprintLength)));

              table.Draw(new XPoint(bounds.Left, bounds.Top), this.graphics);
        }
Exemplo n.º 5
0
        private void PrintData(XRect bounds)
        {
            QRCodeEncoder qrEncoder = new QRCodeEncoder();
              qrEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
              qrEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
              qrEncoder.QRCodeVersion = 7;
              qrEncoder.QRCodeScale = 5;
              string url = string.Format(
            "https://pivote.piratenpartei.ch/sign.aspx?id={0}&k={1}",
            this.certificate.Id.ToString(),
            this.signatureRequest.Key.ToHexString());
              var image = qrEncoder.Encode(url);

              var stream = new System.IO.MemoryStream();
              image.Save(stream, ImageFormat.Png);
              var pngImage = Image.FromStream(stream);

              this.graphics.DrawImage(
            pngImage,
            bounds.Right - XUnit.FromInch(image.Width / graphics.Graphics.DpiX).Point,
            bounds.Top);

              var font = GetFont();
              Table table = new Table(font);
              table.AddColumn(FirstColumnWidth);
              table.AddColumn(bounds.Width - FirstColumnWidth);

              table.AddRow(GuiResources.SigningRequestDocumentRequest, 2, XFontStyle.Regular);

              table.AddRow(" ", 2);

              table.AddRow(GuiResources.SigningRequestDocumentFamilyName, this.signatureRequest.FamilyName);
              table.AddRow(GuiResources.SigningRequestDocumentFirstName, this.signatureRequest.FirstName);
              table.AddRow(GuiResources.SigningRequestDocumentEmailAddress, this.signatureRequest.EmailAddress);
              if (this.certificate is VoterCertificate)
            table.AddRow(GuiResources.SigningRequestDocumentGroup, this.getGroupName(((VoterCertificate)this.certificate).GroupId));
              table.AddRow(GuiResources.SigningRequestDocumentCertificateType, this.certificate.TypeText);

              string certificateId = this.certificate.Id.ToString();
              int idLength = certificateId.Length / 2;
              table.AddRow(GuiResources.SigningRequestDocumentCertificateId, certificateId.Substring(0, idLength));
              table.AddRow(string.Empty, certificateId.Substring(idLength));

              string requestKey = this.signatureRequest.Key.ToHexString();
              int requestKeyLength = requestKey.Length / 4;
              table.AddRow(GuiResources.SigningRequestDocumentRequestKey, FourBlocks(requestKey.Substring(0, requestKeyLength)));
              table.AddRow(string.Empty, FourBlocks(requestKey.Substring(requestKeyLength, requestKeyLength)));
              table.AddRow(string.Empty, FourBlocks(requestKey.Substring(requestKeyLength * 2, requestKeyLength)));
              table.AddRow(string.Empty, FourBlocks(requestKey.Substring(requestKeyLength * 3, requestKeyLength)));

              string fingerprint = this.certificate.Fingerprint.Replace(" ", string.Empty);
              int fingerprintLength = fingerprint.Length / 4;
              table.AddRow(GuiResources.SigningRequestDocumentFingerprint, FourBlocks(fingerprint.Substring(0, fingerprintLength)));
              table.AddRow(string.Empty, FourBlocks(fingerprint.Substring(fingerprintLength, fingerprintLength)));
              table.AddRow(string.Empty, FourBlocks(fingerprint.Substring(fingerprintLength * 2, fingerprintLength)));
              table.AddRow(string.Empty, FourBlocks(fingerprint.Substring(fingerprintLength * 3, fingerprintLength)));

              table.Draw(new XPoint(bounds.Left, bounds.Top), this.graphics);
        }