public static Optional<MultifactorAuthenticationProvider> getMultifactorAuthenticationProviderById(
        final String providerId, final ApplicationContext context) {
        return getAvailableMultifactorAuthenticationProviders(context)
            .values()
            .stream()
            .filter(provider -> StringUtils.isNotBlank(providerId) && provider.matches(providerId))
            .findFirst();
    }
Method returns an Optional that will contain a {@link MultifactorAuthenticationProvider} that has the
same id as the passed providerId parameter.

@param providerId - the id to match
@param context    - ApplicationContext
@return - Optional
core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/MultifactorAuthenticationUtils.java