Package java.security.cert

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


    private static Collection<? extends Certificate>
    loadCertificates(final java.io.InputStream is)
        throws IOException, CertificateException {
       
        final CertificateFactory factory = CertificateFactory.getInstance("X.509");
        return factory.generateCertificates(is);
    }

    /**
     * This method converts the JAXB KeyManagersType into a list of
     * JSSE KeyManagers.
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

            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

        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

        public boolean importTrustCert(String fileName, String alias) throws FileNotFoundException, CertificateException {
            // 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();
            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

        java.security.NoSuchProviderException,
        java.security.KeyStoreException,
        java.security.NoSuchAlgorithmException,
        java.security.UnrecoverableKeyException, java.io.IOException {
        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++) {
View Full Code Here

        // load the cert chain
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        ByteArrayInputStream bais = new ByteArrayInputStream(certChain);

        Collection<? extends Certificate> certCol = cf.generateCertificates(bais);
        Certificate[] certs = new Certificate[certCol.toArray().length];
        if (certCol.size() == 1) {
            Debug.logInfo("Single certificate; no chain", module);
            bais = new ByteArrayInputStream(certChain);
            Certificate cert = cf.generateCertificate(bais);
View Full Code Here

            if (derBytes != null && derBytes.length > 0) {
                BufferedInputStream bufInput = null;
                Collection certColl = null;
                try {
                    bufInput = new BufferedInputStream(new ByteArrayInputStream(derBytes));
                    certColl = certFactory.generateCertificates(bufInput);
                } catch(Exception ex) {
                    //XXX we do this because JDK 1.4 cannot load certs with large key
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.log(Level.FINE, "Can't load cert: " + alias, ex);
                    } else if (_logger.isLoggable(Level.INFO)) {
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

        X509CRL crl = (X509CRL)cf.generateCRL(new ByteArrayInputStream(info.getEncoded()));
        if (crl == null || !areEqual(crl.getEncoded(), crls.get(0).getDERObject().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

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.