/// <summary>
 /// Authenticates the user against Rally. This must be called from the UI thread.
 /// </summary>
 /// <param name="authenticationStateChange">The delegate to call when an authentication state change occurs.</param>
 /// <param name="ssoAuthenticationComplete">The delegate to call when an authentication state change occurs due to SSO.</param>
 /// <example>
 /// Opening the login window and passing the two delegates to it.
 /// <code language="C#">
 /// authMgr.ShowUserLoginWindow(authenticationStateChange, ssoAuthenticationComplete);
 /// </code>
 /// </example>
 public virtual void ShowUserLoginWindow(AuthenticationStateChange authenticationStateChange,
                                         SsoAuthenticationComplete ssoAuthenticationComplete)
 {
     AuthenticationStateChange = authenticationStateChange;
     SsoAuthenticationComplete = ssoAuthenticationComplete;
     ShowUserLoginWindowInternal();
 }
        private void UpdateAuthenticationState()
        {
            if (AuthenticationStateChange != null)
            {
                switch (Api.AuthenticationState)
                {
                case RallyRestApi.AuthenticationResult.Authenticated:
                    AuthenticationStateChange.Invoke(Api.AuthenticationState, Api);
                    break;

                case RallyRestApi.AuthenticationResult.PendingSSO:
                case RallyRestApi.AuthenticationResult.NotAuthorized:
                    AuthenticationStateChange.Invoke(Api.AuthenticationState, null);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            if (Api.AuthenticationState == RallyRestApi.AuthenticationResult.Authenticated)
            {
                LoginDetails.SaveToDisk();
            }
        }
 /// <summary>
 /// Performs an logout from Rally.
 /// </summary>
 /// <example>
 /// <code language="C#">
 /// authMgr.PerformLogoutFromRally();
 /// </code>
 /// </example>
 protected void PerformLogoutFromRally()
 {
     Api.Logout();
     LoginDetails.MarkUserAsLoggedOut();
     AuthenticationStateChange.Invoke(Api.AuthenticationState, null);
 }
		/// <summary>
		/// Authenticates the user against Rally. This must be called from the UI thread.
		/// </summary>
		/// <param name="authenticationStateChange">The delegate to call when an authentication state change occurs.</param>
		/// <param name="ssoAuthenticationComplete">The delegate to call when an authentication state change occurs due to SSO.</param>
		/// <example>
		/// Opening the login window and passing the two delegates to it.
		/// <code language="C#">
		/// authMgr.ShowUserLoginWindow(authenticationStateChange, ssoAuthenticationComplete);
		/// </code>
		/// </example>
		public virtual void ShowUserLoginWindow(AuthenticationStateChange authenticationStateChange,
			SsoAuthenticationComplete ssoAuthenticationComplete)
		{
			AuthenticationStateChange = authenticationStateChange;
			SsoAuthenticationComplete = ssoAuthenticationComplete;
			ShowUserLoginWindowInternal();
		}