Package java.security.cert

Examples of java.security.cert.X509CRL


   
    private X509CRL loadCrl(
        String crlName)
        throws Exception
    {
        X509CRL crl = (X509CRL)certs.get(crlName);
       
        if (crl != null)
        {
            return crl;
        }
View Full Code Here


       
        for (int i=0; i<good.length; i++) {
            bais = new ByteArrayInputStream(
                    (good[i][0] + x509crl + good[i][1]).getBytes("UTF-8"));

            X509CRL crl = (X509CRL) factory.generateCRL(bais);
            assertNotNull("Factory returned null on correct data", crl);

            if (publicKey != null) {
                // verify the signatures
                crl.verify(publicKey);
            }
        }

        for (int i=0; i<bad_content.length; i++) {
            bais = new ByteArrayInputStream(
View Full Code Here

            crlLocation = crlLocation.trim();
            InputStream is = loadInputStream(loader, crlLocation);

            try {
                CertificateFactory cf = getCertificateFactory();
                X509CRL crl = (X509CRL)cf.generateCRL(is);
               
                if (provider == null || provider.length() == 0) {
                    crlCertStore =
                        CertStore.getInstance(
                            "Collection",
View Full Code Here

                // Download manually CRLs.
                Collection<? extends Certificate> certificates = path.getCertificates();
                ArrayList<X509CRL> crls = new ArrayList<X509CRL>();
                for (Certificate c : certificates) {
                    X509CRL crl = CRLDownloader.getCRL((X509Certificate) c);
                    if (crl != null) {
                        crls.add(crl);
                    }
                }
                parameters.addCertStore(CertStore.getInstance("Collection",
View Full Code Here

        String certificateFileName = command.getOptionValue("cert");
        String crlFileName = command.getOptionValue("out");

        try {
            // Download the CRL.
            X509CRL crl = CRLDownloader.getCRL(certificateFileName);
            if (crl == null) {
                System.err.println(messages.getString(
                    "Certificate_has_no_CRL_distribution_point."));
                System.exit(1);
            }

            // Write CRL to file.
            FileOutputStream file = new FileOutputStream(crlFileName);
            file.write(crl.getEncoded());
            file.close();

        } catch (Exception exception) {
            // Print stack trace in case of unexpected exception.
            exception.printStackTrace();
View Full Code Here

        IOException,
        CertificateException,
        CRLException
    {
        // Check if CRL exists in the memory cache.
        X509CRL crl = crlCache.get(url);
        if (crl != null) {
            // Check if CRL is still valid.
            if (crl.getNextUpdate().after(new Date())) {
                return crl;
            } else {
                crlCache.remove(url);
            }
        }
View Full Code Here

                    if (downloaded) {
                        continue;
                    }

                    // Download CRL.
                    X509CRL crl = CRLDownloader.getCRL(certificate);
                    if (crl == null) {
                        throw new NoCRLException(String.format(messages.getString(
                            "Could_not_get_CRL_for_the_certificate__%s"),
                            CertificateValidator.getCertificateName(certificate)));
                    }
                    crls.add(crl);
                }
            }

            // Add signature certificates, OCSP responses and CRLs to global stores.
            certMap.put(signature, certificates);
            ocspMap.put(signature, ocspResponses);
            crlMap.put(signature, crls);
        }

        // Open output file for writing.
        FileOutputStream output = new FileOutputStream(outputFileName);
        File temp = File.createTempFile("tmp", ".tmp");
        PdfStamper stamper = PdfStamper.createSignature(
            reader, output, '\0', temp, true);

        // Create a DSS (Document Security Store).
        LtvVerification verification = stamper.getLtvVerification();

        // Add certificates, OCSP responses and CRLs to DSS.
        for (String signature : certMap.keySet()) {
            ArrayList<byte[]> certificates = new ArrayList<byte[]>();
            for (X509Certificate certificate : certMap.get(signature)) {
                certificates.add(certificate.getEncoded());
            }
            ArrayList<byte[]> ocsps = new ArrayList<byte[]>();
            for (BasicOCSPResp response : ocspMap.get(signature)) {
                ocsps.add(response.getEncoded());
            }
            ArrayList<byte[]> crls = new ArrayList<byte[]>();
            for (X509CRL crl : crlMap.get(signature)) {
                crls.add(crl.getEncoded());
            }
            verification.addVerification(signature, ocsps, crls, certificates);
        }

        // Timestamp the document.
View Full Code Here

        PdfArray crlArray = dictionary.getAsArray(PdfName.CRLS);
        ArrayList<X509CRL> crls = new ArrayList<X509CRL>();
        if (crlArray != null) {
            for (int i = 0; i < crlArray.size(); i++) {
                PRStream stream = (PRStream) crlArray.getAsStream(i);
                X509CRL crl = (X509CRL) factory.generateCRL(new ByteArrayInputStream(PdfReader.getStreamBytes(stream)));
                crls.add(crl);
            }
        }
        if (ocsps.size() == 0 && crls.size() == 0) {
            throw new NoRevocationStatusException(messages.getString(
View Full Code Here

            return crlList;
        }

        for (org.opensaml.xml.signature.X509CRL xmlCRL : x509Data.getX509CRLs()) {
            if (xmlCRL != null && xmlCRL.getValue() != null) {
                X509CRL newCRL = getCRL(xmlCRL);
                crlList.add(newCRL);
            }
        }

        return crlList;
View Full Code Here

                SearchResult sr = answer.next();
                Attributes attrs = sr.getAttributes();
                Attribute attribute = attrs.get(tmpAttrName);
                if (attribute != null) {
                    CertificateFactory cf = CertificateFactory.getInstance("X.509");
                    X509CRL crl = (X509CRL) cf.generateCRL(new ByteArrayInputStream(
                            (byte[]) attribute.get()));
                    crls.add(crl);
                }
            }
            return crls;
View Full Code Here

TOP

Related Classes of java.security.cert.X509CRL

Copyright © 2018 www.massapicom. 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.