/**
   * Looks up the mfa data for a specific service.
   *
   * @param targetService the service to check
   * @return service specific mfa settings
   */
  private ServiceMfaData getServicesAuthenticationData(final WebApplicationService targetService) {
    final RegisteredService registeredService = this.servicesManager.findServiceBy(targetService);
    if (registeredService == null) {
      logger.debug(
          "No registered service is found. Delegating to the next argument extractor in the chain...");
      return null;
    }

    if (!(registeredService instanceof RegisteredServiceWithAttributes)) {
      logger.debug("Registered service is not capable of defining an mfa attribute.");
      return null;
    }

    final ServiceMfaData serviceData = new ServiceMfaData();

    final RegisteredServiceWithAttributes service =
        RegisteredServiceWithAttributes.class.cast(registeredService);

    final Map mfaRole = Map.class.cast(service.getExtraAttributes().get(MFA_ROLE));
    if (mfaRole == null) {
      return null;
    }

    serviceData.setAttributeName(String.class.cast(mfaRole.get(MFA_ATTRIBUTE_NAME)));
    serviceData.setAttributePattern(String.class.cast(mfaRole.get(MFA_ATTRIBUTE_PATTERN)));
    serviceData.setAuthenticationMethod(
        String.class.cast(service.getExtraAttributes().get(AUTHN_METHOD)));

    if (serviceData.isValid()) {
      return serviceData;
    }

    return null;
  }