Examples of PdfPKCS7


Examples of com.itextpdf.text.pdf.PdfPKCS7

            oscp = ocspClient.getEncoded();
          }
        }
      }

      PdfPKCS7 pkcs7 = new PdfPKCS7(privateKey, chain, null, digestType.getAlgorithm(), null, false);
      byte[] authenticatedAttributes = pkcs7.getAuthenticatedAttributeBytes(hash, calendar, oscp);
      pkcs7.update(authenticatedAttributes, 0, authenticatedAttributes.length);
      pkcs7.setLocation(this.request.getLocation());
      pkcs7.setReason(this.request.getReason());

      if (tsc == null) {
        pkcs7.setSignDate(calendar);
      }

      byte[] encodedPkcs7 = pkcs7.getEncodedPKCS7(hash, calendar, tsc, oscp);

      byte[] output = new byte[(contentSize - 2) / 2];

      System.arraycopy(encodedPkcs7, 0, output, 0, encodedPkcs7.length);
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

      Collection<Signature> signatures = new ArrayList<Signature>();
      if (fields != null) {
        List<String> list = fields.getSignatureNames();
        if ((list != null) && (!list.isEmpty())) {
          for (String str : list) {
            PdfPKCS7 pk = fields.verifySignature(str);

            PdfString string = fields.getSignatureDictionary(str).getAsString(PdfName.CONTENTS);
            byte[] content = string.getBytes();

            X509Certificate certificate = pk.getSigningCertificate();
            Certificate[] chain = pk.getSignCertificateChain();

            byte[] encoded = content;
            TimeStamp timeStamp = null;
            String location = pk.getLocation();
            String reason = pk.getReason();
            Date date = pk.getSignDate().getTime();
            Boolean valid = Boolean.TRUE;
            Signatory signatory = this.toSignatory(certificate);

            Store store = new JCAStore(KeyStoreType.JKS);
            store.add(new CertificateEntry(new Alias(certificate.getSerialNumber().toString()), certificate));
            Object[] fails = PdfPKCS7.verifyCertificates(chain, store.toKeyStore(), pk.getCRLs(), pk.getSignDate());
            if (ConditionUtils.isNotEmpty(fails)) {
              valid = Boolean.FALSE;
            }

            TimeStampToken timeStampToken = pk.getTimeStampToken();
            if (timeStampToken != null) {
              timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
              timeStampToken.getTimeStampInfo();
              if (valid.booleanValue()) {
                boolean ok = pk.verifyTimestampImprint();
                valid = Boolean.valueOf(ok);
              }
            }

            Signature sig = new Signature();
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

            oscp = ocspClient.getEncoded();
          }
        }
      }

      PdfPKCS7 pkcs7 = new PdfPKCS7(privateKey, chain, null, digestType.getAlgorithm(), null, false);
      byte[] authenticatedAttributes = pkcs7.getAuthenticatedAttributeBytes(hash, calendar, oscp);
      pkcs7.update(authenticatedAttributes, 0, authenticatedAttributes.length);
      pkcs7.setLocation(this.parameters.getLocation());
      pkcs7.setReason(this.parameters.getReason());

      if (tsc == null) {
        pkcs7.setSignDate(calendar);
      }

      byte[] encodedPkcs7 = pkcs7.getEncodedPKCS7(hash, calendar, tsc, oscp);

      byte[] output = new byte[(contentSize - 2) / 2];

      System.arraycopy(encodedPkcs7, 0, output, 0, encodedPkcs7.length);
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

      Collection<Signature> signatures = new ArrayList<Signature>();
      if (fields != null) {
        List<String> list = fields.getSignatureNames();
        if ((list != null) && (!list.isEmpty())) {
          for (String str : list) {
            PdfPKCS7 pk = fields.verifySignature(str);

            PdfString string = fields.getSignatureDictionary(str).getAsString(PdfName.CONTENTS);
            byte[] content = string.getBytes();

            X509Certificate certificate = pk.getSigningCertificate();
            Certificate[] chain = pk.getSignCertificateChain();

            byte[] encoded = content;
            TimeStamp timeStamp = null;
            String location = pk.getLocation();
            String reason = pk.getReason();
            Date date = pk.getSignDate().getTime();
            Boolean valid = Boolean.TRUE;
            Signatory signatory = this.toSignatory(certificate);

            Store store = new JCAStore(KeyStoreType.JKS);
            store.add(new CertificateEntry(new Alias(certificate.getSerialNumber().toString()), certificate));
            Object[] fails = PdfPKCS7.verifyCertificates(chain, store.toKeyStore(), pk.getCRLs(), pk.getSignDate());
            if (ConditionUtils.isNotEmpty(fails)) {
              valid = Boolean.FALSE;
            }

            TimeStampToken timeStampToken = pk.getTimeStampToken();
            if (timeStampToken != null) {
              timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
              timeStampToken.getTimeStampInfo();
              if (valid.booleanValue()) {
                boolean ok = pk.verifyTimestampImprint();
                valid = Boolean.valueOf(ok);
              }
            }

            Signature sig = new Signature();
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

            oscp = ocspClient.getEncoded();
          }
        }
      }

      PdfPKCS7 pkcs7 = new PdfPKCS7(privateKey, chain, null, digestType.getAlgorithm(), null, false);
      byte[] authenticatedAttributes = pkcs7.getAuthenticatedAttributeBytes(hash, calendar, oscp);
      pkcs7.update(authenticatedAttributes, 0, authenticatedAttributes.length);
      pkcs7.setLocation(this.parameters.getLocation());
      pkcs7.setReason(this.parameters.getReason());

      if (tsc == null) {
        pkcs7.setSignDate(calendar);
      }

      byte[] encodedPkcs7 = pkcs7.getEncodedPKCS7(hash, calendar, tsc, oscp);

      byte[] output = new byte[(contentSize - 2) / 2];

      System.arraycopy(encodedPkcs7, 0, output, 0, encodedPkcs7.length);
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

      Collection<Signature> signatures = new ArrayList<Signature>();
      if (fields != null) {
        List<String> list = fields.getSignatureNames();
        if ((list != null) && (!list.isEmpty())) {
          for (String str : list) {
            PdfPKCS7 pk = fields.verifySignature(str);

            PdfString string = fields.getSignatureDictionary(str).getAsString(PdfName.CONTENTS);
            byte[] content = string.getBytes();

            X509Certificate certificate = pk.getSigningCertificate();
            Certificate[] chain = pk.getSignCertificateChain();

            byte[] encoded = content;
            TimeStamp timeStamp = null;
            String location = pk.getLocation();
            String reason = pk.getReason();
            Date date = pk.getSignDate().getTime();
            Boolean valid = Boolean.TRUE;
            Signatory signatory = this.toSignatory(certificate);

            Store store = new JCAStore(KeyStoreType.JKS);
            store.add(new CertificateEntry(new Alias(certificate.getSerialNumber().toString()), certificate));
            Object[] fails = PdfPKCS7.verifyCertificates(chain, store.toKeyStore(), pk.getCRLs(), pk.getSignDate());
            if (ConditionUtils.isNotEmpty(fails)) {
              valid = Boolean.FALSE;
            }

            TimeStampToken timeStampToken = pk.getTimeStampToken();
            if (timeStampToken != null) {
              timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
              timeStampToken.getTimeStampInfo();
              if (valid.booleanValue()) {
                boolean ok = pk.verifyTimestampImprint();
                valid = Boolean.valueOf(ok);
              }
            }

            Signature sig = new Signature();
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

            oscp = ocspClient.getEncoded();
          }
        }
      }

      PdfPKCS7 pkcs7 = new PdfPKCS7(privateKey, chain, null, digestType.getAlgorithm(), null, false);
      byte[] authenticatedAttributes = pkcs7.getAuthenticatedAttributeBytes(hash, calendar, oscp);
      pkcs7.update(authenticatedAttributes, 0, authenticatedAttributes.length);

      if (this.parameters.getSignatureInfo() != null) {
        pkcs7.setLocation(this.parameters.getSignatureInfo().getLocation());
        pkcs7.setReason(this.parameters.getSignatureInfo().getReason());
        pkcs7.setSignName(this.parameters.getSignatureInfo().getName());
      }

      if (tsc == null) {
        pkcs7.setSignDate(calendar);
      }

      byte[] encodedPkcs7 = pkcs7.getEncodedPKCS7(hash, calendar, tsc, oscp);

      byte[] output = new byte[(contentSize - 2) / 2];

      System.arraycopy(encodedPkcs7, 0, output, 0, encodedPkcs7.length);
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPKCS7

      Collection<Signature> signatures = new ArrayList<Signature>();
      if (fields != null) {
        List<String> list = fields.getSignatureNames();
        if ((list != null) && (!list.isEmpty())) {
          for (String str : list) {
            PdfPKCS7 pk = fields.verifySignature(str);

            PdfString string = fields.getSignatureDictionary(str).getAsString(PdfName.CONTENTS);
            byte[] content = string.getBytes();

            X509Certificate certificate = pk.getSigningCertificate();
            Certificate[] chain = pk.getSignCertificateChain();

            byte[] encoded = content;
            TimeStamp timeStamp = null;
            String location = pk.getLocation();
            String reason = pk.getReason();
            String signName = pk.getSignName();
            Date date = pk.getSignDate().getTime();
            Boolean valid = Boolean.TRUE;
            Signatory signatory = this.toSignatory(certificate);

            Store store = new JCAStore(KeyStoreType.JKS);
            store.add(new CertificateEntry(new Alias(certificate.getSerialNumber().toString()), certificate));
            Object[] fails = PdfPKCS7.verifyCertificates(chain, store.toKeyStore(), pk.getCRLs(), pk.getSignDate());
            if (ConditionUtils.isNotEmpty(fails)) {
              valid = Boolean.FALSE;
            }

            TimeStampToken timeStampToken = pk.getTimeStampToken();
            if (timeStampToken != null) {
              timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
              timeStampToken.getTimeStampInfo();
              if (valid.booleanValue()) {
                boolean ok = pk.verifyTimestampImprint();
                valid = Boolean.valueOf(ok);
              }
            }

            Signature sig = new Signature();
View Full Code Here

Examples of com.itextpdf.text.pdf.security.PdfPKCS7

            Map<String, PdfPKCS7> result = SignatureFinder.find(
                inputDocumentFileName, includeTimestamps);

            // Print signature name, signature date and certificate name for each signature.
            for (String signature : result.keySet()) {
                PdfPKCS7 pkcs7 = result.get(signature);
                Calendar signDate = pkcs7.getSignDate();
                String certificateName = CertificateValidator.getCertificateName(
                    pkcs7.getSigningCertificate());
                System.out.print(signature + ", ");
                System.out.print(DatatypeConverter.printDateTime(signDate) + ", ");
                System.out.println(certificateName);
            }
        } catch (Exception exception) {
View Full Code Here

Examples of com.itextpdf.text.pdf.security.PdfPKCS7

            Map<String, PdfPKCS7> result = SignatureValidator.validateDocument(
                inputDocumentFileName, rootCertificatesFileName);

            // Print signature name, signature date and certificate name for each signature.
            for (String signature : result.keySet()) {
                PdfPKCS7 pkcs7 = result.get(signature);
                Calendar date = pkcs7.getSignDate();
                String signer = CertificateValidator.getCertificateName(
                    pkcs7.getSigningCertificate());
                System.out.print(signature + ", ");
                System.out.print(DatatypeConverter.printDateTime(date) + ", ");
                System.out.println(signer);
            }
        } catch (Exception exception) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.