Esempio n. 1
0
        /// <summary>Handles the critical feature button click event.</summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">Event arguments</param>
        private void criticalFeatureButton_Click(object sender, EventArgs e)
        {
            if (SampleLicense.IsClockBackdatedAtRuntime(m_LastLicenseValidationTime))
            {
                //It looks like our system clock was back-dated while the application was running.
                m_LastLicenseValidationResult = false;
                m_License.LastError           = new LicenseError(LicenseError.ERROR_SYSTEM_TIME_INVALID);
            }
            else if (m_LastLicenseValidationResult && m_License.TypeOfLicense != LicenseTypes.FullNonExpiring)
            {
                //If the license is time-limited, and prior validation has passed, check to make sure the license is not expired (since time has passed since the last validation).
                LicenseEffectiveDateValidation dateValidation = new LicenseEffectiveDateValidation(m_License);
                if (!dateValidation.Validate())
                {
                    m_LastLicenseValidationResult = false;
                    m_LastLicenseValidationTime   = DateTime.UtcNow;
                    m_License.LastError           = dateValidation.LastError;
                }
            }

            if (!m_LastLicenseValidationResult)
            {
                //Double check the license validation result.  This prevents a hacker from sending a window message
                //to enable the button regardless of the validation result.
                UpdateLicenseStatus();
                sampleLicensingGui.ShowDialog(LicensingGuiDialog.LicenseManagement, this, FormStartPosition.CenterParent);
                return;
            }

            MessageBox.Show("This is a critical feature!");
        }
Esempio n. 2
0
        /// <summary>Shows the <see cref="LicensingGui"/> object's license management form.</summary>
        private void ManageLicense()
        {
            if (LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_NONE &&
                LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_PLUS_EVALUATION_WARNING)
            {
                m_License.LastError = LicenseConfiguration.EncryptionKey.LastError;
            }
            else if (SampleLicense.IsClockBackdatedAtRuntime(m_LastLicenseValidationTime))
            {
                //It looks like our system clock was back-dated while the application was running.
                m_LastLicenseValidationResult = false;
                m_License.LastError           = new LicenseError(LicenseError.ERROR_SYSTEM_TIME_INVALID);
            }
            else if (m_License.LastError.ErrorNumber != LicenseError.ERROR_COULD_NOT_LOAD_LICENSE)
            {
                //If the license was loaded, validate it.
                m_LastLicenseValidationResult = m_License.Validate();
                m_LastLicenseValidationTime   = DateTime.UtcNow;
            }

            //Update the license status on the form.
            UpdateLicenseStatus();

            //Show the license management dialog.
            sampleLicensingGui.ShowDialog(LicensingGuiDialog.LicenseManagement, this, FormStartPosition.CenterParent);
        }
Esempio n. 3
0
        /// <summary>Shows the <see cref="LicensingGui"/> object's license management form.</summary>
        private void ManageLicense()
        {
            if (LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_NONE &&
                LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_PLUS_EVALUATION_WARNING)
            {
                m_License.LastError = LicenseConfiguration.EncryptionKey.LastError;
            }
            else if (SampleLicense.IsClockBackdatedAtRuntime(m_LastLicenseValidationTime))
            {
                m_LastLicenseValidationResult = false;
                m_License.LastError           = new LicenseError(LicenseError.ERROR_SYSTEM_TIME_INVALID);
            }
            else if (m_License.LastError.ErrorNumber != LicenseError.ERROR_COULD_NOT_LOAD_LICENSE)
            {
                m_LastLicenseValidationResult = m_License.Validate();
                m_LastLicenseValidationTime   = DateTime.UtcNow;
                statusLabel.Text = "Status: " + m_License.LastError.ErrorString;
            }

            this.criticalFeatureButton.Enabled = UpdateLicenseStatus();

            sampleLicensingGui.ShowDialog(LicensingGuiDialog.LicenseManagement, this, FormStartPosition.CenterParent);

            //Update the status
            this.criticalFeatureButton.Enabled = UpdateLicenseStatus();
        }