Package java.security.cert

Examples of java.security.cert.CertPath


        System.arraycopy(foundCerts, 0, x509certs, 1, foundCerts.length);
       
        try {
            // Generate cert path
            List<X509Certificate> certList = Arrays.asList(x509certs);
            CertPath path = getCertificateFactory().generateCertPath(certList);

            Set<TrustAnchor> set = new HashSet<TrustAnchor>();
            if (trustedCerts != null) {
                for (X509Certificate cert : trustedCerts) {
                    TrustAnchor anchor =
View Full Code Here


        super(WSSecurityTokenConstants.X509PkiPathV1Token, wsInboundSecurityContext, crypto,
                callbackHandler, id, keyIdentifier, securityProperties, true);

        InputStream in = new UnsynchronizedByteArrayInputStream(binaryContent);
        try {
            CertPath certPath = getCrypto().getCertificateFactory().generateCertPath(in);
            List<? extends Certificate> l = certPath.getCertificates();
            X509Certificate[] certs = new X509Certificate[l.size()];
            Iterator<? extends Certificate> iterator = l.iterator();
            for (int i = 0; i < l.size(); i++) {
                certs[i] = (X509Certificate) iterator.next();
            }
View Full Code Here

                    {
                        List<Certificate> certificateList = new ArrayList<Certificate>();

                        for (CodeSigner signer : signers)
                        {
                            CertPath path = signer.getSignerCertPath();

                            certificateList.addAll(path.getCertificates());
                        }

                        certificates = certificateList.toArray(new Certificate[certificateList.size()]);
                    }
                }
View Full Code Here

      }

      List list = new ArrayList(1);
      list.add(cert);

      CertPath cp;
      CertPathValidator cpv;
      PKIXParameters parameters;

      try
      {
View Full Code Here

            X509Certificate finalCert = (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(finalCertBin));

                //Testing CertPath generation from List
            List list = new ArrayList();
            list.add(interCert);
            CertPath certPath1 = cf.generateCertPath(list);

                //Testing CertPath encoding as PkiPath
            byte[] encoded = certPath1.getEncoded("PkiPath");

                //Testing CertPath generation from InputStream
            ByteArrayInputStream inStream = new ByteArrayInputStream(encoded);
            CertPath certPath2 = cf.generateCertPath(inStream, "PkiPath");

                //Comparing both CertPathes
            if (! certPath2.equals(certPath1))
            {
                return new SimpleTestResult(false,  this.getName() + ": CertPath differ after encoding and decoding.");
            }
           
            encoded = certPath1.getEncoded("PKCS7");

                //Testing CertPath generation from InputStream
            inStream = new ByteArrayInputStream(encoded);
            certPath2 = cf.generateCertPath(inStream, "PKCS7");
   
                //Comparing both CertPathes
            if (! certPath2.equals(certPath1))
            {
                return new SimpleTestResult(false,  this.getName() + ": CertPath differ after encoding and decoding.");
            }
           
            encoded = certPath1.getEncoded("PEM");

                //Testing CertPath generation from InputStream
            inStream = new ByteArrayInputStream(encoded);
            certPath2 = cf.generateCertPath(inStream, "PEM");
   
                //Comparing both CertPathes
            if (!certPath2.equals(certPath1))
            {
                return new SimpleTestResult(false,  this.getName() + ": CertPath differ after encoding and decoding.");
            }
           
            TestResult res = testExceptions();
View Full Code Here

            targetConstraints.setSubject(finalCert.getSubjectX500Principal().getEncoded());
            PKIXBuilderParameters params = new PKIXBuilderParameters(trust, targetConstraints);
            params.addCertStore(store);
            params.setDate(validDate.getTime());
            PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) cpb.build(params);
            CertPath                  path = result.getCertPath();
           
            if (path.getCertificates().size() != 2)
            {
                return new SimpleTestResult(false, this.getName() + ": wrong number of certs in baseTest path");
            }
        }
        catch (Exception e)
View Full Code Here

           
            buildParams.addCertStore(store);
            buildParams.setDate(new Date());
           
            PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult)builder.build(buildParams);
            CertPath                  path = result.getCertPath();
           
            if (path.getCertificates().size() != 2)
            {
                return new SimpleTestResult(false, this.getName() + ": wrong number of certs in v0Test path");
            }
        }
        catch (Exception e)
View Full Code Here

            //validating path
        List certchain = new ArrayList();
        certchain.add(finalCert);
        certchain.add(interCert);
        CertPath cp = CertificateFactory.getInstance("X.509","BC").generateCertPath(certchain);
        Set trust = new HashSet();
        trust.add(new TrustAnchor(rootCert, null));

        CertPathValidator cpv = CertPathValidator.getInstance("PKIX","BC");
        PKIXParameters param = new PKIXParameters(trust);
View Full Code Here

    List<X509Certificate> certs = new ArrayList<X509Certificate>();
    for (X509Certificate certificate : chain) {
      certificate.checkValidity();
      certs.add(certificate);
    }
    CertPath cp = CertificateFactory.getInstance("X.509").generateCertPath(certs);
    try {
      CertPathValidatorResult result = validator.validate(cp, parameters);
      System.out.println(result);
    } catch (CertPathValidatorException e) {
      // e.printStackTrace();
View Full Code Here

            Collection certCollection = certs.getCertificates(info.getSID());
            Iterator<X509Certificate> certIter = certCollection.iterator();
            if (certIter.hasNext()) {
                X509Certificate signerCert = certIter.next();
                // The issuer's certifcate is searched in the list of trusted certificate.
                CertPath path = verifyCertificate(signerCert, certs, keyStore);

                try {
                    // if the signature is valid the SMIMESignedInfo is
                    // created using "true" as last argument. If it is 
                    // invalid an exception is thrown by the "verify" method
View Full Code Here

TOP

Related Classes of java.security.cert.CertPath

Copyright © 2018 www.massapicom. 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.