private Set<Event> resolveEventViaMultivaluedPrincipalAttribute(
      final Principal principal,
      final Object attributeValue,
      final RegisteredService service,
      final RequestContext context,
      final MultifactorAuthenticationProvider provider,
      final Predicate<String> predicate) {
    final ImmutableSet.Builder<Event> builder = ImmutableSet.builder();
    if (attributeValue instanceof Collection) {
      logger.debug("Attribute value {} is a multi-valued attribute", attributeValue);
      final Collection<String> values = (Collection<String>) attributeValue;
      for (final String value : values) {
        try {
          if (predicate.test(value)) {
            logger.debug(
                "Attribute value predicate {} has successfully matched the [{}]", predicate, value);

            logger.debug(
                "Attempting to verify multifactor authentication provider {} for {}",
                provider,
                service);
            if (provider.isAvailable(service)) {
              logger.debug("Provider {} is successfully verified", provider);

              final String id = provider.getId();
              final Event event =
                  validateEventIdForMatchingTransitionInContext(
                      id, context, buildEventAttributeMap(principal, service, provider));
              builder.add(event);
            }
          } else {
            logger.debug("Attribute value predicate {} could not match the [{}]", predicate, value);
          }
        } catch (final Exception e) {
          logger.debug("Ignoring {} since no matching transition could be found", value);
        }
      }
      return builder.build();
    }
    logger.debug(
        "Attribute value {} of type {} is not a multi-valued attribute",
        attributeValue,
        attributeValue.getClass());
    return null;
  }
  private Set<Event> resolveEventViaSinglePrincipalAttribute(
      final Principal principal,
      final Object attributeValue,
      final RegisteredService service,
      final RequestContext context,
      final MultifactorAuthenticationProvider provider,
      final Predicate<String> predicate) {
    try {
      if (attributeValue instanceof String) {
        logger.debug("Attribute value {} is a single-valued attribute", attributeValue);
        if (predicate.test((String) attributeValue)) {
          logger.debug(
              "Attribute value predicate {} has matched the [{}]", predicate, attributeValue);

          logger.debug(
              "Attempting to isAvailable multifactor authentication provider {} for {}",
              provider,
              service);

          if (provider.isAvailable(service)) {
            logger.debug("Provider {} is successfully verified", provider);
            final String id = provider.getId();
            final Event event =
                validateEventIdForMatchingTransitionInContext(
                    id, context, buildEventAttributeMap(principal, service, provider));
            return ImmutableSet.of(event);
          } else {
            logger.debug("Provider {} could not be verified", provider);
          }
        } else {
          logger.debug(
              "Attribute value predicate {} could not match the [{}]", predicate, attributeValue);
        }
      }
    } catch (final Exception e) {
      throw Throwables.propagate(e);
    }
    logger.debug("Attribute value {} is not a single-valued attribute", attributeValue);
    return null;
  }