code: public boolean needAuthorization(ResponseEvent event) {
      Response response = event.getResponse();
      int status = response.getStatusCode();
  
      if ((status == Response.UNAUTHORIZED) || (status == Response.PROXY_AUTHENTICATION_REQUIRED)) {
        return true;
      }
  
      return false;
    }
docs: Called to find out if a sent NOTIFY was challenged. See related method
  resendWithAuthorization().
  
  @param event object returned by waitResponse().
  @return true if response status is UNAUTHORIZED or PROXY_AUTHENTICATION_REQUIRED, false
  otherwise.