示例#1
0
        /// <summary>
        /// Creates authenticator instance.
        /// </summary>
        /// <param name="parameters">Connection parameters to be used.</param>
        /// <param name="serviceUrlProvider">Url provider instance to
        /// retrieve server url from.</param>
        /// <returns>new authenticator instance.</returns>
        private Authenticator _CreateAuthenticator(
            AgsServerConnectionParameters parameters,
            IRoutingServiceUrlProvider serviceUrlProvider)
        {
            var soapUrl = parameters.SoapUrl;

            if (serviceUrlProvider != null)
            {
                soapUrl = _serviceUrlProvider.QueryServiceUrl();
            }

            var authenticator = new Authenticator(soapUrl, _config.TokenType);

            return(authenticator);
        }
        /// <summary>
        /// Initializes a new instance of the AgsServerConnection class
        /// with the specified authenticator instance, connection parameters
        /// and ArcGIS server to connect to.
        /// </summary>
        /// <param name="authenticator">Authenticator instance to be used
        /// for accessing ArcGIS server.</param>
        /// <param name="parameters">Connection parameters instance.</param>
        /// <param name="server">ArcGIS server instance to connect to.</param>
        public AgsServerConnection(
            IAgsServerAuthenticator authenticator,
            AgsServerConnectionParameters parameters,
            AgsServer server)
        {
            Debug.Assert(authenticator != null);
            Debug.Assert(parameters != null);
            Debug.Assert(server != null);

            _authenticator = authenticator;
            _parameters = parameters;
            _server = server;

            this.RequiresHttpAuthentication = _server.RequiresHttpAuthentication;
        }
        /// <summary>
        /// Initializes a new instance of the AgsServerConnection class
        /// with the specified authenticator instance, connection parameters
        /// and ArcGIS server to connect to.
        /// </summary>
        /// <param name="authenticator">Authenticator instance to be used
        /// for accessing ArcGIS server.</param>
        /// <param name="parameters">Connection parameters instance.</param>
        /// <param name="server">ArcGIS server instance to connect to.</param>
        public AgsServerConnection(
            IAgsServerAuthenticator authenticator,
            AgsServerConnectionParameters parameters,
            AgsServer server)
        {
            Debug.Assert(authenticator != null);
            Debug.Assert(parameters != null);
            Debug.Assert(server != null);

            _authenticator = authenticator;
            _parameters    = parameters;
            _server        = server;

            this.RequiresHttpAuthentication = _server.RequiresHttpAuthentication;
        }
示例#4
0
        /// <summary>
        /// Opens connection to the ArcGIS server, performing authentication
        /// if necessary.
        /// </summary>
        /// <returns>New instance of the ArcGIS server connection.</returns>
        /// <exception cref="System.InvalidOperationException">Server is in
        /// unavailable state.</exception>
        /// <exception cref="ESRI.ArcLogistics.AuthenticationException">Failed
        /// to authenticate within ArcGIS server.</exception>
        /// <exception cref="ESRI.ArcLogistics.CommunicationException">Failed
        /// to establish connection to the server.</exception>
        public AgsServerConnection OpenConnection()
        {
            _CheckState();

            AgsServerConnection connection = null;

            try
            {
                var parameters = new AgsServerConnectionParameters(_config)
                {
                    SoapUrl            = _parameters.SoapUrl,
                    Credentials        = _parameters.Credentials,
                    AuthenticationType = _parameters.AuthenticationType
                };

                var authenticator = _authenticator;
                if (_serviceUrlProvider != null)
                {
                    // Get new soap URL.
                    string newSoapUrl = _serviceUrlProvider.QueryServiceUrl();

                    // Replace old url and connect to new one.
                    parameters.SoapUrl = newSoapUrl;
                    authenticator      = new Authenticator(newSoapUrl, _config.TokenType);

                    // Use older authenticator for initialization.
                    authenticator.Initialize(_authenticator);
                }

                connection = new AgsServerConnection(
                    authenticator,
                    parameters,
                    this);
            }
            catch (Exception e)
            {
                if (_IsCommError(e))
                {
                    throw _CreateCommException(e);
                }

                throw;
            }

            return(connection);
        }
示例#5
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        private void _InitParameters(
            ServerInfoWrap config,
            NetworkCredential licAccount)
        {
            var parameters            = new AgsServerConnectionParameters(config);
            var useLicenseCredentials =
                parameters.AuthenticationType ==
                AgsServerAuthenticationType.UseApplicationLicenseCredentials &&
                licAccount != null;

            if (useLicenseCredentials)
            {
                parameters.Credentials = new NetworkCredential(
                    licAccount.UserName,
                    licAccount.Password);
            }

            _parameters = parameters;
        }
示例#6
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        private void _InitParameters(
            ServerInfoWrap config,
            NetworkCredential licAccount)
        {
            var parameters = new AgsServerConnectionParameters(config);
            var useLicenseCredentials =
                parameters.AuthenticationType ==
                AgsServerAuthenticationType.UseApplicationLicenseCredentials &&
                licAccount != null;
            if (useLicenseCredentials)
            {
                parameters.Credentials = new NetworkCredential(
                    licAccount.UserName,
                    licAccount.Password);
            }

            _parameters = parameters;
        }
示例#7
0
        /// <summary>
        /// Creates authenticator instance.
        /// </summary>
        /// <param name="parameters">Connection parameters to be used.</param>
        /// <param name="serviceUrlProvider">Url provider instance to
        /// retrieve server url from.</param>
        /// <returns>new authenticator instance.</returns>
        private Authenticator _CreateAuthenticator(
            AgsServerConnectionParameters parameters,
            IRoutingServiceUrlProvider serviceUrlProvider)
        {
            var soapUrl = parameters.SoapUrl;
            if (serviceUrlProvider != null)
            {
                soapUrl = _serviceUrlProvider.QueryServiceUrl();
            }

            var authenticator = new Authenticator(soapUrl, _config.TokenType);

            return authenticator;
        }
示例#8
0
        /// <summary>
        /// Opens connection to the ArcGIS server, performing authentication
        /// if necessary.
        /// </summary>
        /// <returns>New instance of the ArcGIS server connection.</returns>
        /// <exception cref="System.InvalidOperationException">Server is in
        /// unavailable state.</exception>
        /// <exception cref="ESRI.ArcLogistics.AuthenticationException">Failed
        /// to authenticate within ArcGIS server.</exception>
        /// <exception cref="ESRI.ArcLogistics.CommunicationException">Failed
        /// to establish connection to the server.</exception>
        public AgsServerConnection OpenConnection()
        {
            _CheckState();

            AgsServerConnection connection = null;
            try
            {
                var parameters = new AgsServerConnectionParameters(_config)
                {
                    SoapUrl = _parameters.SoapUrl,
                    Credentials = _parameters.Credentials,
                    AuthenticationType = _parameters.AuthenticationType
                };

                var authenticator = _authenticator;
                if (_serviceUrlProvider != null)
                {
                    // Get new soap URL.
                    string newSoapUrl = _serviceUrlProvider.QueryServiceUrl();

                    // Replace old url and connect to new one.
                    parameters.SoapUrl = newSoapUrl;
                    authenticator = new Authenticator(newSoapUrl, _config.TokenType);

                    // Use older authenticator for initialization.
                    authenticator.Initialize(_authenticator);
                }

                connection = new AgsServerConnection(
                    authenticator,
                    parameters,
                    this);
            }
            catch (Exception e)
            {
                if (_IsCommError(e))
                {
                    throw _CreateCommException(e);
                }

                throw;
            }

            return connection;
        }