Examples of generateCertificates()


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

        X509CRL crl = (X509CRL)cf.generateCRL(new ByteArrayInputStream(info.getEncoded()));
        if (crl == null || !areEqual(crl.getEncoded(), crls.get(0).toASN1Primitive().getEncoded()))
        {
            fail("PKCS7 crl not read");
        }
        Collection col = cf.generateCertificates(new ByteArrayInputStream(info.getEncoded()));
        if (col.size() != 1 || !col.contains(cert))
        {
            fail("PKCS7 cert collection not right");
        }
        col = cf.generateCRLs(new ByteArrayInputStream(info.getEncoded()));
View Full Code Here

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

        //
        // sample message
        //
        InputStream in = new ByteArrayInputStream(pkcs7CrlProblem);
        Collection certCol = cf.generateCertificates(in);
        Collection crlCol = cf.generateCRLs(in);

        if (crlCol.size() != 0)
        {
            fail("wrong number of CRLs: " + crlCol.size());
View Full Code Here

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

    } catch (CertificateException e) {
      throw new UnsupportedCryptoPrimitiveException("Failure getting X.509 factory", e);
    }

    try {
      Collection<? extends Certificate> certs = factory.generateCertificates(pemStream);
      Certificate[] toReturn = certs.toArray(new Certificate[]{});
      return Arrays.asList(toReturn);
    } catch (CertificateException e) {
      throw new InvalidInputException("Not a valid PEM stream", e);
    }
View Full Code Here

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

            try
            {
                CertificateFactory cf = CertificateFactory.getInstance("X.509");
                ByteArrayInputStream bis = new ByteArrayInputStream(sslCert.toString().getBytes());

                Collection certCollection = cf.generateCertificates(bis);
                X509Certificate[] certificates = new X509Certificate[certCollection.size()];

                int i=0;
                Iterator iter=certCollection.iterator();
                while(iter.hasNext())
View Full Code Here

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

            PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate(keySpec);

            // populate keystore with private key and certs
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            @SuppressWarnings("unchecked")
            Collection<Certificate> certs = (Collection<Certificate>) cf.generateCertificates(new ByteArrayInputStream(
                  pemCerts.toString().getBytes(Charsets.UTF_8)));
            keyStore.load(null);
            keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(),
                  certs.toArray(new java.security.cert.Certificate[0]));
View Full Code Here

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

            try {
                // Uploading certificate using a disk file fails on Windows.  Certificate text is used instead.
                //InputStream is = new FileInputStream(fileName);
                InputStream is = new ByteArrayInputStream(fileName.getBytes());
                CertificateFactory cf = CertificateFactory.getInstance("X.509");
                Collection certs = cf.generateCertificates(is);
                X509Certificate cert = (X509Certificate) certs.iterator().next();
                instance.importTrustCertificate(cert, alias, password);
                String[] update = new String[certificates.length+1];
                System.arraycopy(certificates, 0, update, 0, certificates.length);
                update[certificates.length] = alias;
View Full Code Here

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

        String certFile = request.getParameter("certificate");
        request.setAttribute("certificate", certFile);
        InputStream is = new FileInputStream(certFile);
        try {
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            Collection certificates = cf.generateCertificates(is);
            X509Certificate cert = (X509Certificate) certificates.iterator().next();
            request.setAttribute("fingerprint", CertificateUtil.generateFingerprint(cert, "MD5"));
            request.setAttribute("issuer", cert.getIssuerDN().getName());
            request.setAttribute("subject", cert.getSubjectDN().getName());
            request.setAttribute("serial", cert.getSerialNumber());
View Full Code Here

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

        }

        public boolean importTrustCert(String fileName, String alias) throws FileNotFoundException, CertificateException {
            InputStream is = new FileInputStream(fileName);
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            Collection certs = cf.generateCertificates(is);
            X509Certificate cert = (X509Certificate) certs.iterator().next();
            boolean result = instance.importTrustCertificate(cert, alias, password);
            if(result) {
                String[] update = new String[certificates.length+1];
                System.arraycopy(certificates, 0, update, 0, certificates.length);
View Full Code Here

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

            {
                CertificateFactory fac = CertificateFactory.getInstance(X_509);

                InputStream instream = new ByteArrayInputStream(clientCert.getBytes(UTF_8));

                Collection<X509Certificate> certs = (Collection<X509Certificate>) fac.generateCertificates(instream);
                request.setAttribute(ATTR_SSL_CERTIFICATE, certs.toArray(new X509Certificate[certs.size()]));
            }
            catch (UnsupportedEncodingException e)
            {
                // Any JRE should support UTF-8...
View Full Code Here

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

            java.security.NoSuchAlgorithmException,
            java.security.UnrecoverableKeyException, java.io.IOException {

        CertificateFactory cf = CertificateFactory.getInstance("X.509",
                keyStoreProvider);
        Collection certcoll = cf.generateCertificates(is);

        Certificate[] chain = new Certificate[certcoll.size()];

        Iterator iter = certcoll.iterator();
        for (int i = 0; iter.hasNext(); i++) {
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.