Package java.security.cert

Examples of java.security.cert.X509CertSelector


        for (X509Certificate rootCertificate : rootCertificates) {
            anchors.add(new TrustAnchor(rootCertificate, null));
        }

        // Prepare to build a certificate path.
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(certificate);
        PKIXBuilderParameters parameters = new PKIXBuilderParameters(anchors, selector);
        parameters.setMaxPathLength(-1);
        parameters.addCertStore(CertStore.getInstance("Collection",
            new CollectionCertStoreParameters(Collections.singletonList(certificate))));
        if (intermediateCertificates != null) {
View Full Code Here


        if (trustAnchors == null || trustAnchors.isEmpty()) {
            throw new GeneralSecurityException(
                    "Unable to validate X509 certificate, no trust anchors found in the PKIX validation information");
        }

        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(untrustedCredential.getEntityCertificate());

        log.trace("Adding trust anchors to PKIX validator parameters");
        PKIXBuilderParameters params = new PKIXBuilderParameters(trustAnchors, selector);

        Integer effectiveVerifyDepth = getEffectiveVerificationDepth(validationInfo);
View Full Code Here

     * @param x509Certificate to check
     * @return the validity state of the certificate
     */
    boolean isCertificateChainValid(List<X509Certificate> certificates) {
        X509Certificate targetCert = certificates.get(0);
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(targetCert);
        try {
            List<X509Certificate> intermediateCerts = certRepo.getCaCerts();
            List<X509Certificate> trustedAuthorityCerts = certRepo.getTrustedCaCerts();
            Set<TrustAnchor> trustAnchors = asTrustAnchors(trustedAuthorityCerts);
            CertStoreParameters intermediateParams = new CollectionCertStoreParameters(intermediateCerts);
View Full Code Here

                                                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);
View Full Code Here

                                                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);
View Full Code Here

                anchors.add(new TrustAnchor((X509Certificate)cert, null));
      }
        }

        final CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX");
        X509CertSelector targetConstraints = new X509CertSelector();
        targetConstraints.setCertificate(signerCert);
        PKIXBuilderParameters cpbParams =
            new PKIXBuilderParameters(anchors, targetConstraints);

        cpbParams.addCertStore(certs);
        cpbParams.setRevocationEnabled(false);
View Full Code Here

                                                KeyStore trustStore)
        throws Exception {
        CertPathParameters params = null;
        if("PKIX".equalsIgnoreCase(algorithm)) {
            PKIXBuilderParameters xparams =
                new PKIXBuilderParameters(trustStore, new X509CertSelector());
            Collection<? extends CRL> crls = getCRLs(crlf);
            CertStoreParameters csp = new CollectionCertStoreParameters(crls);
            CertStore store = CertStore.getInstance("Collection", csp);
            xparams.addCertStore(store);
            xparams.setRevocationEnabled(true);
View Full Code Here

                X509Certificate xcert = (X509Certificate) o;
            ksr = certSelect(xcert, sm);
        // check X509IssuerSerial
        } else if (o instanceof X509IssuerSerial) {
            X509IssuerSerial xis = (X509IssuerSerial) o;
            X509CertSelector xcs = new X509CertSelector();
            try {
                xcs.setSubjectPublicKeyAlgID(algOID);
                xcs.setSerialNumber(xis.getSerialNumber());
            xcs.setIssuer(new X500Principal
                (xis.getIssuerName()).getName());
            } catch (IOException ioe) {
            throw new KeySelectorException(ioe);
        }
        ksr = keyStoreSelect(xcs);
        // check X509SubjectName
        } else if (o instanceof String) {
            String sn = (String) o;
            X509CertSelector xcs = new X509CertSelector();
            try {
                xcs.setSubjectPublicKeyAlgID(algOID);
            xcs.setSubject(new X500Principal(sn).getName());
        } catch (IOException ioe) {
            throw new KeySelectorException(ioe);
        }
        ksr = keyStoreSelect(xcs);
        // check X509SKI
        } else if (o instanceof byte[]) {
            byte[] ski = (byte[]) o;
            X509CertSelector xcs = new X509CertSelector();
            try {
                xcs.setSubjectPublicKeyAlgID(algOID);
        } catch (IOException ioe) {
            throw new KeySelectorException(ioe);
        }
        // DER-encode ski - required by X509CertSelector
        byte[] encodedSki = new byte[ski.length+2];
        encodedSki[0] = 0x04; // OCTET STRING tag value
        encodedSki[1] = (byte) ski.length; // length
        System.arraycopy(ski, 0, encodedSki, 2, ski.length);
        xcs.setSubjectKeyIdentifier(encodedSki);
        ksr = keyStoreSelect(xcs);
        // check X509CRL
        // not supported: should use CertPath API
        } else {
            // skip all other entries
View Full Code Here

            X509Certificate cert, Set<X509Certificate> trustedRootCerts,
            Set<X509Certificate> intermediateCerts,
            boolean verifySelfSignedCert) throws GeneralSecurityException {

        // Create the selector that specifies the starting certificate
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(cert);

        // Create the trust anchors (set of root CA certificates)
        Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();
        for (X509Certificate trustedRootCert : trustedRootCerts) {
            trustAnchors.add(new TrustAnchor(trustedRootCert, null));
View Full Code Here

                                                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);
View Full Code Here

TOP

Related Classes of java.security.cert.X509CertSelector

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.