Example #1
0
        bool IsLicenseValid(ILicenseBlob b)
        {
            var details = b.Fields;

            if (IsLicenseExpired(details))
            {
                permanentIssues.AcceptIssue(new Issue("License " + details.Id + " has expired.", b.ToRedactedString(),
                                                      IssueSeverity.Error));
                return(false);
            }

            if (!HasLicenseBegun(details))
            {
                permanentIssues.AcceptIssue(new Issue(
                                                "License " + details.Id + " was issued in the future; check system clock.", b.ToRedactedString(),
                                                IssueSeverity.Error));
                return(false);
            }

            if (IsBuildDateNewer(details.SubscriptionExpirationDate))
            {
                permanentIssues.AcceptIssue(new Issue(
                                                $"License {details.Id} covers ImageResizer versions prior to {details.SubscriptionExpirationDate?.ToString("D")}, but you are using a build dated {GetBuildDate()?.ToString("D")}",
                                                b.ToRedactedString(),
                                                IssueSeverity.Error));
                return(false);
            }
            if (details.IsRevoked())
            {
                var message = b.Fields.GetMessage();
                permanentIssues.AcceptIssue(new Issue($"License {details.Id}" + (message != null ? $": {message}" : " is no longer valid"),
                                                      b.ToRedactedString(), IssueSeverity.Error));
                return(false);
            }
            return(true);
        }
Example #2
0
        bool AreFeaturesLicensed(ILicenseBlob b, IEnumerable <IEnumerable <string> > oneFromEach, bool logIssues)
        {
            var licenseFeatures = b.Fields.GetFeatures();
            var notCovered      = oneFromEach.Where(
                set => !set.Intersect(licenseFeatures, StringComparer.OrdinalIgnoreCase).Any());
            var success = !notCovered.Any();

            if (!success && logIssues)
            {
                permanentIssues.AcceptIssue(new Issue(
                                                $"License {b.Fields.Id} needs to be upgraded; it does not cover in-use features {notCovered.SelectMany(v => v).Distinct().Delimited(", ")}", b.ToRedactedString(),
                                                IssueSeverity.Error));
            }
            return(success);
        }