private void Validate(string license) { if (_validator != null) { try { _validator.AssertValidLicense(); Logger.InfoFormat("Found a {0} license.", _validator.LicenseType); Logger.InfoFormat("Registered to {0}", _validator.Name); Logger.InfoFormat("Expires on {0}", _validator.ExpirationDate); if ((_validator.LicenseAttributes != null) && (_validator.LicenseAttributes.Count > 0)) { foreach (var licenseAttribute in _validator.LicenseAttributes) { Logger.InfoFormat("[{0}]: [{1}]", licenseAttribute.Key, licenseAttribute.Value); } } ValidateLicenseVersion(); CreateLicense(); StoreLicense(license); } catch (InvalidLicenseException) { TrialExpired = true; Logger.Info("Suitable license was not found"); } catch (LicenseExpiredException) { TrialExpired = true; Logger.Info("License has expired."); } catch (LicenseNotFoundException) { Logger.Info("License could not be loaded."); } catch (LicenseFileNotFoundException) { Logger.Info("License could not be loaded."); } } if (CurrentLicense == null) { Logger.Info("No valid license found."); CreateTrialLicense(); ValidateTrialStartDate(); } }
private void Validate() { if (validator != null) { try { validator.AssertValidLicense(); Logger.InfoFormat("Found a {0} license.", validator.LicenseType); Logger.InfoFormat("Registered to {0}", validator.Name); Logger.InfoFormat("Expires on {0}", validator.ExpirationDate); if ((validator.LicenseAttributes != null) && (validator.LicenseAttributes.Count > 0)) { foreach (var licenseAttribute in validator.LicenseAttributes) { Logger.InfoFormat("[{0}]: [{1}]", licenseAttribute.Key, licenseAttribute.Value); } } CheckIfNServiceBusVersionIsNewerThanLicenseVersion(); ConfigureNServiceBusLicense(); return; } catch (LicenseExpiredException) { trialPeriodHasExpired = true; Logger.Error("License has expired."); } catch (LicenseNotFoundException) { Logger.Error("License could not be loaded."); } catch (LicenseFileNotFoundException) { Logger.Error("License could not be loaded."); } Logger.Warn("Falling back to run in Basic1 license mode."); RunInBasic1Mode(DateTime.UtcNow); return; } Logger.Info("No valid license found."); ConfigureNServiceBusToRunInTrialMode(); }
private void ExecuteInternal(InMemoryRavenConfiguration config) { var licensePath = GetLicensePath(config); var licenseText = GetLicenseText(config); if (TryLoadLicense(licenseText) == false) { return; } try { licenseValidator.AssertValidLicense(() => { string value; LicenseAttributes = licenseValidator.LicenseAttributes; AssertForV2(licenseValidator.LicenseAttributes); if (licenseValidator.LicenseAttributes.TryGetValue("OEM", out value) && "true".Equals(value, StringComparison.InvariantCultureIgnoreCase)) { licenseValidator.MultipleLicenseUsageBehavior = AbstractLicenseValidator.MultipleLicenseUsage.AllowSameLicense; } }); CurrentLicense = new LicensingStatus { Status = "Commercial - " + licenseValidator.LicenseType, Error = false, Message = "Valid license at " + licensePath }; } catch (Exception e) { logger.ErrorException("Could not validate license at " + licensePath + ", " + licenseText, e); CurrentLicense = new LicensingStatus { Status = "AGPL - Open Source", Error = true, Message = "Could not validate license: " + licensePath + ", " + licenseText + Environment.NewLine + e }; } }
private void Validate() { if (validator != null) { try { validator.AssertValidLicense(); tracer.Info((string)"Found a {0} license.", (object)validator.LicenseType); tracer.Info((string)"Registered to {0}", (object)validator.Name); tracer.Info((string)"Expires on {0}", (object)validator.ExpirationDate); CheckIfStudioVersionIsNewerThanLicenseVersion(); ConfigureStudioLicense(); return; } catch (LicenseExpiredException) { trialPeriodHasExpired = true; tracer.Error("License has expired."); } catch (LicenseNotFoundException) { tracer.Error("License could not be loaded."); } catch (LicenseFileNotFoundException) { tracer.Error("License could not be loaded."); } return; } tracer.Info("No valid license found."); ConfigureStudioToRunInTrialMode(); }
private void ExecuteInternal(InMemoryRavenConfiguration config, bool firstTime = false, bool forceUpdate = false) { var licensePath = GetLicensePath(config); var licenseText = GetLicenseText(config); if (TryLoadLicense(config) == false) { return; } string errorMessage = string.Empty; try { try { licenseValidator.AssertValidLicense(() => { string value; errorMessage = AssertLicenseAttributes(licenseValidator.LicenseAttributes, licenseValidator.LicenseType); if (licenseValidator.LicenseAttributes.TryGetValue("OEM", out value) && "true".Equals(value, StringComparison.OrdinalIgnoreCase)) { licenseValidator.MultipleLicenseUsageBehavior = AbstractLicenseValidator.MultipleLicenseUsage.AllowSameLicense; } string allowExternalBundles; if (licenseValidator.LicenseAttributes.TryGetValue("allowExternalBundles", out allowExternalBundles) && bool.Parse(allowExternalBundles) == false) { var directoryCatalogs = config.Catalog.Catalogs.OfType <DirectoryCatalog>().ToArray(); foreach (var catalog in directoryCatalogs) { config.Catalog.Catalogs.Remove(catalog); } } }, config.TurnOffDiscoveryClient, firstTime, forceUpdate); } catch (LicenseExpiredException ex) { errorMessage = ex.Message; } var attributes = new Dictionary <string, string>(alwaysOnAttributes, StringComparer.OrdinalIgnoreCase); foreach (var licenseAttribute in licenseValidator.LicenseAttributes) { attributes[licenseAttribute.Key] = licenseAttribute.Value; } var message = "Valid license at " + licensePath; var status = "Commercial"; if (licenseValidator.LicenseType != LicenseType.Standard) { status += " - " + licenseValidator.LicenseType; } if (licenseValidator.IsOemLicense() && licenseValidator.ExpirationDate < SystemTime.UtcNow) { message = string.Format("Expired ({0}) OEM/ISV license at {1}", licenseValidator.ExpirationDate.ToShortDateString(), licensePath); status += " (Expired)"; } CurrentLicense = new LicensingStatus { Status = status, Error = !String.IsNullOrEmpty(errorMessage), Message = String.IsNullOrEmpty(errorMessage) ? message : errorMessage, Attributes = attributes }; } catch (Exception e) { logger.ErrorException("Could not validate license at " + licensePath + ", " + licenseText, e); try { var xmlDocument = new XmlDocument(); xmlDocument.Load(licensePath); var ns = new XmlNamespaceManager(xmlDocument.NameTable); ns.AddNamespace("sig", "http://www.w3.org/2000/09/xmldsig#"); var sig = xmlDocument.SelectSingleNode("/license/sig:Signature", ns); if (sig != null) { sig.RemoveAll(); } licenseText = xmlDocument.InnerXml; } catch (Exception) { // couldn't remove the signature, maybe not XML? } CurrentLicense = new LicensingStatus { Status = "AGPL - Open Source", Error = true, Details = "License Path: " + licensePath + Environment.NewLine + ", License Text: " + licenseText + Environment.NewLine + ", Exception: " + e, Message = "Could not validate license: " + e.Message, Attributes = new Dictionary <string, string>(alwaysOnAttributes, StringComparer.OrdinalIgnoreCase) }; } }
private void ExecuteInternal(InMemoryRavenConfiguration config) { var licensePath = GetLicensePath(config); var licenseText = GetLicenseText(config); if (TryLoadLicense(licenseText) == false) { return; } try { licenseValidator.AssertValidLicense(() => { string value; AssertForV2(licenseValidator.LicenseAttributes); if (licenseValidator.LicenseAttributes.TryGetValue("OEM", out value) && "true".Equals(value, StringComparison.OrdinalIgnoreCase)) { licenseValidator.MultipleLicenseUsageBehavior = AbstractLicenseValidator.MultipleLicenseUsage.AllowSameLicense; } string allowExternalBundles; if (licenseValidator.LicenseAttributes.TryGetValue("allowExternalBundles", out allowExternalBundles) && bool.Parse(allowExternalBundles) == false) { var directoryCatalogs = config.Catalog.Catalogs.OfType <DirectoryCatalog>().ToArray(); foreach (var catalog in directoryCatalogs) { config.Catalog.Catalogs.Remove(catalog); } } }); var attributes = new Dictionary <string, string>(alwaysOnAttributes, StringComparer.OrdinalIgnoreCase); foreach (var licenseAttribute in licenseValidator.LicenseAttributes) { attributes[licenseAttribute.Key] = licenseAttribute.Value; } CurrentLicense = new LicensingStatus { Status = "Commercial - " + licenseValidator.LicenseType, Error = false, Message = "Valid license at " + licensePath, Attributes = attributes }; } catch (Exception e) { logger.ErrorException("Could not validate license at " + licensePath + ", " + licenseText, e); try { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(licensePath); var sig = xmlDocument.SelectSingleNode("/license/Signature"); if (sig != null && sig.ParentNode != null) { sig.ParentNode.RemoveChild(sig); } var stringBuilder = new StringBuilder(); xmlDocument.WriteTo(XmlWriter.Create(stringBuilder)); licenseText = stringBuilder.ToString(); } catch (Exception) { // couldn't remove the signature, maybe not XML? } CurrentLicense = new LicensingStatus { Status = "AGPL - Open Source", Error = true, Message = "Could not validate license: " + licensePath + ", " + licenseText + Environment.NewLine + e, Attributes = new Dictionary <string, string>(alwaysOnAttributes, StringComparer.OrdinalIgnoreCase) }; } }
public void Execute(DocumentDatabase database) { string publicKey; using (var stream = typeof(ValidateLicense).Assembly.GetManifestResourceStream("Raven.Database.Commercial.RavenDB.public")) { if (stream == null) { throw new InvalidOperationException("Could not find public key for the license"); } publicKey = new StreamReader(stream).ReadToEnd(); } var licensePath = GetLicensePath(database); var licenseText = GetLicenseText(database); licenseValidator = new StringLicenseValidator(publicKey, licenseText) { DisableFloatingLicenses = true, }; licenseValidator.LicenseInvalidated += LicenseValidatorOnLicenseInvalidated; licenseValidator.MultipleLicensesWereDiscovered += LicenseValidatorOnMultipleLicensesWereDiscovered; if (string.IsNullOrEmpty(licenseText)) { CurrentLicense = new LicensingStatus { Status = "AGPL - Open Source", Error = false, Message = "No license file was found at " + licenseText + "\r\nThe AGPL license restrictions apply, only Open Source / Development work is permitted." }; return; } try { licenseValidator.AssertValidLicense(() => { string value; if (licenseValidator.LicenseAttributes.TryGetValue("OEM", out value) && "true".Equals(value, StringComparison.InvariantCultureIgnoreCase)) { licenseValidator.MultipleLicenseUsageBehavior = AbstractLicenseValidator.MultipleLicenseUsage.AllowSameLicense; } }); CurrentLicense = new LicensingStatus { Status = "Commercial - " + licenseValidator.LicenseType, Error = false, Message = "Valid license at " + licensePath }; } catch (Exception e) { logger.ErrorException("Could not validate license at " + licensePath + ", " + licenseText, e); CurrentLicense = new LicensingStatus { Status = "AGPL - Open Source", Error = true, Message = "Could not validate license: " + licensePath + ", " + licenseText + Environment.NewLine + e }; } }