Java 8 PKIXBuilderParameters - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PKIXBuilderParameters class.

This code example shows how to use the following methods:addCertStore, setRevocationEnabled
        X509Certificate rootCert = CertUtils.getCertFromFile("anchor.cer");
        TrustAnchor anchor = new TrustAnchor
            (rootCert.getSubjectX500Principal(), rootCert.getPublicKey(), null);
        X509CertSelector sel = new X509CertSelector();
        sel.setBasicConstraints(-2);
        PKIXBuilderParameters params = new PKIXBuilderParameters
            (Collections.singleton(anchor), sel);
        params.setRevocationEnabled(false);
        X509Certificate eeCert = CertUtils.getCertFromFile("ee.cer");
        X509Certificate caCert = CertUtils.getCertFromFile("ca.cer");
        ArrayList<X509Certificate> certs = new ArrayList<X509Certificate>();
        certs.add(caCert);
        certs.add(eeCert);
        CollectionCertStoreParameters ccsp =
            new CollectionCertStoreParameters(certs);
        CertStore cs = CertStore.getInstance("Collection", ccsp);
        params.addCertStore(cs);
        PKIXCertPathBuilderResult res = CertUtils.build(params);
        CertPath cp = res.getCertPath();
        // check that first certificate is an EE cert 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCertStore, setDate, setRevocationEnabled, setTargetCertConstraints
        trust.add(new TrustAnchor(caCert, null));
 
        CertPathValidator cpv = CertPathValidator.getInstance("PKIX","BC");
        //PKIXParameters param = new PKIXParameters(trust); 
 
        PKIXBuilderParameters param = new PKIXBuilderParameters(trust, null);
        X509CertSelector certSelector = new X509CertSelector();
        certSelector.setCertificate(crlCaCert);
        param.setTargetCertConstraints(certSelector);
        param.addCertStore(store);
        param.setRevocationEnabled(true);
        param.setDate(validDate.getTime());
 
        PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult)cpv.validate(cp, param);
    } 
 
    public void performTest() 
        throws Exception 
    { 
        CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCertStore, setDate, setRevocationEnabled, setTargetCertConstraints
This code example shows how to use the following methods:addCertStore, setDate
This code example shows how to use the following methods:addCertStore, setRevocationEnabled
        certSelector.setCertificate(userCert);
        certSelector.setSubject(userCert.getSubjectDN().getName()); // seems to be required
 
        // build a valid cerificate path 
        CertPathBuilder certPathBuilder = CertPathBuilder.getInstance("PKIX", "SUN");
        PKIXBuilderParameters certPathBuilderParams = new PKIXBuilderParameters(trustAnchors, certSelector);
        certPathBuilderParams.addCertStore(certStore);
        certPathBuilderParams.setRevocationEnabled(false);
        CertPathBuilderResult result = certPathBuilder.build(certPathBuilderParams);
 
        // get and show cert path 
        CertPath certPath = result.getCertPath();
//        System.out.println(certPath.toString()); 
    } 
 
    private static X509Certificate getTrustedCertificate() throws Exception {
        String sCert =
            "-----BEGIN CERTIFICATE-----\n" 
          + "MIIBezCCASWgAwIBAgIQyWD8dLUoqpJFyDxrfRlrsTANBgkqhkiG9w0BAQQFADAW\n" 
          + "MRQwEgYDVQQDEwtSb290IEFnZW5jeTAeFw0wMTEwMTkxMjU5MjZaFw0zOTEyMzEy\n" 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setMaxPathLength, addCertStore, setRevocationEnabled
This code example shows how to use the following methods:setMaxPathLength, addCertStore, setRevocationEnabled
     
            X509CertSelector certSelect = new X509CertSelector();
            certSelect.setCertificate(certList.get(0));
             
            // Configure certification path builder parameters 
            PKIXBuilderParameters pbParams = new PKIXBuilderParameters(_trustStore, certSelect);
            pbParams.addCertStore(CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList)));
     
            // Set maximum certification path length 
            pbParams.setMaxPathLength(_maxCertPathLength);
     
            // Enable revocation checking 
            pbParams.setRevocationEnabled(true);
     
            // Set static Certificate Revocation List 
            if (_crls != null && !_crls.isEmpty())
            { 
                pbParams.addCertStore(CertStore.getInstance("Collection", new CollectionCertStoreParameters(_crls)));
            } 
     

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setMaxPathLength, addCertStore, setRevocationEnabled
                                                String crlf, 
                                                KeyStore trustStore)
        throws Exception { 
        CertPathParameters params = null;
        if("PKIX".equalsIgnoreCase(algorithm)) {
            PKIXBuilderParameters xparams = new PKIXBuilderParameters(trustStore, 
                                                                     new X509CertSelector());
            Collection crls = getCRLs(crlf);
            CertStoreParameters csp = new CollectionCertStoreParameters(crls);
            CertStore store = CertStore.getInstance("Collection", csp);
            xparams.addCertStore(store);
            xparams.setRevocationEnabled(true);
            String trustLength = (String)attributes.get("trustMaxCertLength");
            if(trustLength != null) {
                try { 
                    xparams.setMaxPathLength(Integer.parseInt(trustLength));
                } catch(Exception ex) {
                    log.warn("Bad maxCertLength: "+trustLength);
                } 
            } 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCertStore, setRevocationEnabled
 
 
        CertStore certStore = CertStore.getInstance("Collection", storeParams);
 
 
        PKIXBuilderParameters parameters = new PKIXBuilderParameters(
                keyStore, targetConstraints);
        parameters.addCertStore(certStore);
        parameters.setRevocationEnabled(false);
        return parameters;
    } 
 
    @Override 
    public void validateCertPath(CertPath path) {
        List<? extends Certificate> certificates = path.getCertificates();
        Certificate certificate = certificates.get(0);
 
        assertEquals("unexpected certificate type", "X.509", certificate
                .getType());
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCertStore, setRevocationEnabled
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 PKIXBuilderParameters Methods: