示例#1
0
 /// <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);
 }
示例#2
0
        /// <summary>
        /// Update the values of the registry based on the results of the
        /// query, if required. Note: this method does not read the values
        /// from the registry.
        /// </summary>
        public void UpdateRegistry(WmWinRegistry registry)
        {
            if (Res == WmLoginTicketQueryRes.MiscError) return;

            if (Res == WmLoginTicketQueryRes.InvalidCfg)
            {
                registry.KpsLoginToken = "";
                registry.KpsUserPower = 0;
                registry.KcdAddr = "";
                registry.KcdPort = 0;
            }

            else if (Res == WmLoginTicketQueryRes.OK)
            {
                registry.KcdAddr = Ticket.KcdAddr;
                registry.KcdPort = Ticket.KcdPort;
                registry.KpsUserPower = 0;
            }

            registry.WriteRegistry();
        }
示例#3
0
 /// <summary>
 /// Return an instance of this class having the values read from the
 /// registry.
 /// </summary>
 public static WmWinRegistry Spawn()
 {
     WmWinRegistry self = new WmWinRegistry();
     self.ReadRegistry();
     return self;
 }
示例#4
0
        /// <summary>
        /// Fill the values of the server info specified based on the values of
        /// the registry specified.
        /// </summary>
        public static void RegToServerInfo(WmWinRegistry reg, K3p.kpp_server_info info)
        {
            if (reg.CanLoginOnKps())
            {
                info.kps_login = reg.KpsUserName;
                info.kps_secret = reg.KpsLoginToken;
                info.kps_net_addr = reg.KpsAddr;
                info.kps_port_num = reg.KpsPort;
            }

            else
            {
                info.kps_login = "";
                info.kps_secret = "";
                info.kps_net_addr = "";
                info.kps_port_num = 0;
            }
        }
示例#5
0
        /// <summary>
        /// Submit the query using the credentials obtained from the registry
        /// specified.
        /// </summary>
        public void Submit(WmKmodBroker broker, WmWinRegistry registry, WmLoginTicketQueryDelegate callback)
        {
            // Set the proper callback.
            Callback2 = callback;

            // Fill out the server information.
            K3p.K3pSetServerInfo ssi = new K3p.K3pSetServerInfo();
            WmK3pServerInfo.RegToServerInfo(registry, ssi.Info);

            // Submit the query.
            base.Submit(broker, new K3pCmd[] { ssi, new K3p.kpp_get_kws_ticket() }, AnalyseResults);
        }
示例#6
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;
 }
示例#7
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;
            }
        }
示例#8
0
        /// <summary>
        /// Get the KAS ID used to create a new workspace.
        /// </summary>
        public KasIdentifier GetKasID(WmWinRegistry registry)
        {
            String host;
            UInt16 port;

            if (Misc.ApplicationSettings.UseCustomKas && Misc.ApplicationSettings.CustomKasAddress != "")
            {
                host = Misc.ApplicationSettings.CustomKasAddress;

                if (Misc.ApplicationSettings.CustomKasPort == "")
                    port = 443;

                else
                {
                    try
                    {
                        port = UInt16.Parse(Misc.ApplicationSettings.CustomKasPort);
                    }

                    catch (Exception e)
                    {
                        Logging.LogException(e);
                        port = 443;
                    }
                }

                Logging.Log("Using custom KAS server: " + host + ":" + port.ToString());
            }

            else
            {
                host = registry.KcdAddr;
                port = registry.KcdPort;
            }

            return new KasIdentifier(host, port);
        }
示例#9
0
        /// <summary>
        /// If the registry information indicates that we can create a
        /// workspace, this method returns true. Otherwise, it returns false 
        /// and either sends a get ticket query if confirmFlag is true and we
        /// have a login token or goes to the result page otherwise.
        /// </summary>
        private bool CheckCanCreateKws(WmWinRegistry registry, bool confirmFlag)
        {
            Logging.Log(1, "CheckCanCreateKws()");
            bool okFlag = false;
            if (!registry.CanLoginOnKps()) OpRes = KwmCoreKwsOpRes.InvalidCfg;
            else if (!registry.CanCreateKws()) OpRes = KwmCoreKwsOpRes.NoPower;
            else okFlag = true;

            if (!okFlag)
            {
                if (confirmFlag && registry.CanLoginOnKps())
                {
                    m_ih.Wiz.ShowPleaseWait("Getting authorization from SOS server " + registry.KpsAddr + ":" + registry.KpsPort);
                    m_opStep = KwmCoreKwsOpStep.InitialPowerQuery;
                    m_sh.PostLoginTicketQuery(registry, HandleLoginTicketQueryResult);
                }

                else
                {
                    ShowWizardEnd();
                }
            }

            return okFlag;
        }
示例#10
0
        /// <summary>
        /// If the registry information indicates that we can create a
        /// workspace, this method returns true. Otherwise, it cancels the 
        /// operation.
        /// </summary>
        protected bool CheckCanCreateKws(WmWinRegistry registry)
        {
            if (!registry.CanCreateKws())
            {
                HandleMiscFailure(new Exception("not authorized to create a " + Base.GetKwsString()));
                return false;
            }

            return true;
        }