code: protected PGPPrivateKey findPrivateKey(InputStream secretKey, final String userId, String password) throws PGPException, IOException {
      LOGGER.trace("findPrivateKey(InputStream, String, String)");
      LOGGER.trace("Secret Key: {}, User ID: {}, Password: {}", secretKey == null ? "not set" : "set", userId, password == null ? "not set" : "********");
      return findPrivateKey(secretKey, password, new KeyFilter<PGPSecretKey>() {
  
        @Override
        public boolean accept(PGPSecretKey secretKey) {
          boolean result = false;
          Iterator<String> userIdIterator = secretKey.getUserIDs();
          while (!result && userIdIterator.hasNext()) {
            result = userId.equals(userIdIterator.next());
          }
          return result;
        }
  
      });
    }
docs: read a private key and unlock it with the given password
  
  @param secretKey
  the secret key stream
  @param userId
  the required user id
  @param password
  the password to unlock the private key
  @return the applicable private key or null if none is found
  @throws PGPException
  @throws IOException