public void Execute(DocumentDatabase database) { if (alreadyRun) return; alreadyRun = true; 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 }; } }