List of usage examples for java.security.cert CertSelector match
boolean match(Certificate cert);
From source file:org.globus.gsi.stores.ResourceCertStore.java
/** * Returns a <code>Collection</code> of <code>Certificate</code>s that match * the specified selector. If no <code>Certificate</code>s match the * selector, an empty <code>Collection</code> will be returned. * <p/>//from w w w .java2s .c om * For some <code>CertStore</code> types, the resulting * <code>Collection</code> may not contain <b>all</b> of the * <code>Certificate</code>s that match the selector. For instance, an LDAP * <code>CertStore</code> may not search all entries in the directory. * Instead, it may just search entries that are likely to contain the * <code>Certificate</code>s it is looking for. * <p/> * Some <code>CertStore</code> implementations (especially LDAP * <code>CertStore</code>s) may throw a <code>CertStoreException</code> * unless a non-null <code>CertSelector</code> is provided that includes * specific criteria that can be used to find the certificates. Issuer * and/or subject names are especially useful criteria. * * @param selector * A <code>CertSelector</code> used to select which * <code>Certificate</code>s should be returned. Specify * <code>null</code> to return all <code>Certificate</code>s (if * supported). * @return A <code>Collection</code> of <code>Certificate</code>s that match * the specified selector (never <code>null</code>) * @throws java.security.cert.CertStoreException * if an exception occurs */ public Collection<? extends Certificate> engineGetCertificates(CertSelector selector) throws CertStoreException { logger.debug("selecting Certificates"); if (selector != null && !(selector instanceof X509CertSelector)) { throw new IllegalArgumentException(); } if (caDelegate.getCollection() == null) { return null; } // Given that we always only use subject, how can we improve performance // here. Custom Vector<X509Certificate> certSet = new Vector<X509Certificate>(); if (selector == null) { for (TrustAnchor trustAnchor : caDelegate.getCollection()) { certSet.add(trustAnchor.getTrustedCert()); } } else { for (TrustAnchor trustAnchor : caDelegate.getCollection()) { X509Certificate cert = trustAnchor.getTrustedCert(); if (selector.match(cert)) { certSet.add(cert); } } } return certSet; }