public void Initialize(ProviderConfiguration providerConfiguration, IList<string> scope = null, IRestClientFactory restClientFactory = null) { if (providerConfiguration == null) { throw new ArgumentNullException("providerConfiguration"); } if (providerConfiguration.Providers == null) { throw new ArgumentException("providerConfiguration.Providers"); } foreach (ProviderKey provider in providerConfiguration.Providers) { IAuthenticationProvider authenticationProvider; switch (provider.Name.ToLowerInvariant()) { case "facebook": authenticationProvider = new FacebookProvider(provider, scope, restClientFactory); break; case "google": authenticationProvider = new GoogleProvider(provider, scope, restClientFactory); break; case "twitter": authenticationProvider = new TwitterProvider(provider, restClientFactory); break; default: throw new ApplicationException( "Unhandled ProviderName found - unable to know which Provider Type to create."); } AddProvider(authenticationProvider); } }
public AuthenticationService(ProviderConfiguration providerConfiguration, IList<string> scope = null, IRestClient restClient = null) { Condition.Requires(providerConfiguration).IsNotNull(); Condition.Requires(providerConfiguration.Providers).IsNotNull(); var redirectUri = string.Format("{0}?{1}=", providerConfiguration.CallbackUri, providerConfiguration.CallbackQuerystringKey); foreach (ProviderKey provider in providerConfiguration.Providers) { var providerSpecificRedirectUri = new Uri((redirectUri + provider.Name).ToLower()); IAuthenticationProvider authenticationProvider; switch (provider.Name) { case ProviderType.Facebook: authenticationProvider = new FacebookProvider(provider, providerSpecificRedirectUri, scope, restClient); break; case ProviderType.Google: authenticationProvider = new GoogleProvider(provider, providerSpecificRedirectUri, scope, restClient); break; case ProviderType.Twitter: authenticationProvider = new TwitterProvider(provider, providerSpecificRedirectUri, restClient); break; default: throw new ApplicationException( "Unhandled ProviderType found - unable to know which Provider Type to create."); } AddProvider(authenticationProvider); } }
private static void SetupCustomConfigProviders(IList<Type> discoveredProviders, ProviderConfiguration providerConfig) { if (providerConfig.Providers == null) { throw new ArgumentException("providerConfiguration.Providers"); } foreach (ProviderKey provider in providerConfig.Providers) { var discoverProvider = DiscoverProvider(discoveredProviders, provider); Add(discoverProvider, false); } }
public AuthenticationService(ProviderConfiguration providerConfiguration, IList<string> scope = null, IRestClientFactory restClientFactory = null) { Initialize(providerConfiguration, scope, restClientFactory); }