コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TwitterDataProvider"/> class.
        /// Constructor.
        /// </summary>
        /// <param name="tokens">OAuth tokens for request.</param>
        /// <param name="authenticationBroker">Authentication result interface.</param>
        /// <param name="passwordManager">Platform password manager</param>
        /// <param name="storageManager">Platform storage provider</param>
        /// <param name="signatureManager">Platform signature manager</param>
        public TwitterDataProvider(TwitterOAuthTokens tokens, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager, ISignatureManager signatureManager)
        {
            if (string.IsNullOrEmpty(tokens.ConsumerSecret))
            {
                throw new ArgumentException("Missing consumer secret");
            }

            if (string.IsNullOrEmpty(tokens.ConsumerKey))
            {
                throw new ArgumentException("Missing consumer key");
            }

            if (string.IsNullOrEmpty(tokens.CallbackUri))
            {
                throw new ArgumentException("Missing callback uri");
            }

            _tokens = tokens;
            _authenticationBroker = authenticationBroker ?? throw new ArgumentException("Missing AuthenticationBroker");
            _passwordManager      = passwordManager ?? throw new ArgumentException("Missing PasswordManager");
            _storageManager       = storageManager ?? throw new ArgumentException("Missing StorageManager");
            _signatureManager     = signatureManager ?? throw new ArgumentException("Missing SignatureManager");

            if (_client == null)
            {
                HttpClientHandler handler = new HttpClientHandler();
                handler.AutomaticDecompression = DecompressionMethods.GZip;
                _client = new HttpClient(handler);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WeiboDataProvider"/> class.
        /// Constructor.
        /// </summary>
        /// <param name="tokens">OAuth tokens for request.</param>
        /// <param name="authenticationBroker">Authentication result interface.</param>
        /// <param name="passwordManager">Platform password manager</param>
        /// <param name="storageManager">Platform storage provider</param>
        public WeiboDataProvider(WeiboOAuthTokens tokens, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager)
        {
            if (string.IsNullOrEmpty(tokens.AppSecret))
            {
                throw new ArgumentException("Missing app secret");
            }

            if (string.IsNullOrEmpty(tokens.AppKey))
            {
                throw new ArgumentException("Missing app key");
            }

            if (string.IsNullOrEmpty(tokens.RedirectUri))
            {
                throw new ArgumentException("Missing redirect uri");
            }

            _tokens = tokens;
            _authenticationBroker = authenticationBroker ?? throw new ArgumentException("Invalid AuthenticationBroker");
            _passwordManager      = passwordManager ?? throw new ArgumentException("Invalid PasswordManager");
            _storageManager       = storageManager ?? throw new ArgumentException("Invalid StorageManager");
            if (_client == null)
            {
                HttpClientHandler handler = new HttpClientHandler {
                    AutomaticDecompression = DecompressionMethods.GZip
                };
                _client = new HttpClient(handler);
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LinkedInDataProvider"/> class.
        /// Constructor.
        /// </summary>
        /// <param name="tokens">OAuth tokens for request.</param>
        /// <param name="requiredPermissions">Required permissions for the session.</param>
        /// <param name="authentication">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface.</param>
        public LinkedInDataProvider(LinkedInOAuthTokens tokens, LinkedInPermissions requiredPermissions, IAuthenticationBroker authentication, IPasswordManager passwordManager, IStorageManager storageManager)
        {
            if (string.IsNullOrEmpty(tokens.ClientSecret))
            {
                throw new ArgumentException("Missing client secret key");
            }

            if (string.IsNullOrEmpty(tokens.ClientId))
            {
                throw new ArgumentException("Missing client ID");
            }

            if (string.IsNullOrEmpty(tokens.CallbackUri))
            {
                throw new ArgumentException("Missing callback uri");
            }

            // Check if its a valid combination of LinkedInPermissions
            if ((~(int)LinkedInPermissionsHelpers.AllPermissions & (int)requiredPermissions) != 0)
            {
                throw new ArgumentException("Error retrieving required permissions");
            }

            Tokens = tokens;
            RequiredPermissions = requiredPermissions;
            _authentication     = authentication ?? throw new ArgumentException("Invalid AuthenticationBroker");
            _storageManager     = storageManager ?? throw new ArgumentException("Invalid StorageManager");
            _passwordManager    = passwordManager ?? throw new ArgumentException("Invalid PasswordManager");
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LinkedInDataProvider"/> class.
        /// Constructor.
        /// </summary>
        /// <param name="tokens">OAuth tokens for request.</param>
        /// <param name="requiredPermissions">Required permissions for the session.</param>
        /// <param name="authentication">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface.</param>
        public LinkedInDataProvider(LinkedInOAuthTokens tokens, LinkedInPermissions requiredPermissions, IAuthenticationBroker authentication, IPasswordManager passwordManager, IStorageManager storageManager)
        {
            if (string.IsNullOrEmpty(tokens.ClientSecret))
            {
                throw new ArgumentException("Missing client secret key");
            }

            if (string.IsNullOrEmpty(tokens.ClientId))
            {
                throw new ArgumentException("Missing client ID");
            }

            if (string.IsNullOrEmpty(tokens.CallbackUri))
            {
                throw new ArgumentException("Missing callback uri");
            }

            if (!Enum.IsDefined(typeof(LinkedInPermissions), requiredPermissions))
            {
                throw new ArgumentException("Error retrieving required permissions");
            }

            Tokens = tokens;
            RequiredPermissions = requiredPermissions;
            _authentication     = authentication ?? throw new ArgumentException("Invalid AuthenticationBroker");
            _storageManager     = storageManager ?? throw new ArgumentException("Invalid StorageManager");
            _passwordManager    = passwordManager ?? throw new ArgumentException("Invalid PasswordManager");
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkedInDataProvider"/> class.
 /// Constructor.
 /// </summary>
 /// <param name="tokens">OAuth tokens for request.</param>
 /// <param name="requiredPermissions">Required permissions for the session.</param>
 public LinkedInDataProvider(LinkedInOAuthTokens tokens, LinkedInPermissions requiredPermissions)
 {
     Tokens = tokens;
     RequiredPermissions = requiredPermissions;
     _authentication     = new UwpAuthenticationBroker();
     _storageManager     = new UwpStorageManager();
     _passwordManager    = new UwpPasswordManager();
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkedInDataProvider"/> class.
 /// Constructor.
 /// </summary>
 /// <param name="tokens">OAuth tokens for request.</param>
 /// <param name="requiredPermissions">Required permissions for the session.</param>
 /// <param name="authentication">Authentication result interface.</param>
 /// <param name="passwordManager">Password Manager interface, store the password.</param>
 /// <param name="storageManager">Storage Manager interface.</param>
 public LinkedInDataProvider(LinkedInOAuthTokens tokens, LinkedInPermissions requiredPermissions, IAuthenticationBroker authentication, IPasswordManager passwordManager, IStorageManager storageManager)
 {
     Tokens = tokens;
     RequiredPermissions = requiredPermissions;
     _authentication     = authentication;
     _storageManager     = storageManager;
     _passwordManager    = passwordManager;
 }
コード例 #7
0
        /// <summary>
        /// Initialize underlying provider with relevant token information.
        /// </summary>
        /// <param name="oAuthTokens">Token instance.</param>
        /// <param name="authenticationBroker">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(WeiboOAuthTokens oAuthTokens, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager)
        {
            _tokens = oAuthTokens ?? throw new ArgumentNullException(nameof(oAuthTokens));
            this._authenticationBroker = authenticationBroker ?? throw new ArgumentNullException(nameof(authenticationBroker));
            this._passwordManager      = passwordManager ?? throw new ArgumentNullException(nameof(passwordManager));
            this._storageManager       = storageManager ?? throw new ArgumentNullException(nameof(storageManager));

            _isInitialized = true;

            _weiboDataProvider = null;

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Initialize underlying provider with relevant token information.
        /// </summary>
        /// <param name="oAuthTokens">Token instance.</param>
        /// <param name="authenticationBroker">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface</param>
        /// <param name="signatureManager">Signature manager to sign the OAuth request</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(TwitterOAuthTokens oAuthTokens, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager, ISignatureManager signatureManager)
        {
            tokens = oAuthTokens ?? throw new ArgumentNullException(nameof(oAuthTokens));
            this.authenticationBroker = authenticationBroker ?? throw new ArgumentNullException(nameof(authenticationBroker));
            this.passwordManager      = passwordManager ?? throw new ArgumentNullException(nameof(passwordManager));
            this.storageManager       = storageManager ?? throw new ArgumentNullException(nameof(storageManager));
            this.signatureManager     = signatureManager ?? throw new ArgumentNullException(nameof(signatureManager));

            isInitialized = true;

            twitterDataProvider = null;

            return(true);
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TwitterDataProvider"/> class.
 /// Constructor.
 /// </summary>
 /// <param name="tokens">OAuth tokens for request.</param>
 public TwitterDataProvider(TwitterOAuthTokens tokens)
 {
     _tokens = tokens;
     _authenticationBroker = new UwpAuthenticationBroker();
     _passwordManager      = new UwpPasswordManager();
     _storageManager       = new UwpStorageManager();
     _signatureManager     = new UwpSignatureManager();
     if (_client == null)
     {
         HttpClientHandler handler = new HttpClientHandler();
         handler.AutomaticDecompression = DecompressionMethods.GZip;
         _client = new HttpClient(handler);
     }
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeiboDataProvider"/> class.
 /// Constructor.
 /// </summary>
 /// <param name="tokens">OAuth tokens for request.</param>
 /// <param name="authenticationBroker">Authentication result interface.</param>
 /// <param name="passwordManager">Platform password manager</param>
 /// <param name="storageManager">Platform storage provider</param>
 public WeiboDataProvider(WeiboOAuthTokens tokens, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager)
 {
     _tokens = tokens;
     _authenticationBroker = authenticationBroker;
     _passwordManager      = passwordManager;
     _storageManager       = storageManager;
     if (_client == null)
     {
         HttpClientHandler handler = new HttpClientHandler {
             AutomaticDecompression = DecompressionMethods.GZip
         };
         _client = new HttpClient(handler);
     }
 }
コード例 #11
0
        /// <summary>
        /// Initialize underlying provider with relevent token information.
        /// </summary>
        /// <param name="oAuthTokens">Token instance.</param>
        /// <param name="authentication">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface.</param>
        /// <param name="requiredPermissions">Scope / permissions app requires user to sign up for.</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(LinkedInOAuthTokens oAuthTokens, IAuthenticationBroker authentication, IPasswordManager passwordManager, IStorageManager storageManager, LinkedInPermissions requiredPermissions = LinkedInPermissions.NotSet)
        {
            _oAuthTokens          = oAuthTokens ?? throw new ArgumentNullException(nameof(oAuthTokens));
            _authenticationBroker = authentication ?? throw new ArgumentNullException(nameof(authentication));
            _storageManager       = storageManager ?? throw new ArgumentNullException(nameof(storageManager));
            _passwordManager      = passwordManager ?? throw new ArgumentNullException(nameof(passwordManager));

            _requiredPermissions = requiredPermissions;

            Provider.RequiredPermissions = requiredPermissions;
            Provider.Tokens = oAuthTokens;

            _isInitialized = true;

            return(true);
        }
コード例 #12
0
        /// <summary>
        /// Initialize underlying provider with relevant token information.
        /// </summary>
        /// <param name="appKey">App key.</param>
        /// <param name="appSecret">App secret.</param>
        /// <param name="redirectUri">Redirect URI. Has to match redirect URI defined at open.weibo.com/apps (can be arbitrary).</param>
        /// <param name="authenticationBroker">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(string appKey, string appSecret, string redirectUri, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager)
        {
            if (string.IsNullOrEmpty(appKey))
            {
                throw new ArgumentNullException(nameof(appKey));
            }

            if (string.IsNullOrEmpty(appSecret))
            {
                throw new ArgumentNullException(nameof(appSecret));
            }

            if (string.IsNullOrEmpty(redirectUri))
            {
                throw new ArgumentNullException(nameof(redirectUri));
            }

            if (authenticationBroker == null)
            {
                throw new ArgumentException(nameof(authenticationBroker));
            }

            if (passwordManager == null)
            {
                throw new ArgumentException(nameof(passwordManager));
            }

            if (storageManager == null)
            {
                throw new ArgumentException(nameof(storageManager));
            }

            var oAuthTokens = new WeiboOAuthTokens
            {
                AppKey      = appKey,
                AppSecret   = appSecret,
                RedirectUri = redirectUri
            };

            return(Initialize(oAuthTokens, authenticationBroker, passwordManager, storageManager));
        }
 public AuthorizationCodeAuthorizationInteractionClient(IAuthenticationBroker authenticationBroker) : base(authenticationBroker)
 {
 }
コード例 #14
0
        /// <summary>
        /// Initialize underlying provider with relevant token information.
        /// </summary>
        /// <param name="consumerKey">Consumer key.</param>
        /// <param name="consumerSecret">Consumer secret.</param>
        /// <param name="callbackUri">Callback URI. Has to match callback URI defined at apps.twitter.com (can be arbitrary).</param>
        /// <param name="authenticationBroker">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface</param>
        /// <param name="signatureManager">Signature manager to sign the OAuth request</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(string consumerKey, string consumerSecret, string callbackUri, IAuthenticationBroker authenticationBroker, IPasswordManager passwordManager, IStorageManager storageManager, ISignatureManager signatureManager)
        {
            if (string.IsNullOrEmpty(consumerKey))
            {
                throw new ArgumentNullException(nameof(consumerKey));
            }

            if (string.IsNullOrEmpty(consumerSecret))
            {
                throw new ArgumentNullException(nameof(consumerSecret));
            }

            if (string.IsNullOrEmpty(callbackUri))
            {
                throw new ArgumentNullException(nameof(callbackUri));
            }

            if (authenticationBroker == null)
            {
                throw new ArgumentException(nameof(authenticationBroker));
            }

            if (passwordManager == null)
            {
                throw new ArgumentException(nameof(passwordManager));
            }

            if (storageManager == null)
            {
                throw new ArgumentException(nameof(storageManager));
            }

            if (signatureManager == null)
            {
                throw new ArgumentException(nameof(signatureManager));
            }

            var oAuthTokens = new TwitterOAuthTokens
            {
                ConsumerKey    = consumerKey,
                ConsumerSecret = consumerSecret,
                CallbackUri    = callbackUri
            };

            return(Initialize(oAuthTokens, authenticationBroker, passwordManager, storageManager, signatureManager));
        }
コード例 #15
0
        /// <summary>
        /// Initialize underlying provider with relevent token information.
        /// </summary>
        /// <param name="clientId">Client Id.</param>
        /// <param name="clientSecret">Client secret.</param>
        /// <param name="callbackUri">Callback URI. Has to match callback URI defined at www.linkedin.com/developer/apps/ (can be arbitrary).</param>
        /// <param name="authentication">Authentication result interface.</param>
        /// <param name="passwordManager">Password Manager interface, store the password.</param>
        /// <param name="storageManager">Storage Manager interface.</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(string clientId, string clientSecret, string callbackUri, IAuthenticationBroker authentication, IPasswordManager passwordManager, IStorageManager storageManager)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }

            if (string.IsNullOrEmpty(clientSecret))
            {
                throw new ArgumentNullException(nameof(clientSecret));
            }

            if (string.IsNullOrEmpty(callbackUri))
            {
                throw new ArgumentNullException(nameof(callbackUri));
            }

            var oAuthTokens = new LinkedInOAuthTokens
            {
                ClientId     = clientId,
                ClientSecret = clientSecret,
                CallbackUri  = callbackUri
            };

            return(Initialize(oAuthTokens, authentication, passwordManager, storageManager, LinkedInPermissions.ReadBasicProfile));
        }
コード例 #16
0
 public AuthorizationInteractionServiceBase(IAuthenticationBroker authenticationBroker)
 {
     this.authenticationBroker = authenticationBroker;
 }