code: public static Optional<MultifactorAuthenticationProvider> getMultifactorAuthenticationProviderFromApplicationContext(final String providerId) {
          try {
              LOGGER.trace("Locating bean definition for [{}]", providerId);
              return MultifactorAuthenticationUtils.getAvailableMultifactorAuthenticationProviders(ApplicationContextProvider.getApplicationContext()).values().stream()
                  .filter(p -> p.matches(providerId))
                  .findFirst();
          } catch (final Exception e) {
              LOGGER.trace("Could not locate [{}] bean id in the application context as an authentication provider.", providerId);
          }
          return Optional.empty();
      }
docs: Find the MultifactorAuthenticationProvider in the application contact that matches the specified providerId (e.g. "mfa-duo").
  
  @param providerId the provider id
  @return the registered service multifactor authentication provider