Java 8 PKIXParameters - 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 PKIXParameters class.

This code example shows how to use the following methods:addCertStore, setDate, setExplicitPolicyRequired, setInitialPolicies, setRevocationEnabled
     
        CertStore  store = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certsAndCrls), "BC");
         
        //CertPathValidator validator = CertPathValidator.getInstance("PKIX","BC"); 
        PKIXCertPathReviewer reviewer;
        PKIXParameters    params = new PKIXParameters(trustedSet);
         
        params.addCertStore(store);
        params.setRevocationEnabled(true);
        params.setDate(new GregorianCalendar(2010, 1, 1).getTime());
 
        if (policies != null)
        { 
            params.setExplicitPolicyRequired(true);
            params.setInitialPolicies(policies);
        } 
         
        reviewer = new PKIXCertPathReviewer(certPath,params);
         
        return reviewer;

7
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setRevocationEnabled
        Session session = Session.getDefaultInstance(props, null);
 
        // read message 
        MimeMessage msg = new MimeMessage(session, getClass().getResourceAsStream(message));
 
        SignedMailValidator validator = new SignedMailValidator(msg, params);
        SignerInformation signer = (SignerInformation) validator
                .getSignerInformationStore().getSigners().iterator().next(); 
        return validator.getValidationResult(signer);
    } 
 
    private void assertContainsMessage(List msgList, String messageId,
            String text) throws Exception
    { 
        Iterator it = msgList.iterator();
        boolean found = false;
        while (it.hasNext())
        { 
            ErrorBundle message = (ErrorBundle) it.next();
            if (message.getId().equals(messageId))

6
CodeRank
Experience pair programming with AI  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, setRevocationEnabled
                        .println("no trustanchor file found, using a dummy trustanchor");
                trust = getDummyTrustAnchor();
            } 
            trustanchors.add(trust);
 
            param = new PKIXParameters(trustanchors);
        } 
 
        // load one ore more crls from files (here we only load one crl) 
        List crls = new ArrayList();
        X509CRL crl = loadCRL("crl.file");
        if (crl != null)
        { 
            crls.add(crl);
        } 
        CertStore certStore = CertStore.getInstance("Collection",
                new CollectionCertStoreParameters(crls), "BC");
 
        // add crls and enable revocation checking 
        param.addCertStore(certStore);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addCertStore, setRevocationEnabled
					new CollectionCertStoreParameters(allCerts));
		} 
	} 
	 
	public PKIXParameters getParameters() throws InvalidAlgorithmParameterException	{
		final PKIXParameters params = new PKIXParameters(trustAnchors);
		params.addCertStore(trustStore);
		params.setRevocationEnabled(revocationEnabled);
		return params;
	} 
	 
	public Collection<? extends Certificate> getTrustedCerts() throws CertStoreException {
		return trustStore.getCertificates(null);
	} 
	 
	public Collection<? extends CRL> getRevocationLists() throws CertStoreException {
		return trustStore.getCRLs(null);
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  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:getTargetCertConstraints, getTrustAnchors
    { 
        ExtendedPKIXBuilderParameters params;
        try 
        { 
            params = new ExtendedPKIXBuilderParameters(pkixParams
                    .getTrustAnchors(), X509CertStoreSelector
                    .getInstance((X509CertSelector) pkixParams
                            .getTargetCertConstraints()));
        } 
        catch (Exception e)
        { 
            // cannot happen 
            throw new RuntimeException(e.getMessage());
        } 
        params.setParams(pkixParams);
        return params;
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 PKIXParameters Questions & Answers:

See Code Examples for Java 8 PKIXParameters Methods: