code: X509Certificate selectCertificate(final CertStore store,
  			final Collection<X509CertSelector> selectors) throws CertStoreException {
  		for (CertSelector selector : selectors) {
  			LOGGER.debug("Selecting certificate using {}", selector);
  			Collection<? extends Certificate> certs = store
  					.getCertificates(selector);
  			if (certs.size() > 0) {
  				LOGGER.debug("Selected {} certificate(s) using {}",
  						certs.size(), selector);
  				return (X509Certificate) certs.iterator().next();
  			} else {
  				LOGGER.debug("No certificates selected");
  			}
  		}
  		return (X509Certificate) store.getCertificates(null).iterator().next();
  	}
docs: Finds the certificate of the SCEP message object recipient.
  
  @param store
  the certificate store to inspect.
  @return the recipient's certificate.
  @throws CertStoreException
  if the CertStore cannot be inspected