protected AbstractClientProvider(OAuthWebConfigurationElement ccRoot, OAuthConfigurationElement ccOauth)
 {
     // TODO: This copying still feels wrong - config class and this client base class share data
     ClientId = ccOauth.ClientId;
     ClientSecret = ccOauth.ClientSecret;
     CallBackUrl = ccOauth.CallbackUrl;
     Scope = ccOauth.Scope;
     Endpoint = ccOauth.Endpoint;
     
     //AcceptedRedirectUrl = ccRoot.AcceptedRedirectUrl;
     FailedRedirectUrl = ccRoot.FailedRedirectUrl;
     Proxy = ccRoot.Proxy;
 }
Пример #2
0
        public static T CreateClient <T>(string oConfigurationName) where T : AbstractClientProvider, new()
        {
            Configuration.OAuthConfigurationSection clientConfiguration =
                ConfigurationManager.GetSection("oauth2.login.configuration") as Configuration.OAuthConfigurationSection;

            if (clientConfiguration != null)
            {
                string acceptedUrl = clientConfiguration.WebConfiguration.AcceptedRedirectUrl;
                string failedUrl   = clientConfiguration.WebConfiguration.FailedRedirectUrl;


                IEnumerator configurationReader = clientConfiguration.OAuthVClientConfigurations.GetEnumerator();

                while (configurationReader.MoveNext())
                {
                    if (configurationReader.Current is Configuration.OAuthConfigurationElement)
                    {
                        Configuration.OAuthConfigurationElement clientConfigurationElement =
                            configurationReader.Current as Configuration.OAuthConfigurationElement;

                        if (oConfigurationName != null)
                        {
                            if (clientConfigurationElement.Name == oConfigurationName)
                            {
                                T client = (T)Activator.CreateInstance(typeof(T), new object[] {
                                    clientConfigurationElement.ClientId,
                                    clientConfigurationElement.ClientSecret,
                                    clientConfigurationElement.CallbackUrl,
                                    clientConfigurationElement.Scope,
                                    acceptedUrl,
                                    failedUrl,
                                    clientConfigurationElement.Proxy
                                });

                                return(client);
                            }
                        }
                        else
                        {
                            throw new Exception("ERROR: [MultiOAuthFactroy] ConfigurationName is not found!");
                        }
                    }
                }
            }

            return(default(T));
        }
Пример #3
0
 public PayPalClient(OAuthWebConfigurationElement ccRoot, OAuthConfigurationElement ccOauth)
     : base(ccRoot, ccOauth)
 {
     //ServiceType = typeof (PayPalService);
 }
Пример #4
0
 public GoogleClient(OAuthWebConfigurationElement ccRoot, OAuthConfigurationElement ccOauth)
     : base(ccRoot, ccOauth)
 {
     //ServiceType = typeof (GoogleService);
 }
Пример #5
0
 public TwitterClient(OAuthWebConfigurationElement ccRoot, OAuthConfigurationElement ccOauth)
     : base(ccRoot, ccOauth)
 {
     //ServiceType = typeof(TwitterService);
 }
Пример #6
0
 public FacebookClient(OAuthWebConfigurationElement ccRoot, OAuthConfigurationElement ccOauth)
     : base(ccRoot, ccOauth)
 {
     //ServiceType = typeof (FacebookService);
 }
Пример #7
0
 public WindowsLiveClient(OAuthWebConfigurationElement ccRoot, OAuthConfigurationElement ccOauth)
     : base(ccRoot, ccOauth)
 {
     //ServiceType = typeof (WindowsLiveService);
 }