Esempio n. 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OAuthChannel"/> class.
		/// </summary>
		/// <param name="signingBindingElement">The binding element to use for signing.</param>
		/// <param name="store">The web application store to use for nonces.</param>
		/// <param name="tokenManager">The token manager instance to use.</param>
		internal OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IConsumerTokenManager tokenManager)
			: this(
			signingBindingElement,
			store,
			tokenManager,
			new OAuthConsumerMessageFactory()) {
		}
Esempio n. 2
0
 public JohnDeereClient(HttpContextBase context, string baseAddress, string consumerKey, string consumerSecret)
 {
     _BaseAddress  = baseAddress;
     _Context      = context;
     _TokenManager = new SimpleConsumerTokenManager(consumerKey, consumerSecret, new CookieOAuthTokenManager(context));
     _WebWorker    = new WebConsumer(ServiceDescription, _TokenManager);
 }
        public TwitterProxy(IConsumerTokenManager manager, ISignInEndpointBuilder endpointBuilder,
            IFubuRequest request, ISystemUrls urls)
        {
            _request = request;
            _urls = urls;

            var endpoints = endpointBuilder.Build();
            _consumer = new WebConsumer(endpoints, manager);
        }
        public TwitterProxy(IConsumerTokenManager manager, ISignInEndpointBuilder endpointBuilder,
                            IFubuRequest request, ISystemUrls urls)
        {
            _request = request;
            _urls    = urls;

            var endpoints = endpointBuilder.Build();

            _consumer = new WebConsumer(endpoints, manager);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsumerBase"/> class.
        /// </summary>
        /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
        /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
        protected ConsumerBase(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
        {
            ErrorUtilities.VerifyArgumentNotNull(serviceDescription, "serviceDescription");
            ErrorUtilities.VerifyArgumentNotNull(tokenManager, "tokenManager");

            ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
            INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge);
            this.OAuthChannel = new OAuthChannel(signingElement, store, tokenManager);
            this.ServiceProvider = serviceDescription;
            this.SecuritySettings = DotNetOpenAuthSection.Configuration.OAuth.Consumer.SecuritySettings.CreateSecuritySettings();
        }
		internal OAuthConsumerChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IConsumerTokenManager tokenManager, ConsumerSecuritySettings securitySettings, IMessageFactory messageFactory = null)
			: base(
			signingBindingElement,
			tokenManager,
			securitySettings,
			messageFactory ?? new OAuthConsumerMessageFactory(),
			InitializeBindingElements(signingBindingElement, store)) {
			Requires.NotNull(tokenManager, "tokenManager");
			Requires.NotNull(securitySettings, "securitySettings");
			Requires.NotNull(signingBindingElement, "signingBindingElement");
		}
Esempio n. 7
0
        public static string GetAccessToken(
            IConsumerTokenManager tokenManager, string requestToken, string verifier)
        {
            DesktopConsumer desktopConsumer = new DesktopConsumer(ServiceDescription, tokenManager);

            var accessToken = desktopConsumer.ProcessUserAuthorization(requestToken, verifier);

            return(string.Format("{0}={1}",
                                 accessToken.AccessToken,
                                 tokenManager.GetTokenSecret(accessToken.AccessToken)));
        }
Esempio n. 8
0
		internal OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IConsumerTokenManager tokenManager, ConsumerSecuritySettings securitySettings)
			: this(
			signingBindingElement,
			store,
			tokenManager,
			securitySettings,
			new OAuthConsumerMessageFactory()) {
			Contract.Requires<ArgumentNullException>(tokenManager != null);
			Contract.Requires<ArgumentNullException>(securitySettings != null);
			Contract.Requires<ArgumentNullException>(signingBindingElement != null);
			Contract.Requires<ArgumentException>(signingBindingElement.SignatureCallback == null, OAuthStrings.SigningElementAlreadyAssociatedWithChannel);
		}
        protected MiiCardOAuthServiceBase(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, bool useDeclarativeBinding, Binding binding, EndpointAddress endpointAddress)
        {
            this.AccessToken = accessToken;

            this._tokenManager = new SingleAccessTokenManager(consumerKey, consumerSecret, AccessToken, accessTokenSecret);

            this._defaultBinding = this.GetDefaultBinding();
            this._specificBinding = binding;
            this._specificEndpointAddress = endpointAddress;

            this.UseDeclarativeBindingConfiguration = useDeclarativeBinding;
        }
Esempio n. 10
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ConsumerBase"/> class.
		/// </summary>
		/// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
		/// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
		protected ConsumerBase(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager) {
			Requires.NotNull(serviceDescription, "serviceDescription");
			Requires.NotNull(tokenManager, "tokenManager");

			ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
			INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge);
			this.SecuritySettings = OAuthElement.Configuration.Consumer.SecuritySettings.CreateSecuritySettings();
			this.OAuthChannel = new OAuthConsumerChannel(signingElement, store, tokenManager, this.SecuritySettings);
			this.ServiceProvider = serviceDescription;

			OAuthReporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, null);
		}
Esempio n. 11
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ConsumerBase"/> class.
		/// </summary>
		/// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
		/// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
		protected ConsumerBase(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager) {
			Contract.Requires<ArgumentNullException>(serviceDescription != null);
			Contract.Requires<ArgumentNullException>(tokenManager != null);

			ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
			INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge);
			this.SecuritySettings = DotNetOpenAuthSection.Configuration.OAuth.Consumer.SecuritySettings.CreateSecuritySettings();
			this.OAuthChannel = new OAuthChannel(signingElement, store, tokenManager, this.SecuritySettings);
			this.ServiceProvider = serviceDescription;

			Reporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, null);
		}
Esempio n. 12
0
        protected MiiCardOAuthServiceBase(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, bool useDeclarativeBinding, Binding binding, EndpointAddress endpointAddress)
        {
            this.AccessToken = accessToken;

            this._tokenManager = new SingleAccessTokenManager(consumerKey, consumerSecret, AccessToken, accessTokenSecret);

            this._defaultBinding          = this.GetDefaultBinding();
            this._specificBinding         = binding;
            this._specificEndpointAddress = endpointAddress;

            this.UseDeclarativeBindingConfiguration = useDeclarativeBinding;
        }
Esempio n. 13
0
        public static Uri GetRequestURL(IConsumerTokenManager tokenManager, string account)
        {
            DesktopConsumer desktopConsumer = new DesktopConsumer(ServiceDescription, tokenManager);

            Dictionary <string, string> requestParams = new Dictionary <string, string>();

            requestParams.Add("oauth_callback", string.Format("{0}/PCOResult.aspx?account={1}",
                                                              Arena.Utility.ArenaUrl.FullApplicationRoot(), account));

            string requestToken = string.Empty;

            return(desktopConsumer.RequestUserAuthorization(requestParams, null, out requestToken));
        }
Esempio n. 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsumerBase"/> class.
        /// </summary>
        /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
        /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
        protected ConsumerBase(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
        {
            Requires.NotNull(serviceDescription, "serviceDescription");
            Requires.NotNull(tokenManager, "tokenManager");

            ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
            INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge);

            this.SecuritySettings = OAuthElement.Configuration.Consumer.SecuritySettings.CreateSecuritySettings();
            this.OAuthChannel     = new OAuthConsumerChannel(signingElement, store, tokenManager, this.SecuritySettings);
            this.ServiceProvider  = serviceDescription;

            OAuthReporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, null);
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsumerBase"/> class.
        /// </summary>
        /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
        /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
        protected ConsumerBase(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
        {
            Contract.Requires <ArgumentNullException>(serviceDescription != null);
            Contract.Requires <ArgumentNullException>(tokenManager != null);

            ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
            INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge);

            this.OAuthChannel     = new OAuthChannel(signingElement, store, tokenManager);
            this.ServiceProvider  = serviceDescription;
            this.SecuritySettings = DotNetOpenAuthSection.Configuration.OAuth.Consumer.SecuritySettings.CreateSecuritySettings();

            Reporting.RecordFeatureAndDependencyUse(this, serviceDescription, tokenManager, null);
        }
Esempio n. 16
0
        public static LinkedInDataProvider GetLinkedInDataProviderForCurrentUser()
        {
            IConsumerTokenManager tokenManager = null;
            string accessToken = null;

            string consumerKey       = KeyStorage.Get(SocialMediaConstants.ConfigKeyLinkedInConsumerKey);
            string consumerKeySecret = KeyStorage.Get(SocialMediaConstants.ConfigKeyLinkedInConsumerSecretKey);

            accessToken = KeyStorage.Get(SocialMediaConstants.ConfigKeyLinkedInDefaultAccessToken);
            if (String.IsNullOrEmpty(accessToken))
            {
                return(null);
            }
            tokenManager = new LinkedInDefaultAccountTokenManager(consumerKey, consumerKeySecret);
            return(new LinkedInDataProvider(tokenManager, accessToken));
        }
Esempio n. 17
0
        public void ProcessAuthRequest(IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(TwitterConsumer.SignInWithTwitterServiceDescription, tokenManager);

            var response = _webConsumer.ProcessUserAuthorization();

            if (response == null)
            {
                return;
            }

            var screenName = response.ExtraData["screen_name"];
            var userId     = int.Parse(response.ExtraData["user_id"]);

            UserId     = userId.ToString(CultureInfo.CurrentCulture);
            UserName   = screenName;
            PictureUrl = string.Format("http://api.twitter.com/1/users/profile_image/{0}.png", screenName);
        }
        public void ProcessAuthRequest(IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(TwitterConsumer.SignInWithTwitterServiceDescription, tokenManager);

            var response = _webConsumer.ProcessUserAuthorization();

            if (response == null)
            {
                return;
            }

            var screenName = response.ExtraData["screen_name"];
            var userId = int.Parse(response.ExtraData["user_id"]);

            UserId = userId.ToString(CultureInfo.CurrentCulture);
            UserName = screenName;
            PictureUrl = string.Format("http://api.twitter.com/1/users/profile_image/{0}.png", screenName);
        }
        public ActionResult PrepareAuthRequest(Uri callback, IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager);

            var accessToken = GetAccessToken();

            if (string.IsNullOrEmpty(accessToken))
            {
                var extraParameters = new Dictionary <string, string>();

                extraParameters.Add("scope", "https://www.googleapis.com/auth/userinfo.profile");
                var request = _webConsumer.PrepareRequestUserAuthorization(callback, extraParameters, null);

                return(_webConsumer.Channel.PrepareResponse(request).AsActionResult());
            }

            return(null);
        }
        public void ProcessAuthRequest(IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager);

            var accessToken = GetAccessToken();

            if (string.IsNullOrEmpty(accessToken)) 
                throw new NoNullAllowedException("AccessToken should not be null");

            var request = _webConsumer.PrepareAuthorizedRequest(_getUserInfoEndpoint, accessToken);
            var response = _webConsumer.Channel.WebRequestHandler.GetResponse(request);
            var json = response.GetResponseReader().ReadToEnd();
            
            var jsonObject = JObject.Parse(json);
            UserId = jsonObject["id"].ToString();
            UserName = jsonObject["name"].ToString();
            PictureUrl = jsonObject["picture"].ToString();
        }
        public ActionResult PrepareAuthRequest(Uri callback, IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager);

            var accessToken = GetAccessToken();

            if (string.IsNullOrEmpty(accessToken))
            {
                var extraParameters = new Dictionary<string, string>();

                extraParameters.Add("scope", "https://www.googleapis.com/auth/userinfo.profile");
                var request = _webConsumer.PrepareRequestUserAuthorization(callback, extraParameters, null);

                return _webConsumer.Channel.PrepareResponse(request).AsActionResult();
            }

            return null;
        }
        public ActionResult PrepareAuthRequest(Uri callback, IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(TwitterConsumer.SignInWithTwitterServiceDescription, tokenManager);

            var token = GetAccessToken();

            if (string.IsNullOrEmpty(token))
            {
                var redirectParameters = new Dictionary<string, string>();

                redirectParameters["force_login"] = "******";

                var request = _webConsumer.PrepareRequestUserAuthorization(callback, null, redirectParameters);

                return _webConsumer.Channel.PrepareResponse(request).AsActionResult();
            }

            return null;
        }
Esempio n. 23
0
        public ActionResult PrepareAuthRequest(Uri callback, IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(TwitterConsumer.SignInWithTwitterServiceDescription, tokenManager);

            var token = GetAccessToken();

            if (string.IsNullOrEmpty(token))
            {
                var redirectParameters = new Dictionary <string, string>();

                redirectParameters["force_login"] = "******";

                var request = _webConsumer.PrepareRequestUserAuthorization(callback, null, redirectParameters);

                return(_webConsumer.Channel.PrepareResponse(request).AsActionResult());
            }

            return(null);
        }
Esempio n. 24
0
            public static object GetUserProfile(IConsumerTokenManager tokenManager, MessageReceivingEndpoint profileEndpoint, string accessToken)
            {
                var w       = new WebConsumer(MxServiceDescription, tokenManager);
                var request = w.PrepareAuthorizedRequest(profileEndpoint, accessToken);

                try
                {
                    using (WebResponse profileResponse = request.GetResponse())
                    {
                        using (Stream responseStream = profileResponse.GetResponseStream())
                        {
                        }
                    }
                }
                catch (Exception exception)
                {
                    return(new AuthenticationResult(exception));
                }

                return(null);
            }
        public void ProcessAuthRequest(IConsumerTokenManager tokenManager)
        {
            _webConsumer = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager);

            var accessToken = GetAccessToken();

            if (string.IsNullOrEmpty(accessToken))
            {
                throw new NoNullAllowedException("AccessToken should not be null");
            }

            var request  = _webConsumer.PrepareAuthorizedRequest(_getUserInfoEndpoint, accessToken);
            var response = _webConsumer.Channel.WebRequestHandler.GetResponse(request);
            var json     = response.GetResponseReader().ReadToEnd();

            var jsonObject = JObject.Parse(json);

            UserId     = jsonObject["id"].ToString();
            UserName   = jsonObject["name"].ToString();
            PictureUrl = jsonObject["picture"].ToString();
        }
Esempio n. 26
0
        public People(IConsumerTokenManager tokenManager, int organizationId, Lookup pcoAccount, string publicArenaUrl)
        {
            IConsumerTokenManager tManager = tokenManager ?? new InMemoryTokenManager(organizationId, pcoAccount);

            _organizationId    = organizationId;
            _pcoAccount        = pcoAccount;
            _pcoAttributeGroup = GetPcoAttributeGroup(_organizationId, _pcoAccount);

            _publicArenaUrl = publicArenaUrl.Trim();
            if (!_publicArenaUrl.EndsWith("/"))
            {
                _publicArenaUrl += "/";
            }

            _accessToken = pcoAccount.Qualifier;
            if (_accessToken.Trim() == string.Empty)
            {
                throw new ApplicationException("'Access Token' does not exist.  Make sure you have successfully authorized your Arena installation with Planning Center Online!");
            }

            _pcoConsumer = new WebConsumer(Consumer.ServiceDescription, tManager);
        }
Esempio n. 27
0
 internal OAuthConsumerChannel(ITamperProtectionChannelBindingElement signingBindingElement, INonceStore store, IConsumerTokenManager tokenManager, ConsumerSecuritySettings securitySettings, IMessageFactory messageFactory = null)
     : base(
         signingBindingElement,
         tokenManager,
         securitySettings,
         messageFactory ?? new OAuthConsumerMessageFactory(),
         InitializeBindingElements(signingBindingElement, store))
 {
     Requires.NotNull(tokenManager, "tokenManager");
     Requires.NotNull(securitySettings, "securitySettings");
     Requires.NotNull(signingBindingElement, "signingBindingElement");
 }
Esempio n. 28
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OAuthClient"/> class.
		/// </summary>
		/// <param name="providerName">
		/// Name of the provider. 
		/// </param>
		/// <param name="serviceDescription">
		/// The service Description.
		/// </param>
		/// <param name="tokenManager">
		/// The token Manager.
		/// </param>
		protected OAuthClient(
			string providerName, ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
			: this(providerName, new DotNetOpenAuthWebConsumer(serviceDescription, tokenManager)) {}
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebConsumer"/> class.
 /// </summary>
 /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
 /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
 public WebConsumer(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
     : base(serviceDescription, tokenManager)
 {
 }
 public LinkedInDataProvider(IConsumerTokenManager tokenManager, string accessToken)
 {
     _tokenManager = tokenManager;
     _accessToken = accessToken;
 }
Esempio n. 31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebOAuthAuthorization"/> class.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token, or null if the user doesn't have one yet.</param>
 public MvcOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken)
     : base(tokenManager, accessToken)
 {
 }
 public static WebConsumer GetConsumer(ServiceProviderDescription serviceProviderDescription, IConsumerTokenManager tokenManager)
 {
     return new WebConsumer(serviceProviderDescription, tokenManager);
 }
Esempio n. 33
0
 public TwitterClient(IConsumerTokenManager tokenManager, string callBackUrl)
 {
     _tokenManager = tokenManager;
     CallBackUrl = callBackUrl;
 }
Esempio n. 34
0
 public TwitterClient(IConsumerTokenManager tokenManager)
 {
     _tokenManager = tokenManager;
 }
 public static void GoogleAuthRequestProcessed(this IGoogleAuthRequestProcessed source, IConsumerTokenManager tokenManager)
 {
     source.ProcessAuthRequest(tokenManager);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CoordinatingOAuthConsumerChannel"/> class.
 /// </summary>
 /// <param name="signingBindingElement">The signing element for the Consumer to use.  Null for the Service Provider.</param>
 /// <param name="tokenManager">The token manager to use.</param>
 /// <param name="securitySettings">The security settings.</param>
 internal CoordinatingOAuthConsumerChannel(ITamperProtectionChannelBindingElement signingBindingElement, IConsumerTokenManager tokenManager, DotNetOpenAuth.OAuth.ConsumerSecuritySettings securitySettings)
     : base(
         signingBindingElement,
         new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge),
         tokenManager,
         securitySettings)
 {
 }
Esempio n. 37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DotNetOpenAuthWebConsumer"/> class.
        /// </summary>
        /// <param name="serviceDescription">
        /// The service description.
        /// </param>
        /// <param name="tokenManager">
        /// The token manager.
        /// </param>
        public DotNetOpenAuthWebConsumer(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
        {
            Requires.NotNull(serviceDescription, "serviceDescription");
            Requires.NotNull(tokenManager, "tokenManager");

            this.webConsumer = new WebConsumer(serviceDescription, tokenManager);
        }
Esempio n. 38
0
 public LinkedInInfo(IConsumerTokenManager tokenManager, string accessToken)
 {
     this.AccessToken = accessToken;
     this.TokenManager = tokenManager;
 }
Esempio n. 39
0
 public LinkedInInfo(IConsumerTokenManager tokenManager, string accessToken)
 {
     this.AccessToken  = accessToken;
     this.TokenManager = tokenManager;
 }
 public static void TwitterAuthRequestProcessed(this ITwitterAuthRequestProcessed source, IConsumerTokenManager tokenManager)
 {
     source.ProcessAuthRequest(tokenManager);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DesktopOAuthAuthorization"/> class
 /// that uses a custom token manager.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token.</param>
 public DesktopOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken, ServiceProviderDescription serviceProviderDescription)
     : base(new DesktopConsumer(serviceProviderDescription, tokenManager))
 {
     this.accessToken = accessToken;
 }
Esempio n. 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebOAuthAuthentication"/> class.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token, or null if the user doesn't have one yet.</param>
 public WebOAuthAuthentication(IConsumerTokenManager tokenManager, string accessToken)
     : base(tokenManager, accessToken, ServiceDescriptions.LinkedInAuthenticationServiceDescription)
 {
 }
 public static WebConsumer GetConsumer(IConsumerTokenManager tokenManager)
 {
     return MiiCardConsumer.GetConsumer(MiiCardConsumer.ServiceDescription, tokenManager);
 }
Esempio n. 44
0
            public static object GetUserProfile(IConsumerTokenManager tokenManager, MessageReceivingEndpoint profileEndpoint, string accessToken)
            {
                var w = new WebConsumer(MxServiceDescription, tokenManager);
                var request = w.PrepareAuthorizedRequest(profileEndpoint, accessToken);

                try
                {
                    using (WebResponse profileResponse = request.GetResponse())
                    {
                        using (Stream responseStream = profileResponse.GetResponseStream())
                        {

                        }
                    }
                }
                catch (Exception exception)
                {
                    return new AuthenticationResult(exception);
                }

                return null;
            }
 public static WebConsumer GetConsumer(Uri oauthUri, IConsumerTokenManager tokenManager)
 {
     return new WebConsumer(GetServiceProviderDescription(oauthUri), tokenManager);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WebOAuthAuthorization"/> class.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token, or null if the user doesn't have one yet.</param>
 public WebOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken)
     : this(tokenManager, accessToken, ServiceDescriptions.LinkedInServiceDescription)
 {
 }
Esempio n. 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebOAuthAuthorization"/> class.
 /// </summary>
 /// <param name="serviceProviderDescription">The service provider description.</param>
 public MvcOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken, ServiceProviderDescription serviceProviderDescription) :
     base(tokenManager, accessToken, serviceProviderDescription)
 {
 }
Esempio n. 48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DesktopOAuthAuthorization"/> class
 /// that uses a custom token manager.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token.</param>
 public DesktopOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken)
     : this(tokenManager, accessToken, TwitterServiceDescription)
 {
 }
Esempio n. 49
0
		public static DesktopConsumer CreateConsumer(IConsumerTokenManager tokenManager) {
			return new DesktopConsumer(ServiceDescription, tokenManager);
		}
Esempio n. 50
0
        protected override void OnLoad(EventArgs e)
        {
            // If we've not yet been supplied a TokenManager then build a session-based one
            if (this.TokenManager == null)
            {
                // First try pulling key and secret information from application settings
                string consumerKey    = ConfigurationManager.AppSettings[MiiCard.ConfigSettingNameMiiCardConsumerKey];
                string consumerSecret = ConfigurationManager.AppSettings[MiiCard.ConfigSettingNameMiiCardConsumerSecret];

                // We require at least a consumer key be available - if it's not, bail out as there's no further
                // we can realistically go
                if (string.IsNullOrWhiteSpace(consumerKey))
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "The TokenManager was not initialised with suitable consumer key and secret information, and the information could not " +
                                  "be found in web.config. Either explicitly specify an IConsumerTokenManager to be used via the TokenManager property, or " +
                                  "add appropriate entries to your web.config's appSettings section with key names {0} and {1}.",
                                  MiiCard.ConfigSettingNameMiiCardConsumerKey,
                                  MiiCard.ConfigSettingNameMiiCardConsumerSecret)
                              );
                }

                this.TokenManager = new SessionStateConsumerTokenManager(consumerKey, consumerSecret);
            }

            Page.RegisterRequiresViewStateEncryption();

            var consumer = this.GetConsumer();
            AuthorizedTokenResponse authTokenResponse = null;

            try
            {
                authTokenResponse = consumer.ProcessUserAuthorization();
            }
            catch (Exception ex)
            {
                this.AuthorisationFailed(this, new MiiCardAuthorisationFailureEventArgs(ex));
            }

            if (authTokenResponse != null)
            {
                // We've been successfully authenticated - if we've been configured to do so then pull down the
                // user's profile so that it can be made available to the event handler
                MiiApiResponse <MiiUserProfile> response = null;

                if (this.LoadUserProfileOnAuthorise)
                {
                    var service = new MiiCardOAuthClaimsService(this.TokenManager.ConsumerKey, this.TokenManager.ConsumerSecret, authTokenResponse.AccessToken, this.TokenManager.GetTokenSecret(authTokenResponse.AccessToken));
                    response = service.GetClaims();

                    if (response.Status == MiiApiCallStatus.Success)
                    {
                        // User profile will be stored in the correct location based on the setting of the
                        // this.UserProfileStorage property
                        this.UserProfile = response;
                        this.AuthorisationSucceeded(this, new MiiCardAuthorisationSuccessEventArgs(authTokenResponse.AccessToken, this.TokenManager.GetTokenSecret(authTokenResponse.AccessToken), authTokenResponse.ExtraData, response));
                    }
                    else
                    {
                        this.AuthorisationFailed(this, new MiiCardAuthorisationFailureEventArgs(response.ErrorCode, response.ErrorMessage));
                    }
                }
                else
                {
                    this.AuthorisationSucceeded(this, new MiiCardAuthorisationSuccessEventArgs(authTokenResponse.AccessToken, this.TokenManager.GetTokenSecret(authTokenResponse.AccessToken), authTokenResponse.ExtraData, null));
                }
            }

            base.OnLoad(e);
        }
Esempio n. 51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DesktopConsumer"/> class.
 /// </summary>
 /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
 /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
 public DesktopConsumer(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager)
     : base(serviceDescription, tokenManager)
 {
 }
Esempio n. 52
0
 public MxClient(IConsumerTokenManager tokenManager)
     : base(NAME, MxServiceDescription, tokenManager)
 {
     this.TokenManager = tokenManager;
 }
Esempio n. 53
0
 public static DesktopConsumer CreateConsumer(IConsumerTokenManager tokenManager)
 {
     return(new DesktopConsumer(ServiceDescription, tokenManager));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DesktopOAuthAuthorization"/> class
 /// that uses a custom token manager.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token.</param>
 public DesktopOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken)
     : this(tokenManager, accessToken, TwitterServiceDescription)
 {
 }
Esempio n. 55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DesktopOAuthAuthorization"/> class
 /// that uses a custom token manager.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token.</param>
 public DesktopOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken, ServiceProviderDescription serviceProviderDescription)
     : base(new DesktopConsumer(serviceProviderDescription, tokenManager))
 {
     this.accessToken = accessToken;
 }
Esempio n. 56
0
 public YDBaseAPI(ConsumerBase consumer,string accessToken)
 {
     _consumer = consumer;
     _tokenManager = consumer.TokenManager;
     _accessToken = accessToken;
 }
Esempio n. 57
0
 public LinkedInDataProvider(IConsumerTokenManager tokenManager, string accessToken)
 {
     _tokenManager = tokenManager;
     _accessToken  = accessToken;
 }
Esempio n. 58
0
 public MxClient(IConsumerTokenManager tokenManager)
     : base(NAME, MxServiceDescription, tokenManager)
 {
     this.TokenManager = tokenManager;
 }
 public static ActionResult GoogleAuthRequestProcessing(this IGoogleAuthRequestProcessing source, Uri callback, IConsumerTokenManager tokenManager)
 {
     return source.PrepareAuthRequest(callback, tokenManager);
 }
Esempio n. 60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebOAuthAuthorization"/> class.
 /// </summary>
 /// <param name="tokenManager">The token manager.</param>
 /// <param name="accessToken">The access token, or null if the user doesn't have one yet.</param>
 public WebOAuthAuthorization(IConsumerTokenManager tokenManager, string accessToken)
     : this(tokenManager, accessToken, ServiceDescriptions.LinkedInServiceDescription)
 {
 }