Examples of generateCertPath()


Examples of java.security.cert.CertificateFactory.generateCertPath()

        for (int i=0; i<bad.length; i++) {
            bais = new ByteArrayInputStream(
                    (bad[i][0] + pkiPath + bad[i][1]).getBytes("UTF-8"));
            try {
                factory.generateCertPath(bais);
                fail("Expected exception was not thrown");
            } catch (Exception e) { }
            bais = new ByteArrayInputStream(
                    (bad[i][0] + pkiPath + bad[i][1]).getBytes("UTF-8"));
            try {
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

                fail("Expected exception was not thrown");
            } catch (Exception e) { }
            bais = new ByteArrayInputStream(
                    (bad[i][0] + pkiPath + bad[i][1]).getBytes("UTF-8"));
            try {
                factory.generateCertPath(bais, "PkiPath");
                fail("Expected exception was not thrown");
            } catch (Exception e) { }
            bais = new ByteArrayInputStream(
                    (bad[i][0] + pkcs7so + bad[i][1]).getBytes("UTF-8"));
            try {
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

                fail("Expected exception was not thrown");
            } catch (Exception e) { }
            bais = new ByteArrayInputStream(
                    (bad[i][0] + pkcs7so + bad[i][1]).getBytes("UTF-8"));
            try {
                factory.generateCertPath(bais, "PKCS7");
                fail("Expected exception was not thrown");
            } catch (Exception e) { }
        }
    }
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

        // on the base of PKCS7 SignedData object
        ByteArrayInputStream bais = new ByteArrayInputStream(
                Base64.decode(pkcs7so.getBytes("UTF-8")));

        Collection certPath =
            factory.generateCertPath(bais, "PKCS7").getCertificates();
        assertEquals("The size of collection differs from expected",
                2, certPath.size());

        if (publicKey != null) {
            // verify the signatures
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

        }

        // testing empty PkiPath structure (ASN.1 such as 0x30, 0x00)
        bais = new ByteArrayInputStream(new byte[] {(byte) 0x30, 0x00});
        assertEquals("The size of the list differs from expected",
                0, factory.generateCertPath(bais, "PkiPath")
                                .getCertificates().size());
    }

}
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

  private byte[] calculateSignerId(List<? extends X509Certificate> certs)
      throws SignatureException {
    try {
      CertificateFactory certFactory = CertificateFactory.getInstance(X509);
      CertPath path = certFactory.generateCertPath(certs);
      byte[] encodedCertPath = path.getEncoded(PKI_PATH_ENCODING);
      MessageDigest digest = MessageDigest.getInstance(
          AlgorithmUtil.getJceName(getHashAlgorithm()));
      return digest.digest(encodedCertPath);
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

      // perhaps by letting them pass in PKIXCertPathCheckers. This can also be
      // useful to check for Wave-specific certificate extensions.

      CertificateFactory certFactory = CertificateFactory.getInstance(
          CERTIFICATE_TYPE);
      CertPath certPath = certFactory.generateCertPath(certs);
      validator.validate(certPath, params);
    } catch (GeneralSecurityException e) {
      throw new SignatureException("Certificate validation failure", e);
    }
  }
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

      ArrayList<Certificate> certlist = new ArrayList<Certificate>();
      // Create CertPath
      certlist.add(certificate);
      // Add other certs...     
      CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
      java.security.cert.CertPath cp = cf.generateCertPath(certlist);
      // Create TrustAnchor. Since EJBCA use BouncyCastle provider, we assume
      // certificate already in correct order
      X509Certificate[] cac = (X509Certificate[]) caCertPath.toArray(new X509Certificate[] {});
      java.security.cert.TrustAnchor anchor = new java.security.cert.
      TrustAnchor(cac[0], null);
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

          params.setDate( new Date() );

          // Create the validator and validate the path
          CertPathValidator certPathValidator = CertPathValidator.getInstance(CertPathValidator.getDefaultType(), "BC");
          CertificateFactory fact = CertTools.getCertificateFactory();
          CertPath certpath = fact.generateCertPath(calist);

          CertPathValidatorResult result = certPathValidator.validate(certpath, params);

          // Get the certificates validate in the path
          PKIXCertPathValidatorResult pkixResult = (PKIXCertPathValidatorResult)result;
View Full Code Here

Examples of java.security.cert.CertificateFactory.generateCertPath()

      certificateResponse = new String(Base64.encode(responseData.getResponseData(), false));
            try {
                CertificateFactory cf = CertificateFactory.getInstance("X.509");
                String pkcs7 = PEM_PKCS7_BEGIN + "\n" + new String(Base64.encode(responseData.getResponseData(), true)) + "\n" + PEM_PKCS7_END + "\n";
                log.debug("pkcs7="+pkcs7);
              CertPath certPath = cf.generateCertPath(new ByteArrayInputStream(responseData.getResponseData()), "PKCS7");
              List<? extends Certificate> certList = certPath.getCertificates();
              Certificate caCert = certList.get(certList.size()-1);
              String caCertificate = new String(Base64.encode(caCert.getEncoded(), false));
        resource = new ByteArrayResource(caCertificate.getBytes());
        mimeType = "application/x-x509-ca-cert";
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.