///<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; } }
/// <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); }
/// <summary> /// Constructor. /// </summary> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 10/13/08 RCG 2.00.00 N/A Created public BetaLicense(string applicationName) { m_License = null; m_ApplicationName = applicationName; GenerateSupportInfo(); m_LicenseInfo = new LicenseValidationRequestInfo(); m_LicenseInfo.SupportInfo = m_LicenseSupportInfo; }
/// <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); }
/// <summary> /// Deactivates the license from the current machine. /// </summary> /// <returns> /// Returns true if the license was deacivated, otherwise false. /// </returns> public bool Deactivate() { 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 return(SecureLicenseManager.Deactivate(_license, this, null, info)); }
public SecureLicense Validate(LicenseValidationRequestInfo requestInfo) { var license = SecureLicenseManager.Validate(this, typeof(XRCReg), requestInfo); return(license); }
/// <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); }
/// <summary> /// Register with specified serial number /// </summary> /// <param name="serial">Serial number</param> public bool Register(string serial, string email) { if (string.IsNullOrWhiteSpace(serial)) { throw new DHBusinessException(new NonLocalizableString("Serial is not defined.")); } var licenseType = GetTypeFromSerial(serial); if (!licenseType.HasValue) { throw new DHBusinessException(new NonLocalizableString("Serial is not defined.")); } var licenseManager = ServiceLocator.Current.GetInstance <ILicenseManager>(licenseType.ToString()); var licenseInfo = licenseInfos.FirstOrDefault(x => x.LicenseType == licenseType); var license = licenseInfo != null ? licenseInfo.License : null; if (license != null) { licenseManager.ResetCacheForLicense(license); } if (licenseInfo != null) { licenseInfos.Remove(licenseInfo); } var requestInfo = new LicenseValidationRequestInfo { DontShowForms = true, SerialNumbers = new string[] { serial }, SaveExternalSerials = true, DisableTrials = true, DisableCache = true, ShouldGetNewSerialNumber = true }; requestInfo.AdditionalServerProperties.Add("email", email); var isExpired = false; try { license = licenseManager.Validate(requestInfo); if (license == null || license.IsTrial) { throw new LicenseInvalidSerialException("License not found or expired"); } if (license.IsActivation && !license.IsActivated) { throw new LicenseCouldNotActivateException(); } LogProvider.Log.Info(CustomModulesNames.PlayerXRay, $"License has been registered: {license.SerialNumber.Substring(0, 5)}"); return(true); } catch (NoLicenseException ex) { // check for expiration first var exceptionData = ParseException(ex); if (exceptionData != null && exceptionData.ContainsKey("errorCode") && exceptionData["errorCode"].Equals("LCS_EXP")) { isExpired = true; LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Registration: License expired", ex); throw new LicenseExpiredException(); } // check for activation errors var errorCodes = Utils.GetErrorCodes(ex); if (errorCodes.Any(x => x.Equals("E_CouldNotActivateAtServer") || x.Equals("E_CannotValidateAtServer"))) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Registration: License wasn't activated", ex); throw new LicenseCouldNotActivateException(); } LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Registration: License not found or expired", ex); throw new LicenseInvalidSerialException("License not found or expired", ex); } catch (LicenseCouldNotActivateException) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Registration: License wasn't activated"); throw; } catch (Exception ex) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Registration: License validation error", ex); throw new LicenseException("Unexpected license validation exception", ex); } finally { licenseInfo = new LicenseInfo(license, licenseType.Value); licenseInfos.Add(licenseInfo); // if license expired we must specify that if (isExpired && license == null) { licenseInfo.IsExpired = true; licenseInfo.Serial = serial; } LogProvider.Log.Info(CustomModulesNames.PlayerXRay, $"License limits: Cash={licenseInfo.CashLimit}, Tournament={licenseInfo.TournamentLimit}"); UpdateExpirationDates(new[] { licenseInfo }); } }
public SecureLicense Validate(LicenseValidationRequestInfo requestInfo) { return(licenseManager.Validate(requestInfo)); }