Rally.RestApi.Auth.ApiAuthManager.PerformAuthenticationCheckAgainstRally C# (CSharp) Method

PerformAuthenticationCheckAgainstRally() private method

Performs an authentication check against Rally with the specified credentials
private PerformAuthenticationCheckAgainstRally ( string &errorMessage, bool allowSso ) : RallyRestApi.AuthenticationResult
errorMessage string
allowSso bool
return RallyRestApi.AuthenticationResult
		private RallyRestApi.AuthenticationResult PerformAuthenticationCheckAgainstRally(out string errorMessage,
			bool allowSso)
		{
			if (!IsUiSupported)
				throw new InvalidProgramException("This method is only supported by UI enabled Authentication Managers.");

			RallyRestApi.AuthenticationResult authResult = RallyRestApi.AuthenticationResult.NotAuthorized;
			errorMessage = String.Empty;
			WebProxy proxy = GetProxy(out errorMessage);
			if (!String.IsNullOrWhiteSpace(errorMessage))
				return RallyRestApi.AuthenticationResult.NotAuthorized;

			if (String.IsNullOrWhiteSpace(LoginDetails.RallyServer))
				errorMessage = LoginFailureServerEmpty;
			else if (String.IsNullOrWhiteSpace(LoginDetails.Username))
				errorMessage = LoginFailureLoginEmpty;

			Uri serverUri = null;
			try
			{
				if (String.IsNullOrWhiteSpace(LoginDetails.RallyServer))
					errorMessage = "Bad URI format for CA Agile Central Server";
				else
					serverUri = new Uri(LoginDetails.RallyServer);
			}
			catch
			{
				errorMessage = "Bad URI format for CA Agile Central Server";
			}

			try
			{
				if (String.IsNullOrWhiteSpace(errorMessage))
				{
					authResult = Api.Authenticate(LoginDetails.Username, LoginDetails.GetPassword(),
						serverUri, proxy, allowSSO: allowSso);
				}
			}
			catch (RallyUnavailableException)
			{
				errorMessage = "CA Agile Central is currently unavailable.";
			}
			catch (WebException e)
			{
				if (e.Response is HttpWebResponse)
				{
					if ((((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.BadGateway) ||
						(((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.BadRequest))
					{
						errorMessage = LoginFailureBadServer;
					}
					else if (((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.ProxyAuthenticationRequired)
					{
						errorMessage = LoginFailureProxyCredentials;
					}
					else if (((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.Unauthorized)
					{
						errorMessage = LoginFailureCredentials;
					}
					else
						errorMessage = LoginFailureUnknown;
				}
				else if ((e is WebException) &&
					(((WebException)e).Status == WebExceptionStatus.ConnectFailure))
				{
					errorMessage = LoginFailureBadConnection;
				}
				else
					errorMessage = LoginFailureUnknown;
			}

			UpdateAuthenticationState(errorMessage);
			return Api.AuthenticationState;
		}
		#endregion