code: public static Pair<Boolean, Optional<Map<String, Object>>> authenticate(final String username,
                                                                              final String password,
                                                                              final List<RadiusServer> servers,
                                                                              final boolean failoverOnAuthenticationFailure,
                                                                              final boolean failoverOnException,
                                                                              final Optional state) throws Exception {
          for (val radiusServer : servers) {
              LOGGER.debug("Attempting to authenticate [{}] at [{}]", username, radiusServer);
              try {
                  val response = radiusServer.authenticate(username, password, state);
                  if (response != null) {
                      val attributes = new HashMap<String, Object>();
                      response.getAttributes().forEach(attribute -> attributes.put(attribute.getAttributeName(), attribute.getValue()));
                      return Pair.of(Boolean.TRUE, Optional.of(attributes));
                  }
  
                  if (!failoverOnAuthenticationFailure) {
                      throw new FailedLoginException("Radius authentication failed for user " + username);
                  }
                  LOGGER.debug("failoverOnAuthenticationFailure enabled -- trying next server");
              } catch (final Exception e) {
                  if (!failoverOnException) {
                      throw e;
                  }
                  LOGGER.warn("failoverOnException enabled -- trying next server.", e);
              }
          }
          return Pair.of(Boolean.FALSE, Optional.empty());
      }
docs: Authenticate pair.
  
  @param username                        the username
  @param password                        the password
  @param servers                         the servers
  @param failoverOnAuthenticationFailure the failover on authentication failure
  @param failoverOnException             the failover on exception
  @param state                           the state
  @return the pair
  @throws Exception the exception