コード例 #1
0
        internal FederatedTokenProvider(Func <ILog> log, ITokenProvider tokenProvider, string rootUrl, string serverUrl, ISerializer serializer = null, string referer = null)
        {
            Guard.AgainstNullArgument("tokenProvider", tokenProvider);
            if (string.IsNullOrWhiteSpace(rootUrl))
            {
                throw new ArgumentNullException("rootUrl", "rootUrl is null.");
            }
            if (string.IsNullOrWhiteSpace(serverUrl))
            {
                throw new ArgumentNullException("serverUrl", "serverUrl is null.");
            }

            Serializer = serializer ?? SerializerFactory.Get();
            Guard.AgainstNullArgument("Serializer", Serializer);

            RootUrl      = rootUrl.AsRootUrl();
            _httpClient  = HttpClientFactory.Get();
            TokenRequest = new GenerateFederatedToken(serverUrl, tokenProvider)
            {
                Referer = referer
            };

            _logger = log() ?? LogProvider.For <FederatedTokenProvider>();
            _logger.DebugFormat("Created new token provider for {0}", RootUrl);
        }
コード例 #2
0
ファイル: TokenProvider.cs プロジェクト: alpascual/ArcGIS.PCL
        /// <summary>
        /// Create a token provider to authenticate against ArcGIS Server
        /// </summary>
        /// <param name="rootUrl">Made up of scheme://host:port/site</param>
        /// <param name="username">ArcGIS Server user name</param>
        /// <param name="password">ArcGIS Server user password</param>
        /// <param name="serializer">Used to (de)serialize requests and responses</param>
        /// <param name="referer">Referer url to use for the token generation</param>
        /// <param name="useEncryption">If true then the token generation request will be encryted</param>
        public TokenProvider(String rootUrl, String username, String password, ISerializer serializer = null, String referer = "", ICryptoProvider cryptoProvider = null)
        {
            if (String.IsNullOrWhiteSpace(username) || String.IsNullOrWhiteSpace(password))
            {
                System.Diagnostics.Debug.WriteLine("TokenProvider for '" + RootUrl + "' not initialized as username/password not supplied.");
                return;
            }

            Serializer = serializer ?? SerializerFactory.Get();
            if (Serializer == null)
            {
                throw new ArgumentNullException("serializer", "Serializer has not been set.");
            }
            RootUrl        = rootUrl.AsRootUrl();
            CryptoProvider = cryptoProvider ?? CryptoProviderFactory.Get();
            TokenRequest   = new GenerateToken(username, password)
            {
                Referer = referer
            };
            UserName = username;

            _httpClient = HttpClientFactory.Get();

            System.Diagnostics.Debug.WriteLine("Created TokenProvider for " + RootUrl);
        }
コード例 #3
0
        internal TokenProvider(Func <ILog> log, string rootUrl, string username, string password, ISerializer serializer = null, string referer = "", ICryptoProvider cryptoProvider = null)
        {
            if (string.IsNullOrWhiteSpace(rootUrl))
            {
                throw new ArgumentNullException(nameof(rootUrl), "rootUrl is null.");
            }
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentNullException(nameof(username), "username is null.");
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new ArgumentNullException(nameof(password), "password is null.");
            }

            Serializer = serializer ?? SerializerFactory.Get();
            Guard.AgainstNullArgument("Serializer", Serializer);
            RootUrl        = rootUrl.AsRootUrl();
            CryptoProvider = cryptoProvider ?? CryptoProviderFactory.Get();
            _httpClient    = HttpClientFactory.Get();
            TokenRequest   = new GenerateToken(username, password)
            {
                Referer = referer
            };
            UserName = username;

            _logger = log() ?? LogProvider.For <TokenProvider>();
            _logger.DebugFormat("Created new token provider for {0}", RootUrl);
        }
コード例 #4
0
        /// <summary>
        /// Create an ArcGIS Server gateway to access secure resources
        /// </summary>
        /// <param name="rootUrl">Made up of scheme://host:port/site</param>
        /// <param name="serializer">Used to (de)serialize requests and responses</param>
        /// <param name="tokenProvider">Provide access to a token for secure resources</param>
        public PortalGatewayBase(String rootUrl, ISerializer serializer = null, ITokenProvider tokenProvider = null)
        {
            RootUrl       = rootUrl.AsRootUrl();
            TokenProvider = tokenProvider;
            Serializer    = serializer ?? SerializerFactory.Get();
            if (Serializer == null)
            {
                throw new ArgumentNullException("serializer", "Serializer has not been set.");
            }

            _httpClient = HttpClientFactory.Get();
            System.Diagnostics.Debug.WriteLine("Created PortalGateway for " + RootUrl);
        }
コード例 #5
0
        internal PortalGatewayBase(Func <ILog> log, string rootUrl, ISerializer serializer = null, ITokenProvider tokenProvider = null, Func <HttpClient> httpClientFunc = null)
        {
            if (string.IsNullOrWhiteSpace(rootUrl))
            {
                throw new ArgumentNullException("rootUrl", "rootUrl is null.");
            }

            RootUrl       = rootUrl.AsRootUrl();
            TokenProvider = tokenProvider;
            Serializer    = serializer ?? SerializerFactory.Get();
            Guard.AgainstNullArgument("Serializer", Serializer);
            var httpFunc = httpClientFunc ?? HttpClientFactory.Get;

            _httpClient = httpFunc();

            _logger = log() ?? LogProvider.For <PortalGatewayBase>();
            _logger.DebugFormat("Created new gateway for {0}", RootUrl);
        }
コード例 #6
0
ファイル: TokenProvider.cs プロジェクト: alpascual/ArcGIS.PCL
        /// <summary>
        /// Create an OAuth token provider to authenticate against ArcGIS Online
        /// </summary>
        /// <param name="clientId">The Client Id from your API access section of your application from developers.arcgis.com</param>
        /// <param name="clientSecret">The Client Secret from your API access section of your application from developers.arcgis.com</param>
        /// <param name="serializer">Used to (de)serialize requests and responses</param>
        public ArcGISOnlineAppLoginOAuthProvider(String clientId, String clientSecret, ISerializer serializer = null)
        {
            if (String.IsNullOrWhiteSpace(clientId) || String.IsNullOrWhiteSpace(clientSecret))
            {
                System.Diagnostics.Debug.WriteLine("ArcGISOnlineAppLoginOAuthProvider not initialized as client Id/secret not supplied.");
                return;
            }

            Serializer = serializer ?? SerializerFactory.Get();
            if (Serializer == null)
            {
                throw new ArgumentNullException("serializer", "Serializer has not been set.");
            }
            OAuthRequest = new GenerateOAuthToken(clientId, clientSecret);

            _httpClient = HttpClientFactory.Get();

            System.Diagnostics.Debug.WriteLine("Created TokenProvider for " + RootUrl);
        }
コード例 #7
0
        internal ArcGISOnlineAppLoginOAuthProvider(Func <ILog> log, string clientId, string clientSecret, ISerializer serializer = null)
        {
            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentNullException("clientId", "clientId is null.");
            }
            if (string.IsNullOrWhiteSpace(clientSecret))
            {
                throw new ArgumentNullException("clientSecret", "clientSecret is null.");
            }

            Serializer = serializer ?? SerializerFactory.Get();
            Guard.AgainstNullArgument("Serializer", Serializer);

            OAuthRequest = new GenerateOAuthToken(clientId, clientSecret);
            _httpClient  = HttpClientFactory.Get();

            _logger = log() ?? LogProvider.For <ArcGISOnlineAppLoginOAuthProvider>();
            _logger.DebugFormat("Created new token provider for {0}", RootUrl);
        }