code: protected PGPSecretKey retrieveSecretKey(PGPSecretKeyRingCollection secretKeyRingCollection, KeyFilter<PGPSecretKey> keyFilter) throws PGPException {
      LOGGER.trace("retrieveSecretKey(PGPSecretKeyRingCollection, KeyFilter<PGPSecretKey>)");
      LOGGER.trace("Secret KeyRing Collection: {}, Key Filter: {}", secretKeyRingCollection == null ? "not set" : "set", keyFilter == null ? "not set" : "set");
      PGPSecretKey result = null;
      Iterator<PGPSecretKeyRing> secretKeyRingIterator = secretKeyRingCollection.getKeyRings();
      PGPSecretKeyRing secretKeyRing = null;
      LOGGER.debug("Iterating secret key ring");
      while( result == null && secretKeyRingIterator.hasNext() ) {
        secretKeyRing = secretKeyRingIterator.next();
        Iterator<PGPSecretKey> secretKeyIterator = secretKeyRing.getSecretKeys();
        LOGGER.debug("Iterating secret keys in key ring");
        while( secretKeyIterator.hasNext() ) {
          PGPSecretKey secretKey = secretKeyIterator.next();
          LOGGER.info("Found secret key: {}", secretKey.getKeyID());
          LOGGER.debug("Checking secret key with filter");
          if (keyFilter.accept(secretKey)) {
            LOGGER.info("Key {} selected from secret key ring");
            result = secretKey;
          }
        }
      }
      return result;
    }
docs: retrieve the appropriate secret key from the secret key ring collection
  based on the key filter
  
  @param secretKeyRingCollection
  the PGP secret key ring collection
  @param keyFilter
  the key filter to apply
  @return the secret key or null if none matches the filter
  @throws PGPException