Package java.security.cert

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


  public static X509Certificate getCert(Certificate[] aCertificationChain)
     throws CertificateException
  {
    List certList = Arrays.asList(aCertificationChain);
    CertificateFactory certFactory = CertificateFactory.getInstance(X509_CERTIFICATE_TYPE);
    CertPath certPath = certFactory.generateCertPath(certList);
    List lista = certPath.getCertificates();
    X509Certificate cert = null;
    // --- il certificato dell'utente e' sempre il primo della catena.
    if(lista.size() > 0)
      cert = (X509Certificate) lista.get(0);
View Full Code Here


                abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(x509Certificates[0].getEncoded()));
            } else {
                try {
                    CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509", "BC");
                    List<X509Certificate> certificates = Arrays.asList(x509Certificates);
                    abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, new Base64(76, new byte[]{'\n'}).encodeToString(certificateFactory.generateCertPath(certificates).getEncoded()));
                } catch (CertificateException e) {
                    throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
                } catch (NoSuchProviderException e) {
                    throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
                }
View Full Code Here

        {
            CertificateFactory cFac = CertificateFactory.getInstance("X.509",
                    "BC");
            arr = os.toByteArray();
            is = new ByteArrayInputStream(arr);
            cFac.generateCertPath(is);
        }
        catch (CertificateException e)
        {
            // ignore okay
        }
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
View Full Code Here

                //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.");
View Full Code Here

           
            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.");
View Full Code Here

           
            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.");
View Full Code Here

        CertificateFactory factory = CertificateFactory.getInstance("X.509");

        ByteArrayInputStream bais = new ByteArrayInputStream(encoding);

        CertPath cert_path = factory.generateCertPath(bais);

        encoding = cert_path.getEncoded("PKCS7");

        X509CertPathImpl cpath = X509CertPathImpl
                .getInstance(encoding, "PKCS7");
View Full Code Here

        List certificates;
        for (int i=0; i<good.length; i++) {
            bais = new ByteArrayInputStream(
                    (good[i][0] + pkiPath + good[i][1]).getBytes());

            certificates = factory.generateCertPath(bais).getCertificates();
            assertEquals("The size of the list differs from expected",
                    2, certificates.size());

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

            bais = new ByteArrayInputStream(
                    (good[i][0] + pkiPath + good[i][1]).getBytes());

            certificates =
                factory.generateCertPath(bais, "PkiPath").getCertificates();
            assertEquals("The size of the list differs from expected",
                    2, certificates.size());

            if (publicKey != null) {
                // verify the signatures
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.