Esempio n. 1
0
        /// <summary>
        /// Process a new response from the license server.
        ///   This data will be used for computing future policy decisions. The
        ///   following parameters are processed:
        ///   <ul>
        ///     <li>VT: the timestamp that the client should consider the response valid until</li>
        ///     <li>GT: the timestamp that the client should ignore retry errors until</li>
        ///     <li>GR: the number of retry errors that the client should ignore</li>
        ///   </ul>
        /// </summary>
        /// <param name="response">
        /// the result from validating the server response
        /// </param>
        /// <param name="rawData">
        /// the raw server response data
        /// </param>
        public void ProcessServerResponse(PolicyServerResponse response, ResponseData rawData)
        {
            // Update retry counter
            this.RetryCount = response == PolicyServerResponse.Retry ? this.RetryCount + 1 : 0;

            switch (response)
            {
            case PolicyServerResponse.Licensed:

                // Update server policy data
                Dictionary <string, string> extras;
                if (!PolicyExtensions.TryDecodeExtras(rawData.Extra, out extras))
                {
                    Debug.WriteLine("Invalid syntax error while decoding extras data from server.");
                }
                else
                {
                    this.SetValidityTimestamp(extras.ContainsKey("VT") ? extras["VT"] : DefaultValidityTimestamp);
                    this.SetRetryUntil(extras.ContainsKey("GT") ? extras["GT"] : DefaultRetryUntil);
                    this.SetMaxRetries(extras.ContainsKey("GR") ? extras["GR"] : DefaultMaxRetries);
                }

                break;

            case PolicyServerResponse.NotLicensed:
                this.SetValidityTimestamp(DefaultValidityTimestamp);
                this.SetRetryUntil(DefaultRetryUntil);
                this.SetMaxRetries(DefaultMaxRetries);
                break;
            }

            this.LastResponse = response;

            this.preferences.Commit();
        }
Esempio n. 2
0
        /// <summary>
        /// Process a new response from the license server.
        ///   This data will be used for computing future policy decisions. The
        ///   following parameters are processed:
        ///   <ul>
        ///     <li>VT: the timestamp that the client should consider the response valid until</li>
        ///     <li>GT: the timestamp that the client should ignore retry errors until</li>
        ///     <li>GR: the number of retry errors that the client should ignore</li>
        ///   </ul>
        /// </summary>
        /// <param name="response">
        /// the result from validating the server response
        /// </param>
        /// <param name="rawData">
        /// the raw server response data
        /// </param>
        public virtual void ProcessServerResponse(PolicyServerResponse response, ResponseData rawData)
        {
            // Update retry counter
            this.RetryCount = response == PolicyServerResponse.Retry ? this.RetryCount + 1 : 0;

            switch (response)
            {
            case PolicyServerResponse.Licensed:

                // Update server policy data
                Dictionary <string, string> extras;
                if (!PolicyExtensions.TryDecodeExtras(rawData.Extra, out extras))
                {
                    Debug.WriteLine("Invalid syntax error while decoding extras data from server.");
                }

                // If no response or not parseable, expire in one minute.
                this.ValidityTimestamp = PolicyExtensions.GetCurrentMilliseconds() + PolicyExtensions.MillisPerMinute;

                foreach (var pair in extras)
                {
                    this.ProcessResponseExtra(pair);
                }

                break;

            case PolicyServerResponse.NotLicensed:
                this.ValidityTimestamp = Preferences.DefaultValidityTimestamp;
                this.RetryUntil        = Preferences.DefaultRetryUntil;
                this.MaxRetries        = Preferences.DefaultMaxRetries;
                break;
            }

            this.LastResponse = response;

            this.Obfuscator.Commit();
        }