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

This code example shows how to use the following methods: getCA, getCAName, getCAPublicKey, getNameConstraints, getTrustedCert
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
            { 
                System.out
                        .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");
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getTrustedCert
    public void testCreateCertPath() throws Exception 
    { 
        // load trust anchor 
        Set trustanchors = new HashSet();
        TrustAnchor ta = getTrustAnchor("certpath_root.crt");
        trustanchors.add(ta);
         
        X509Certificate rootCert = ta.getTrustedCert();
        X509Certificate interCert1 = loadCert("certpath_inter1.crt");
        X509Certificate interCert2 = loadCert("certpath_inter2.crt");
        X509Certificate endCert1 = loadCert("certpath_end1.crt");
        X509Certificate endCert2 = loadCert("certpath_end2.crt");
         
        // init cert stores 
        List certStores = new ArrayList();
        List certList = new ArrayList();
        certList.add(interCert1);
        certList.add(interCert2);
        CertStore store = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList));
        certStores.add(store);
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
                new X509CertImpl(serviceSprintComCertChain[0]),
                new X509CertImpl(serviceSprintComCertChain[1]),
                new X509CertImpl(serviceSprintComCertChain[2])));
 
        Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();
        trustAnchors.add(new TrustAnchor(new X509CertificateObject(
                new X509CertificateStructure( 
                        (ASN1Sequence) new ASN1InputStream(trustedCert).readObject())), null));
 
        IndexedPKIXParameters indexedPKIXParameters = new IndexedPKIXParameters(trustAnchors);
        indexedPKIXParameters.setRevocationEnabled(false);
 
        new PKIXCertPathValidatorSpi().engineValidate(certPath, indexedPKIXParameters);
        // completing normally indicates that the certificate was valid 
    } 
} 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
public final class BuildEEBasicConstraints { 
 
    public static void main(String[] args) throws Exception {
 
        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);
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:
 
    private void doBuild(X509Certificate userCert) throws Exception {
        // get the set of trusted CA certificates (only one in this instance) 
        HashSet trustAnchors = new HashSet();
        X509Certificate trustedCert = getTrustedCertificate();
        trustAnchors.add(new TrustAnchor(trustedCert, null));
 
        // put together a CertStore (repository of the certificates and CRLs) 
        ArrayList certs = new ArrayList();
        certs.add(trustedCert);
        certs.add(userCert);
        CollectionCertStoreParameters certStoreParams = new CollectionCertStoreParameters(certs);
        CertStore certStore = CertStore.getInstance("Collection", certStoreParams);
 
        // specify the target certificate via a CertSelector 
        X509CertSelector certSelector = new X509CertSelector();
        certSelector.setCertificate(userCert);
        certSelector.setSubject(userCert.getSubjectDN().getName()); // seems to be required
 
        // build a valid cerificate path 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:

Related Java 8 TrustAnchor Questions & Answers:

See Code Examples for Java 8 TrustAnchor Methods: