Package java.security.cert

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


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

            InputStream certStream = getStream(fileName);

            Collection c = cf.generateCertificates(certStream);
            Certificate[] certs = new Certificate[c.toArray().length];

            if (c.size() == 1) {
                certStream = getStream(fileName);
                System.out.println("1 certificate");
View Full Code Here


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

            InputStream certStream = getStream(bArray);

            Collection c = cf.generateCertificates(certStream);
            Certificate[] certs = new Certificate[c.toArray().length];

            if (c.size() == 1) {
                certStream = getStream(bArray);
                System.out.println("1 certificate");
View Full Code Here

                                    COSString certString = (COSString)cert.getDictionaryObject(
                                        COSName.getPDFName( "Cert" ) );
                                    byte[] certData = certString.getBytes();
                                    CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
                                    ByteArrayInputStream certStream = new ByteArrayInputStream( certData );
                                    Collection certs = factory.generateCertificates( certStream );
                                    System.out.println( "certs=" + certs );
                                }
                                else if( subFilter.getName().equals( "adbe.pkcs7.sha1" ) )
                                {
                                    COSString certString = (COSString)cert.getDictionaryObject(
View Full Code Here

                                    COSString certString = (COSString)cert.getDictionaryObject(
                                        COSName.getPDFName( "Contents" ) );
                                    byte[] certData = certString.getBytes();
                                    CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
                                    ByteArrayInputStream certStream = new ByteArrayInputStream( certData );
                                    Collection certs = factory.generateCertificates( certStream );
                                    System.out.println( "certs=" + certs );
                                }
                                else
                                {
                                    System.err.println( "Unknown certificate type:" + subFilter );
View Full Code Here

               return result.toString();
            }
         };
         String filteredPem = CharStreams.readLines(CharStreams.newReaderSupplier(pem), callback);
         CertificateFactory fact = CertificateFactory.getInstance("X.509");
         return (Collection<X509Certificate>) fact.generateCertificates(new ByteArrayInputStream(filteredPem
               .getBytes(Charsets.UTF_8)));
      }
   }

   @Override
View Full Code Here

            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

        String certificate = request.getParameter("certificate");
        request.setAttribute("certificate", certificate);
        InputStream is = new ByteArrayInputStream(certificate.getBytes());
        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

            {
                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

      ks.load(null, new char[0]);

      is = getCert();

      CertificateFactory cf = CertificateFactory.getInstance("X.509");
      Collection<? extends Certificate> c = cf.generateCertificates(is);
      Iterator<? extends Certificate> it = c.iterator();
      while(it.hasNext()) {
        Certificate cert = it.next();
        ks.setCertificateEntry(cert.getPublicKey().toString(), cert);
      }
View Full Code Here

        CRL crl = cf.generateCRL(new ByteArrayInputStream(PEMData.CRL_1.getBytes("US-ASCII")));
        if (crl == null)
        {
            fail("PEM crl not read");
        }
        Collection col = cf.generateCertificates(new ByteArrayInputStream(PEMData.CERTIFICATE_2.getBytes("US-ASCII")));
        if (col.size() != 1 || !col.contains(cert))
        {
            fail("PEM cert collection not right");
        }
        col = cf.generateCRLs(new ByteArrayInputStream(PEMData.CRL_2.getBytes("US-ASCII")));
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.