code: public void registerAuthenticationListener(String realm, AuthenticationListener listener) {
          if (realm == null || realm.isEmpty()) {
              throw new InvalidParameterException("The realm name can't be null or empty.");
          }
  
          if (listener == null) {
              throw new InvalidParameterException("The authentication listener object can't be null.");
          }
  
          ChallengeHandler handler = new ChallengeHandler();
          handler.initialize(realm, listener);
          challengeHandlers.put(realm, handler);
      }
docs: Registers authentication listener for specified realm.
  
  @param realm    authentication realm.
  @param listener authentication listener.