Ejemplo n.º 1
0
        private void Bt_Decrypt_Click(object sender, EventArgs e)
        {
            DeployLX.Licensing.v3.SecureLicense         Secure       = new SecureLicense();
            DeployLX.Licensing.Management.v3.LicenseKey myLicenseKey = new DeployLX.Licensing.Management.v3.LicenseKey(new FileStream("", FileMode.Open));

            myLicenseKey.DecryptLicense(Secure);
        }
Ejemplo n.º 2
0
    /// <summary>
    ///     Shows the registration form to the user so they can enter a new serial number. Might be used
    ///     to upgrade to a better edition or fix a wrongly entered serial number.
    /// </summary>
    /// <returns>
    ///     Returns true if the registration unlocked a new license, otherwise false.
    /// </returns>
    public bool ReShowRegistrationForm()
    {
        // Need to validate the license first.
        if (_license == null)
        {
            return(false);
        }

        var info = new LicenseValidationRequestInfo();

#if DEBUG
        // See http://xheo.com/knowledge-base/deploylx/licensing/enabling-developer-mode
        info.DeveloperMode = true;
#endif

        var newLicense = _license.ShowRegistrationForm(this, null, info);
        if (newLicense != null && newLicense != _license)
        {
            _license.Dispose();
            _license = newLicense;
            return(true);
        }


        return(false);
    }
Ejemplo n.º 3
0
        private void Bt_Generate_Click(object sender, EventArgs e)
        {
            MemoryStream  MemStream = new MemoryStream(Properties.Resources.Keys);
            string        value     = string.Empty;
            SecureLicense sl        = new SecureLicense();

            sl.SerialNumber = "1234";
            DeployLX.Licensing.Management.v3.LicenseKey mykey3 = new DeployLX.Licensing.Management.v3.LicenseKey(MemStream);
            // DeployLX.Licensing.Management.v4.LicenseKey key = new DeployLX.Licensing.Management.v4.LicenseKey(MemStream);

            memoEdit1.Text         = "";
            memoEdit1.SelectedText = DateTime.Now + "---" + "Start Generate." + Environment.NewLine;
            Thread.Sleep(TimeSpan.FromMilliseconds(100));
            memoEdit1.SelectedText = "----------------" + Environment.NewLine;
            Thread.Sleep(TimeSpan.FromMilliseconds(100));
            switch (cb_LicMethod.SelectedIndex)
            {
            case 0:
                memoEdit1.SelectedText = DateTime.Now + "---" + "Generate Serial Standard edition." + Environment.NewLine;
                string prefix = "STD-";
                TxtBox_Result.Text = mykey3.MakeSerialNumber(prefix, 1, DeployLX.Licensing.v3.SerialNumberFlags.None, -1, 0, -1, 0, null, "U9VWT2FG3Q7RS0AC1DEYMNX6P8HJ4KL5", DeployLX.Licensing.v3.CodeAlgorithm.SerialNumber);
                break;

            case 1:
                memoEdit1.SelectedText = DateTime.Now + "---" + "Generate Serial Profesional edition." + Environment.NewLine;
                string prefix1 = "PRO-";
                TxtBox_Result.Text = mykey3.MakeSerialNumber(prefix1, 1, SerialNumberFlags.None, -1, 0, -1, 0, null, "U9VWT2FG3Q7RS0AC1DEYMNX6P8HJ4KL5", CodeAlgorithm.SerialNumber);
                break;
            }
            memoEdit1.SelectedText = "Serial is : " + Environment.NewLine;
            Thread.Sleep(TimeSpan.FromMilliseconds(100));
            memoEdit1.SelectedText = TxtBox_Result.Text + Environment.NewLine;
        }
Ejemplo n.º 4
0
    ///<summary>
    ///	Asks DeployLX to assert that the application has a valid license.
    ///</summary>
    ///<exception cref = "DeployLX.Licensing.v4.NoLicenseException">Thrown when a valid license could not be obtained. See exception ValidationRecords for details.</exception>
    ///<param name = "silent">Indicates if DeployLX should validate without showing any forms to the user.</param>
    public void Required(bool silent)
    {
        try
        {
            var info = new LicenseValidationRequestInfo();
            info.DontShowForms = !silent;

#if DEBUG
            // See http://xheo.com/knowledge-base/deploylx/licensing/enabling-developer-mode
            info.DeveloperMode = false;

            // See http://xheo.com/knowledge-base/deploylx/licensing/how-to-testing-license-time-or-subscription-limits
            info.TestDate = DateTime.UtcNow.AddDays(30);
#endif
            var license = SecureLicenseManager.Validate(this, null, info);

            if (_license != null && license != _license)
            {
                _license.Dispose();
            }

            _license = license;

            _lastError = null;
        }
        catch (NoLicenseException ex)
        {
            _lastError = ex;
            RecordLicenseError(ex);
            throw;
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 ///     Make sure all license resources are disposed and any pending data is persisted.
 /// </summary>
 void IDisposable.Dispose()
 {
     if (_license != null)
     {
         _license.Dispose();
     }
     _license = null;
 }
Ejemplo n.º 6
0
 private void Bt_RmvKey_Click(object sender, EventArgs e)
 {
     if (_securelicense.IsActivated || XtraMessageBox.Show("Are you sure you want clear the license? This will stop the application from running.", "Aexio Tools", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         _securelicense = SecureLicenseManager.Validate(this, null, null);
         XtraMessageBox.Show("The license has been reset. The application will be shut down");
     }
 }
Ejemplo n.º 7
0
        public LicenseInfo(SecureLicense license, LicenseType licenseType)
        {
            this.license     = license;
            this.licenseType = licenseType;

            if (IsTrial)
            {
                var timeMonitor = license.GetTimeMonitor();
                ExpiryDate = DateTime.Now + timeMonitor.TimeRemaining;
            }

            InitializeLimits();
        }
Ejemplo n.º 8
0
    /// <summary>
    ///     Activates the license on the current machine.
    /// </summary>
    /// <returns>
    ///     Returns true if the license was activated, otherwise false.
    /// </returns>
    public bool Activate()
    {
        // Hardware Locking and the Activation Process
        // http://xheo.com/docs/DLXl/5/html/developers%20guide/licensing%20basics/hardware%20locking%20and%20the%20activation%20process.html


        if (!Check(false))
        {
            return(false);
        }

        var activation = _license.Limits[typeof(ActivationLimit)] as ActivationLimit;

        if (activation == null)
        {
            return(false);
        }

        if (activation.HasActivated)
        {
            return(true);
        }

        try
        {
            var info = new LicenseValidationRequestInfo();
#if DEBUG
            // See http://xheo.com/knowledge-base/deploylx/licensing/enabling-developer-mode
            info.DeveloperMode = true;
#endif

            var newLicense = SecureLicenseManager.ShowForm(activation, null, this, null, info, null);
            if (newLicense != null && newLicense != _license)
            {
                if (_license != null)
                {
                    _license.Dispose();
                }
                _license = newLicense;
            }

            return(true);
        }
        catch (SecureLicenseException)
        {
            // TODO: Decide how to handle failures here. Might parse exception or just
            // ignore and assume DeployLX error reporting to user was enough.
        }

        return(false);
    }
Ejemplo n.º 9
0
 public void ResetCacheForLicense(SecureLicense license)
 {
     SecureLicenseManager.ResetCacheForLicense(license);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// License validation
        /// </summary>
        public bool Validate()
        {
            licenseInfos.Clear();

            // workaround for obfuscation
            var licenseTypes = new LicenseType[]
            {
                LicenseType.XRayTrial,
                LicenseType.XRayHoldem,
                LicenseType.XRayOmaha,
                LicenseType.XRayCombo
            };

            // validate each possible type
            foreach (LicenseType licenseType in licenseTypes)
            {
                SecureLicense license = null;

                NoLicenseException validationException = null;

                var isExpired = false;
                var serial    = string.Empty;

                var licenseManager = ServiceLocator.Current.GetInstance <ILicenseManager>(licenseType.ToString());

                try
                {
                    var requestInfo = new LicenseValidationRequestInfo
                    {
                        DontShowForms = true
                    };

                    license = licenseManager.Validate(requestInfo);

                    if (!license.IsTrial)
                    {
                        LogProvider.Log.Info(CustomModulesNames.PlayerXRay, string.Format("Found license: {0}-*", license.SerialNumber.Substring(0, 4)));
                    }
                }
                catch (NoLicenseException ex)
                {
                    validationException = ex;

                    var exceptionData = ParseException(ex);

                    if (exceptionData != null &&
                        exceptionData.ContainsKey("errorCode") && exceptionData["errorCode"].Equals("LCS_EXP"))
                    {
                        isExpired = true;
                        serial    = exceptionData["serial"];
                    }
                }
                catch (Exception ex)
                {
                    LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Validation: License validation error", ex);
                }

                // Trial license - check if real trial is expired or does not exists
                if (license != null && license.IsTrial)
                {
                    licenseManager.ResetCacheForLicense(license);

                    var requestInfo = new LicenseValidationRequestInfo
                    {
                        DontShowForms = true,
                        DisableTrials = true
                    };

                    try
                    {
                        license = licenseManager.Validate(requestInfo);
                    }
                    catch (NoLicenseException ex)
                    {
                        validationException = ex;
                    }
                }

                var licenseInfo = new LicenseInfo(license, licenseType);
                licenseInfo.ValidationException = validationException;

                // if license expired we must specify that
                if (isExpired && license == null)
                {
                    licenseInfo.IsExpired = true;
                    licenseInfo.Serial    = serial;
                }

                if (!licenseInfo.IsTrial || licenseInfos.All(x => !x.IsTrial))
                {
                    licenseInfos.Add(licenseInfo);
                }
            }

            isInitialized = true;

            UpdateExpirationDates(licenseInfos);

            var isValid = licenseInfos.Any(x => x.IsRegistered);

            return(isValid);
        }