public static Optional<MultifactorAuthenticationProvider> getMultifactorAuthenticationProviderFromApplicationContext(
        final String providerId,
        final ApplicationContext applicationContext) {
        LOGGER.trace("Locating bean definition for [{}]", providerId);
        return getAvailableMultifactorAuthenticationProviders(applicationContext).values().stream()
            .filter(provider -> provider.matches(providerId))
            .findFirst();
    }
Gets multifactor authentication provider from application context.

@param providerId         the provider id
@param applicationContext the application context
@return the multifactor authentication provider from application context
core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/MultifactorAuthenticationUtils.java