Exemple #1
0
        /// <summary>
        /// Called when the KMOD ticket query results are available.
        /// </summary>
        private void OnKmodTicketResult(WmLoginTicketQuery query)
        {
            if (m_kmodQuery != query)
            {
                return;
            }
            m_kmodQuery = null;

            // Generic failure.
            if (query.Res != WmLoginTicketQueryRes.OK)
            {
                m_kmodResCode = EAnpRegisterKpsCode.Failure;
                m_kmodEx      = new Exception(query.OutDesc);
            }

            // No KCD failure.
            else if (query.Ticket.KcdAddr == "")
            {
                m_kmodResCode = EAnpRegisterKpsCode.NoKcd;
            }

            // Query completed.
            OnQueryCompletion();
        }
Exemple #2
0
 /// <summary>
 /// Obtain a login ticket and login with it.
 /// </summary>
 private void HandleTicketLoginStep()
 {
     m_currentStep = KwsLoginStep.Ticket;
     m_ticketQuery = new WmLoginTicketQuery();
     m_ticketQuery.Submit(Wm.KmodBroker, KwmCfg.Cur, HandleTicketLoginResult);
 }
Exemple #3
0
        /// <summary>
        /// Called when the login query results are available.
        /// </summary>
        private void OnLoginResult(KmodQuery query)
        {
            Logging.Log("OnLoginResult() called.");
            ClearKmodQuery();
            K3p.kmo_server_info_ack ack = query.OutMsg as K3p.kmo_server_info_ack;

            if (ack != null)
            {
                creds.Token = ack.Token;
                WmLoginTicketQuery ticketQuery = new WmLoginTicketQuery();
                SaveCredentials();
                m_query = ticketQuery;
                ticketQuery.Submit(m_broker, WmWinRegistry.Spawn(), OnTicketResult);
            }

            else
            {
                K3p.kmo_server_info_nack nack = query.OutMsg as K3p.kmo_server_info_nack;

                if (nack != null)
                {
                    if (nack.Error.StartsWith("cannot resolve ")) creds.SetServerError(nack.Error);
                    else creds.SetCredError(nack.Error);
                }

                else
                {
                    creds.SetServerError(query.OutDesc);
                }

                this.Enabled = true;
            }
        }
Exemple #4
0
        /// <summary>
        /// Called when the ticket query results are available.
        /// </summary>
        private void OnTicketResult(WmLoginTicketQuery query)
        {
            ClearKmodQuery();

            query.UpdateRegistry(WmWinRegistry.Spawn());
            if (query.Res != WmLoginTicketQueryRes.OK) creds.SetServerError(query.OutDesc);
            else LoginSuccess = true;

            this.Enabled = true;

            // Pass to the next page.
            if (LoginSuccess)
            {
                ((ConfigKPPWizard)GetWizard()).ShowSuccessPage();
                return;
            }
        }
        /// <summary>
        /// Handle the results of the ticket query.
        /// </summary>
        private void HandleTicketLoginResult(WmLoginTicketQuery query)
        {
            // Clear the query.
            Debug.Assert(m_ticketQuery == query);
            m_ticketQuery = null;

            // Update the registry, if required.
            query.UpdateRegistry(WmWinRegistry.Spawn());

            // The query failed.
            if (query.Res == WmLoginTicketQueryRes.InvalidCfg ||
                query.Res == WmLoginTicketQueryRes.MiscError)
            {
                HandleLoginFailure(KwsLoginResult.CannotGetTicket, "cannot obtain ticket: " + query.OutDesc);
            }

            // The query succeeded.
            else
            {
                // Update the credentials.
                m_kws.CoreData.Credentials.Ticket = query.Ticket.BinaryTicket;
                m_kws.SetDirty();

                // Send the login command.
                SendLoginCommand();
            }
        }
 /// <summary>
 /// Obtain a login ticket and login with it.
 /// </summary>
 private void HandleTicketLoginStep(WmWinRegistry registry)
 {
     m_currentStep = KwsLoginStep.Ticket;
     m_ticketQuery = new WmLoginTicketQuery();
     m_ticketQuery.Submit(m_wm.KmodBroker, registry, HandleTicketLoginResult);
 }
Exemple #7
0
 /// <summary>
 /// Obtain a login ticket and login with it.
 /// </summary>
 private void HandleTicketLoginStep()
 {
     m_currentStep = KwsLoginStep.Ticket;
     m_ticketQuery = new WmLoginTicketQuery();
     m_ticketQuery.Submit(Wm.KmodBroker, KwmCfg.Cur, HandleTicketLoginResult);
 }
Exemple #8
0
        /// <summary>
        /// Called when the KMOD ticket query results are available.
        /// </summary>
        private void OnKmodTicketResult(WmLoginTicketQuery query)
        {
            if (m_kmodQuery != query) return;
            m_kmodQuery = null;

            // Generic failure.
            if (query.Res != WmLoginTicketQueryRes.OK)
            {
                m_kmodResCode = EAnpRegisterKpsCode.Failure;
                m_kmodEx = new Exception(query.OutDesc);
            }

            // No KCD failure.
            else if (query.Ticket.KcdAddr == "")
                m_kmodResCode = EAnpRegisterKpsCode.NoKcd;

            // Query completed.
            OnQueryCompletion();
        }
Exemple #9
0
        /// <summary>
        /// Handle the results of the login ticket query.
        /// </summary>
        public void HandleLoginTicketQueryResult(WmLoginTicketQuery query, WmWinRegistry registry)
        {
            Logging.Log(1, "HandleLoginTicketQueryResult()");
            Debug.Assert(Op.m_kmodQuery == query);
            Op.m_kmodQuery = null;

            // Update the registry, if required.
            query.UpdateRegistry(registry);

            // Update the credentials, if required.
            if (query.Res == WmLoginTicketQueryRes.OK)
            {
                Creds.Ticket = query.Ticket.BinaryTicket;
                Creds.UserName = query.Ticket.AnpTicket.Elements[0].String;
                Creds.UserEmailAddress = query.Ticket.AnpTicket.Elements[1].String;
            }
        }
Exemple #10
0
 /// <summary>
 /// Post a login ticket query.
 /// </summary>
 public void PostLoginTicketQuery(WmWinRegistry registry, WmLoginTicketQueryDelegate callback)
 {
     Logging.Log(1, "PostLoginTicketQuery()");
     WmLoginTicketQuery loginQuery = new WmLoginTicketQuery();
     loginQuery.Submit(Op.Wm.KmodBroker, registry, callback);
     Op.m_kmodQuery = loginQuery;
 }
Exemple #11
0
        /// <summary>
        /// Handle the results of the login ticket query.
        /// </summary>
        private void HandleLoginTicketQueryResult(WmLoginTicketQuery query)
        {
            if (m_doneFlag) return;
            Debug.Assert(m_opStep == KwmCoreKwsOpStep.InitialPowerQuery ||
                         m_opStep == KwmCoreKwsOpStep.KasConnectAndGetTicket);

            WmWinRegistry registry = WmWinRegistry.Spawn();
            m_sh.HandleLoginTicketQueryResult(query, registry);

            // An error occurred.
            if (query.Res == WmLoginTicketQueryRes.MiscError)
            {
                OpRes = KwmCoreKwsOpRes.MiscError;
                ErrorString = query.OutDesc;
                ShowWizardEnd();
            }

            // We can create the workspace.
            else if (CheckCanCreateKws(registry, false))
            {
                // We were doing the initial power query. Retry the operation.
                if (m_opStep == KwmCoreKwsOpStep.InitialPowerQuery) RetryOp(false);

                // We obtained the login ticket for creating the workspace.
                else HandleKasConnectAndGetTicketResult();
            }
        }
Exemple #12
0
 /// <summary>
 /// Handle the results of the login ticket query.
 /// </summary>
 private void HandleLoginTicketQueryResult(WmLoginTicketQuery query)
 {
     if (!CheckCtx(KwmCoreKwsOpStep.KasConnectAndGetTicket)) return;
     WmWinRegistry registry = WmWinRegistry.Spawn();
     m_sh.HandleLoginTicketQueryResult(query, registry);
     if (query.Res == WmLoginTicketQueryRes.MiscError) HandleMiscFailure(new Exception(query.OutDesc));
     else if (CheckCanCreateKws(registry)) HandleKasConnectAndGetTicketResult();
 }
Exemple #13
0
 /// <summary>
 /// Submit the ticket query to KMOD.
 /// </summary>
 private void SubmitKmodTicketQuery()
 {
     WmLoginTicketQuery ticketQuery = new WmLoginTicketQuery();
     m_kmodQuery = ticketQuery;
     KwmCfg cfg = new KwmCfg();
     UpdateRegistryObject(cfg);
     ticketQuery.Submit(Wm.KmodBroker, cfg, OnKmodTicketResult);
 }
Exemple #14
0
        public override void Start()
        {
            try
            {
                // Make sure we can login on the KPS.
                if (!KwmCfg.Cur.CanLoginOnKps()) throw new EAnpExInvalidKpsConfig();

                // Get a ticket.
                m_step = OpStep.TicketReply;
                WmLoginTicketQuery ticketQuery = new WmLoginTicketQuery();
                m_kmodQuery = ticketQuery;
                ticketQuery.Submit(Wm.KmodBroker, KwmCfg.Cur, OnKmodTicketResult);
            }

            catch (Exception ex)
            {
                HandleFailure(ex);
            }
        }
 // Cancel and clear the ticket query, if required.
 private void ClearTicketQuery()
 {
     if (m_ticketQuery != null)
     {
         m_ticketQuery.Cancel();
         m_ticketQuery = null;
     }
 }
Exemple #16
0
        /// <summary>
        /// Called when the KMOD ticket query results are available.
        /// </summary>
        private void OnKmodTicketResult(WmLoginTicketQuery query)
        {
            if (m_kmodQuery != query) return;
            m_kmodQuery = null;
            Debug.Assert(m_step == OpStep.TicketReply);

            try
            {
                // Update the registry information.
                query.UpdateRegistry();

                // Generic failure.
                if (query.Res != WmLoginTicketQueryRes.OK) throw new Exception(query.OutDesc);

                // We cannot create a workspace.
                if (!KwmCfg.Cur.CanCreateKws()) throw new EAnpExInvalidKpsConfig();

                // Update the credentials.
                Creds.Ticket = query.Ticket.BinaryTicket;
                Creds.UserName = query.Ticket.AnpTicket.Elements[0].String;
                Creds.UserEmailAddress = query.Ticket.AnpTicket.Elements[1].String;

                // Set the KCD address.
                if (KwmCfg.Cur.CustomKcdFlag) Creds.KcdAddress = KwmCfg.Cur.CustomKcdAddress;
                else Creds.KcdAddress = KwmCfg.Cur.KpsKcdAddr;
                if (Creds.KcdAddress == "") throw new Exception("invalid KCD address");

                // Create the workspace object.
                Kws = Wm.CreateWorkspace(Creds);
                RegisterToKws();

                // Start the spawn operation and wait for the connection.
                m_step = OpStep.Connecting;
                Kws.Sm.RequestTaskSwitch(KwsTask.Spawn);
                SendCreateKwsCmdIfNeeded();
            }

            catch (Exception ex)
            {
                HandleFailure(ex);
            }
        }
Exemple #17
0
        /// <summary>
        /// Called when the ticket query results are available.
        /// </summary>
        private void OnTicketResult(WmLoginTicketQuery query)
        {
            ClearKmodQuery();

            query.UpdateRegistry(WmWinRegistry.Spawn());
            if (query.Res != WmLoginTicketQueryRes.OK) creds.SetServerError(query.OutDesc);
            else LoginSuccess = true;

            this.Enabled = true;

            // Pass to the next page.
            if (LoginSuccess) this.PressButton(WizardButtons.Next);
        }