Example #1
0
        public static void Initialize()
        {
            var firstServerStartDate = ServerStore.LicenseStorage.GetFirstServerStartDate();

            if (firstServerStartDate == null)
            {
                firstServerStartDate = SystemTime.UtcNow;
                ServerStore.LicenseStorage.SetFirstServerStartDate(firstServerStartDate.Value);
            }

            LicenseStatus.FirstServerStartDate = firstServerStartDate.Value;

            var license = ServerStore.LicenseStorage.LoadLicense();

            if (license == null)
            {
                return;
            }

            try
            {
                LicenseStatus.Attributes = LicenseValidator.Validate(license, RSAParameters);
                LicenseStatus.Error      = false;
                LicenseStatus.Message    = null;
            }
            catch (Exception e)
            {
                LicenseStatus.Attributes = null;
                LicenseStatus.Error      = true;
                LicenseStatus.Message    = e.Message;

                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Could not validate license. License details", e);
                }

                throw new InvalidDataException("Could not validate license!");
            }
        }