Source:
public Pair<Boolean, Optional<MultifactorAuthenticationProvider>> validateAuthenticationContext(final Assertion assertion, final HttpServletRequest request) { LOGGER.debug("Locating the primary authentication associated with this service request [{}]", assertion.getService()); val registeredService = servicesManager.findServiceBy(assertion.getService()); val authentication = assertion.getPrimaryAuthentication(); val requestedContext = multifactorTriggerSelectionStrategy.resolve(request, registeredService, authentication, assertion.getService()); if (requestedContext.isEmpty()) { LOGGER.debug("No particular authentication context is required for this request"); return Pair.of(Boolean.TRUE, Optional.empty()); } val providerId = requestedContext.get(); val providerOpt = MultifactorAuthenticationUtils.getMultifactorAuthenticationProviderById(providerId, ApplicationContextProvider.getApplicationContext()); if (providerOpt.isPresent()) { val provider = providerOpt.get(); if (provider.isAvailable(registeredService)) { val bypassEvaluator = provider.getBypassEvaluator(); if (!bypassEvaluator.shouldMultifactorAuthenticationProviderExecute(authentication, registeredService, provider, request)) { LOGGER.debug("MFA provider was determined that it should be bypassed for this service request [{}]", providerId, assertion.getService()); bypassEvaluator.updateAuthenticationToRememberBypass(authentication, provider); return Pair.of(Boolean.TRUE, Optional.empty()); } } else { val failure = provider.getFailureModeEvaluator().determineFailureMode(registeredService, provider); if (failure != RegisteredServiceMultifactorPolicy.FailureModes.CLOSED) { return Pair.of(Boolean.TRUE, Optional.empty()); } } } return authenticationContextValidator.validate(authentication, providerId, registeredService); }

Target:
public Pair<Boolean, Optional<MultifactorAuthenticationProvider>> validateAuthenticationContext(final Assertion assertion, final HttpServletRequest request) { LOGGER.debug("Locating the primary authentication associated with this service request [{}]", assertion.getService()); val registeredService = servicesManager.findServiceBy(assertion.getService()); val authentication = assertion.getPrimaryAuthentication(); val requestedContext = multifactorTriggerSelectionStrategy.resolve(request, registeredService, authentication, assertion.getService()); if (requestedContext.isEmpty()) { LOGGER.debug("No particular authentication context is required for this request"); return Pair.of(Boolean.TRUE, Optional.empty()); } val providerId = requestedContext.get(); val providerOpt = MultifactorAuthenticationUtils.getMultifactorAuthenticationProviderById(providerId, applicationContext); if (providerOpt.isPresent()) { val provider = providerOpt.get(); if (provider.isAvailable(registeredService)) { val bypassEvaluator = provider.getBypassEvaluator(); if (!bypassEvaluator.shouldMultifactorAuthenticationProviderExecute(authentication, registeredService, provider, request)) { LOGGER.debug("MFA provider was determined that it should be bypassed for this service request [{}]", providerId, assertion.getService()); bypassEvaluator.updateAuthenticationToRememberBypass(authentication, provider); return Pair.of(Boolean.TRUE, Optional.empty()); } } else { val failure = provider.getFailureModeEvaluator().evaluate(registeredService, provider); if (failure != RegisteredServiceMultifactorPolicy.FailureModes.CLOSED) { return Pair.of(Boolean.TRUE, Optional.empty()); } } } return authenticationContextValidator.validate(authentication, providerId, registeredService); }