Package java.security.cert

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


                }
            }

            if (expected_size == error) { // exception throwing test
                try {
                    factory.generateCertificates(new ByteArrayInputStream(encoding));
                    fail("Expected exception was not thrown");
                } catch (Exception e) { }
            } else {
                Collection certs =
                    factory.generateCertificates(new ByteArrayInputStream(encoding));
View Full Code Here


                    factory.generateCertificates(new ByteArrayInputStream(encoding));
                    fail("Expected exception was not thrown");
                } catch (Exception e) { }
            } else {
                Collection certs =
                    factory.generateCertificates(new ByteArrayInputStream(encoding));
                assertNotNull("Factory returned null on correct data", certs);
                assertEquals("The size of collection differs from expected",
                        expected_size, certs.size());
                verifyCertificates(certs);
            }
View Full Code Here

                    ((X509CRL) it.next()).verify(publicKey);
                }
            }
            bais = new ByteArrayInputStream(
                    (good[i][0] + pkcs7so + good[i][1]).getBytes());
            Collection certs = factory.generateCertificates(bais);
            assertNotNull("Factory returned null on correct PKCS7 data", certs);
            assertEquals("The size of collection differs from expected",
                    2, certs.size());
            if (publicKey != null) {
                // verify the signatures
View Full Code Here

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

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

        // Testing the Certificates generation
        // on the base of PKCS7 SignedData object
        ByteArrayInputStream bais = new ByteArrayInputStream(
                Base64.decode(pkcs7so.getBytes()));

        Collection certs = factory.generateCertificates(bais);
        assertNotNull("Factory returned null on correct PKCS7 data", certs);
        assertEquals("The size of collection differs from expected",
                2, certs.size());

        if (publicKey != null) {
View Full Code Here

      certStream = new FileInputStream(certificateLocation);

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

      certs = factory.generateCertificates(certStream);

      X509Certificate[] certChain = new X509Certificate[certs.size()];

      Iterator certIter = certs.iterator();
View Full Code Here

    Collection oCertColl = null;
    try
    {
      oCertStream = new FileInputStream(sCertsFile);
      CertificateFactory oCF = CertificateFactory.getInstance("X.509");
      oCertColl = oCF.generateCertificates(oCertStream);
      X509Certificate[] oChain = new X509Certificate[oCertColl.size()];
      Iterator oCertIt = oCertColl.iterator();
      int nCert = 0;
      while (oCertIt.hasNext())
      {
View Full Code Here

        ensureLoaded(storePassword);
        InputStream is = null;
        try {
            is = new ByteArrayInputStream(certbuf.getBytes());
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            Collection certcoll = cf.generateCertificates(is);
            Certificate[] chain = new Certificate[certcoll.size()];
            Iterator iter = certcoll.iterator();
            for (int i = 0; iter.hasNext(); i++) {
                chain[i] = (Certificate) iter.next();
            }
View Full Code Here

        CertificateFactory fact = CertificateFactory.getInstance("X.509");
        for (int i = 0; i < CERTIFICATE_URLS.length; i++) {
            URL certUrl = new URL(BASE_URL + CERTIFICATE_URLS[i]);
            try {
                InputStream is = certUrl.openStream();
                Collection certs = fact.generateCertificates(is);
                assertNotNull("The certificates in \""
                        + certUrl.toExternalForm()
                        + "\" were not parsed correctly", certs);
            } catch (IOException e) {
                // the certificate could not be found, skip it
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.