code: private RSAPublicKey getKeyForUser(String userName) throws KeyNotFoundException {
      RSAPublicKey key = null;
      for (final KeyProvider keyProvider : keyProviders) {
        try {
          key = keyProvider.getKey(userName);
          break;
        } catch (KeyNotFoundException e) {
          // that's fine, try the next provider
        }
      }
  
      if (key == null) {
        throw new KeyNotFoundException();
      }
  
      return key;
    }
docs: Get the public key for a user by iterating through all key providers. The first
  matching key will be returned.
  
  @param userName the username to get the key for
  @return the first RSAPublicKey found for the user
  @throws KeyNotFoundException