/// <summary> /// Called when the login reply is received. /// </summary> private void HandleConnectKwsReply(KcdQuery query) { KLogging.Log("Got login reply, kws " + m_kws.InternalID + ", status " + m_kws.Cd.MainStatus); Debug.Assert(m_ks.LoginStatus == KwsLoginStatus.LoggingIn); // This is the standard login reply. if (query.Res.Type == KAnp.KANP_RES_KWS_CONNECT_KWS) { // Get the provided information. KwsConnectRes r = new KwsConnectRes(query.Res); KLogging.Log(m_currentStep + " login step: " + r.ErrMsg); // Dispatch. if (r.Code == KAnp.KANP_KWS_LOGIN_OK) { HandleConnectKwsSuccess(r); } else if (r.Code == KAnp.KANP_KWS_LOGIN_BAD_PWD_OR_TICKET) { HandleBadPwdOrTicket(r); } else { HandleLoginFailure(TranslateKcdLoginStatusCode(r.Code), new Exception(r.ErrMsg)); } } // This is an unexpected reply. else { HandleLoginFailure(KwsLoginResult.MiscKcdError, EAnpException.FromKAnpReply(query.Res)); } }
/// <summary> /// Called when the login fails with KANP_KWS_LOGIN_BAD_PWD_OR_TICKET. /// </summary> private void HandleBadPwdOrTicket(KwsConnectRes r) { // Remember that the workspace is secure and if a password is available. m_kws.Cd.Credentials.SecureFlag = r.SecureFlag; m_ks.PwdPresentFlag = r.PwdOnKcdFlag; m_kws.OnStateChange(WmStateChange.Permanent); // The cached step has failed. if (m_currentStep == KwsLoginStep.Cached) { // Only the cached step was allowed. We're done. if (m_loginType == KwsLoginType.Cached) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, new Exception("security credentials refused")); return; } // We can perform the ticket step. if (KwmCfg.Cur.CanLoginOnKps()) { HandleTicketLoginStep(); return; } } // The ticket step has failed. else if (m_currentStep == KwsLoginStep.Ticket) { // Log the ticket refusal string. KLogging.Log("Ticket refused: " + r.ErrMsg); } // There is no password on the KCD. if (!m_ks.PwdPresentFlag) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, new Exception("a password must be assigned to you")); return; } // The password provided is bad. if (m_currentStep == KwsLoginStep.Pwd) { // Execute that asynchronously since we want our state to be // predictable. if (OnSetLoginPwdRefused != null) { KBase.ExecInUI(OnSetLoginPwdRefused); } } // We need a password. HandlePwdLoginStep(); }
/// <summary> /// Called on successful login. /// </summary> private void HandleConnectKwsSuccess(KwsConnectRes r) { // Update our credentials and login information if needed. if (m_ks.LoginResult != KwsLoginResult.Accepted || m_kws.Cd.Credentials.UserID != r.UserID || m_kws.Cd.Credentials.EmailID != r.EmailID || m_kws.Cd.Credentials.SecureFlag != r.SecureFlag || m_kws.Cd.Credentials.KwmoAddress != r.KwmoAddress) { m_ks.LoginResult = KwsLoginResult.Accepted; m_ks.LoginResultString = "login successful"; m_kws.Cd.Credentials.UserID = r.UserID; m_kws.Cd.Credentials.EmailID = r.EmailID; m_kws.Cd.Credentials.SecureFlag = r.SecureFlag; m_kws.Cd.Credentials.KwmoAddress = r.KwmoAddress; m_kws.OnStateChange(WmStateChange.Permanent); } // Remember the latest event ID available on the KCD. m_ks.LoginLatestEventId = r.LoginLatestEventID; // Tell the state machine. m_kws.Sm.HandleLoginSuccess(); }
/// <summary> /// Called on successful login. /// </summary> private void HandleConnectKwsSuccess(KwsConnectRes r) { // Update our credentials and login information if needed. if (LoginResult != KwsLoginResult.Accepted || m_kws.CoreData.Credentials.UserID != r.UserID || m_kws.CoreData.Credentials.EmailID != r.EmailID || m_kws.CoreData.Credentials.SecureFlag != r.SecureFlag || m_kws.CoreData.Credentials.KwmoAddress != r.KwmoAddress) { LoginResult = KwsLoginResult.Accepted; LoginResultString = "login successful"; m_kws.CoreData.Credentials.UserID = r.UserID; m_kws.CoreData.Credentials.EmailID = r.EmailID; m_kws.CoreData.Credentials.SecureFlag = r.SecureFlag; m_kws.CoreData.Credentials.KwmoAddress = r.KwmoAddress; m_kws.SetDirty(); } // Remember the latest event ID available on the KAS. m_kws.KAnpState.LoginLatestEventId = r.LoginLatestEventID; // Tell the state machine. m_kws.Sm.HandleLoginSuccess(); }
/// <summary> /// Called when the login reply is received. /// </summary> private void HandleConnectKwsReply(KasQuery query) { Logging.Log("Got login reply, kws " + m_kws.InternalID + ", status " + m_kws.MainStatus); Debug.Assert(m_kws.LoginStatus == KwsLoginStatus.LoggingIn); // This is the standard login reply. if (query.Res.Type == KAnpType.KANP_RES_KWS_CONNECT_KWS) { // Get the provided information. KwsConnectRes r = new KwsConnectRes(query.Res); Logging.Log(m_currentStep + " login step: " + r.ErrMsg); // Dispatch. if (r.Code == KAnpType.KANP_KWS_LOGIN_OK) HandleConnectKwsSuccess(r); else if (r.Code == KAnpType.KANP_KWS_LOGIN_BAD_PWD_OR_TICKET) HandleBadPwdOrTicket(r); else HandleLoginFailure(TranslateKcdLoginStatusCode(r.Code), r.ErrMsg); } // This is an unexpected reply. else { HandleLoginFailure(KwsLoginResult.MiscKcdError, Misc.HandleUnexpectedKAnpReply("login", query.Res).Message); } }
/// <summary> /// Called when the login fails with KANP_KWS_LOGIN_BAD_PWD_OR_TICKET. /// </summary> private void HandleBadPwdOrTicket(KwsConnectRes r) { // Remember that the workspace is secure and if a password is available. m_kws.CoreData.Credentials.SecureFlag = r.SecureFlag; PwdOnKcdFlag = r.PwdOnKcdFlag; m_kws.SetDirty(); // The cached step has failed. if (m_currentStep == KwsLoginStep.Cached) { // Clear the ticket refusal string. TicketRefusalString = ""; m_kws.SetDirty(); // Only the cached step was allowed. We're done. if (m_loginType == KwsLoginType.Cached) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, "security credentials refused"); return; } // We can perform the ticket step. WmWinRegistry registry = WmWinRegistry.Spawn(); if (registry.CanLoginOnKps()) { HandleTicketLoginStep(registry); return; } } // The ticket step has failed. else if (m_currentStep == KwsLoginStep.Ticket) { // Set the ticket refusal string. TicketRefusalString = r.ErrMsg; m_kws.SetDirty(); } // There is no password on the KCD. if (!PwdOnKcdFlag) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, "a password must be assigned to you"); return; } // We're not allowed to prompt. if (m_loginType == KwsLoginType.NoPwdPrompt) { HandleLoginFailure(KwsLoginResult.PwdRequired, "password required"); return; } // Prompt for the password. HandlePwdLoginStep(m_currentStep == KwsLoginStep.Pwd); }
/// <summary> /// Called when the login fails with KANP_KWS_LOGIN_BAD_PWD_OR_TICKET. /// </summary> private void HandleBadPwdOrTicket(KwsConnectRes r) { // Remember that the workspace is secure and if a password is available. m_kws.Cd.Credentials.SecureFlag = r.SecureFlag; m_ks.PwdPresentFlag = r.PwdOnKcdFlag; m_kws.OnStateChange(WmStateChange.Permanent); // The cached step has failed. if (m_currentStep == KwsLoginStep.Cached) { // Only the cached step was allowed. We're done. if (m_loginType == KwsLoginType.Cached) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, new Exception("security credentials refused")); return; } // We can perform the ticket step. if (KwmCfg.Cur.CanLoginOnKps()) { HandleTicketLoginStep(); return; } } // The ticket step has failed. else if (m_currentStep == KwsLoginStep.Ticket) { // Log the ticket refusal string. KLogging.Log("Ticket refused: " + r.ErrMsg); } // There is no password on the KCD. if (!m_ks.PwdPresentFlag) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, new Exception("a password must be assigned to you")); return; } // The password provided is bad. if (m_currentStep == KwsLoginStep.Pwd) { // Execute that asynchronously since we want our state to be // predictable. if (OnSetLoginPwdRefused != null) KBase.ExecInUI(OnSetLoginPwdRefused); } // We need a password. HandlePwdLoginStep(); }