Ejemplo n.º 1
0
        public AuthenticationService(AuthenticationProviderFactory factory, ApplicationSettings appSettings)
        {
            _factory = factory;

            if (!String.IsNullOrWhiteSpace(appSettings.FacebookAppId) && !String.IsNullOrWhiteSpace(appSettings.FacebookAppSecret))
            {
                _factory.AddProvider(new FacebookProvider(new ProviderParams
                {
                    PublicApiKey = appSettings.FacebookAppId,
                    SecretApiKey = appSettings.FacebookAppSecret
                }));
            }
            else
            {
                _factory.RemoveProvider("facebook");
            }
            if (!String.IsNullOrWhiteSpace(appSettings.TwitterConsumerKey) && !String.IsNullOrWhiteSpace(appSettings.TwitterConsumerSecret))
            {
                _factory.AddProvider(new TwitterProvider(new ProviderParams
                {
                    PublicApiKey = appSettings.TwitterConsumerKey,
                    SecretApiKey = appSettings.TwitterConsumerSecret
                }));
            }
            else
            {
                _factory.RemoveProvider("twitter");
            }
            if (!String.IsNullOrWhiteSpace(appSettings.GoogleClientID) && !String.IsNullOrWhiteSpace(appSettings.GoogleClientSecret))
            {
                _factory.AddProvider(new GoogleProvider(new ProviderParams
                {
                    PublicApiKey = appSettings.GoogleClientID,
                    SecretApiKey = appSettings.GoogleClientSecret
                }));
            }
            else
            {
                _factory.RemoveProvider("google");
            }
        }