public void Reconnect() { AgsServerState oldState = _state; try { // connect/authenticate _Connect(); _state = AgsServerState.Authorized; } catch (AuthenticationException) { _state = AgsServerState.Unauthorized; throw _CreateAuthException(); } catch (Exception e) { _state = AgsServerState.Unavailable; throw _ConvertException(e); } finally { if (_state != oldState) { _NotifyStateChanged(); } } }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// public void Authorize(string userName, string password, bool saveCredentials) { _CheckState(); _ValidateInputCredentials(userName, password); NetworkCredential credentials = new NetworkCredential(userName, password); AgsServerState oldState = _state; try { _authenticator.Authenticate(credentials); _parameters.Credentials = credentials; _state = AgsServerState.Authorized; if (saveCredentials && _authenticator.IsAuthRequired && _parameters.AuthenticationType == AgsServerAuthenticationType.Yes) { _UpdateCredentials(credentials); } } catch (AuthenticationException) { throw _CreateAuthException(); } catch (Exception e) { throw _ConvertException(e); } finally { if (_state != oldState) { _NotifyStateChanged(); } } }
internal AgsServer(ServerInfoWrap config, NetworkCredential licenseAccount, IRoutingServiceUrlProvider serviceUrlProvider) { Debug.Assert(config != null); // set server parameters _name = config.Name; _title = config.Title; _description = config.Description; _helpPrompt = config.HelpPrompt; _config = config; // init connection _InitParameters(config, licenseAccount); _serviceUrlProvider = serviceUrlProvider; // create authenticator _authenticator = _CreateAuthenticator(_parameters, _serviceUrlProvider); try { // connect/authenticate _Connect(); _state = AgsServerState.Authorized; } catch (AuthenticationException) { _state = AgsServerState.Unauthorized; _initError = _CreateAuthException(); } catch (Exception e) { _state = AgsServerState.Unavailable; _initError = _ConvertException(e); Logger.Error(e); } }
public void Reconnect() { AgsServerState oldState = _state; try { // connect/authenticate _Connect(); _state = AgsServerState.Authorized; } catch (AuthenticationException) { _state = AgsServerState.Unauthorized; throw _CreateAuthException(); } catch (Exception e) { _state = AgsServerState.Unavailable; throw _ConvertException(e); } finally { if (_state != oldState) _NotifyStateChanged(); } }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// public void Authorize(string userName, string password, bool saveCredentials) { _CheckState(); _ValidateInputCredentials(userName, password); NetworkCredential credentials = new NetworkCredential(userName, password); AgsServerState oldState = _state; try { _authenticator.Authenticate(credentials); _parameters.Credentials = credentials; _state = AgsServerState.Authorized; if (saveCredentials && _authenticator.IsAuthRequired && _parameters.AuthenticationType == AgsServerAuthenticationType.Yes) { _UpdateCredentials(credentials); } } catch (AuthenticationException) { throw _CreateAuthException(); } catch (Exception e) { throw _ConvertException(e); } finally { if (_state != oldState) _NotifyStateChanged(); } }
/// <summary> /// Registers the specified header for the specified state. /// </summary> /// <param name="state">The state to register header for.</param> /// <param name="header">The header to be used for the specified state.</param> protected void RegisterHeader(AgsServerState state, string header) { _headers[state] = header; }