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> /// Reports the results of an SSO action. /// </summary> /// <param name="success">Was SSO authentication completed successfully?</param> /// <param name="rallyServer">The server that the ZSessionID is for.</param> /// <param name="zSessionID">The zSessionID that was returned from Rally.</param> protected void ReportSsoResults(bool success, string rallyServer, string zSessionID) { if (SsoAuthenticationComplete != null) { if (success) { RallyRestApi.AuthenticationResult authResult = Api.AuthenticateWithZSessionID(Api.ConnectionInfo.UserName, zSessionID, rallyServer: rallyServer); if (authResult == RallyRestApi.AuthenticationResult.Authenticated) { LoginDetails.SaveToDisk(); NotifyLoginWindowSsoComplete(authResult, Api); SsoAuthenticationComplete.Invoke(authResult, Api); return; } } LoginDetails.MarkUserAsLoggedOut(); Api.Logout(); NotifyLoginWindowSsoComplete(RallyRestApi.AuthenticationResult.NotAuthorized, null); SsoAuthenticationComplete.Invoke(RallyRestApi.AuthenticationResult.NotAuthorized, null); } }