Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />
<PackageVersion Include="Particular.Approvals" Version="2.0.1" />
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.1.1" />
<PackageVersion Include="Particular.Licensing.Sources" Version="6.2.1" />
<PackageVersion Include="Particular.Licensing.Sources" Version="7.3.0" />
<PackageVersion Include="Particular.Obsoletes" Version="1.1.0" />
<PackageVersion Include="Particular.ServicePulse.Core" Version="2.9.1" />
<PackageVersion Include="Polly.Core" Version="8.7.0" />
Expand Down
26 changes: 0 additions & 26 deletions src/ServiceControl.Config/UI/License/LicenseComponentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

static class LicenseComponentFactory
{
const string UpgradeProtectionLicenseText = "Please extend your upgrade protection so that we can continue to provide you with support and new versions of the Particular Service Platform.";
const string SubscriptionLicenseText = "Please extend your license to continue using the Particular Service Platform.";

static readonly CountInflector DaysInflector = new()
Expand Down Expand Up @@ -74,31 +73,6 @@ static LicenseComponent SubscriptionExpiryComponent(LicenseDetails details)

static LicenseComponent UpgradeProtectionExpiryComponent(LicenseDetails details)
{
if (details.WarnUserUpgradeProtectionHasExpired)
{
return new LicenseComponent
{
Label = "Upgrade protection expiry date:",
Value = $"{details.UpgradeProtectionExpiration:d} - expired",
Importance = Importance.Warning,
ShortText = "Platform license expired",
WarningText = UpgradeProtectionLicenseText
};
}

if (details.WarnUserUpgradeProtectionIsExpiring)
{
var daysRemain = DaysInflector.Inflect(details.DaysUntilUpgradeProtectionExpires ?? 0);
return new LicenseComponent
{
Label = "Upgrade protection expiry date:",
Value = $"{details.UpgradeProtectionExpiration:d} - {daysRemain} left",
Importance = Importance.Warning,
ShortText = $"Warning: Upgrade protection expiring in {daysRemain}",
WarningText = UpgradeProtectionLicenseText
};
}

return new LicenseComponent
{
Label = "Upgrade protection expiry date:",
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceControl.LicenseManagement/DetectedLicense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public DetectedLicense(string licensePath, LicenseDetails details)
}

public string Location { get; }

public LicenseDetails Details { get; }

public bool IsEvaluationLicense { get; init; }
}
}
23 changes: 14 additions & 9 deletions src/ServiceControl.LicenseManagement/LicenseDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,35 @@
public class LicenseDetails
{
public DateTime? ExpirationDate { get; private init; }

public DateTime? UpgradeProtectionExpiration { get; private init; }

public bool IsTrialLicense { get; private init; }

public bool IsCommercialLicense { get; private init; }

public bool IsExtendedTrial { get; private init; }

public string LicenseType { get; private init; }

public string Edition { get; private init; }

public string RegisteredTo { get; private init; }

public bool ValidForServiceControl { get; private init; }

public int? DaysUntilSubscriptionExpires { get; private init; }
public int? DaysUntilUpgradeProtectionExpires { get; private init; }

public bool WarnUserTrialIsExpiring { get; private init; }

public bool WarnUserTrialHasExpired { get; private init; }

public bool WarnUserSubscriptionIsExpiring { get; private init; }

public bool WarnUserSubscriptionHasExpired { get; private init; }
public bool WarnUserUpgradeProtectionIsExpiring { get; private init; }
public bool WarnUserUpgradeProtectionHasExpired { get; private init; }

public string Status { get; private init; }

public LicensedProduct[] Products { get; private init; }

public static LicenseDetails TrialFromEndDate(DateOnly endDate)
Expand Down Expand Up @@ -71,11 +82,8 @@ internal static LicenseDetails FromLicense(License license)
Products = license.LicensedEndpoints?.Select(le => new LicensedProduct(le.Size.EndsWith("U") ? "Unlimited" : Regex.Replace(le.Size, @"^\D*", ""), le.Quantity)).ToArray(),
ValidForServiceControl = license.ValidForApplication("ServiceControl"),
DaysUntilSubscriptionExpires = license.GetDaysUntilLicenseExpires(),
DaysUntilUpgradeProtectionExpires = license.GetDaysUntilUpgradeProtectionExpires(),
WarnUserUpgradeProtectionHasExpired = licenseStatus is LicenseStatus.ValidWithExpiredUpgradeProtection or LicenseStatus.InvalidDueToExpiredUpgradeProtection,
WarnUserTrialIsExpiring = licenseStatus == LicenseStatus.ValidWithExpiringTrial,
WarnUserSubscriptionIsExpiring = licenseStatus == LicenseStatus.ValidWithExpiringSubscription,
WarnUserUpgradeProtectionIsExpiring = licenseStatus == LicenseStatus.ValidWithExpiringUpgradeProtection,
WarnUserTrialHasExpired = licenseStatus == LicenseStatus.InvalidDueToExpiredTrial,
WarnUserSubscriptionHasExpired = licenseStatus == LicenseStatus.InvalidDueToExpiredSubscription,
Status = licenseStatus.ToString()
Expand All @@ -85,9 +93,6 @@ internal static LicenseDetails FromLicense(License license)

public bool HasLicenseExpired() => ExpirationDate.HasValue && HasLicenseDateExpired(ExpirationDate.Value);

public bool ReleaseNotCoveredByMaintenance(DateTime buildTimeStamp) =>
buildTimeStamp > UpgradeProtectionExpiration;

static bool HasLicenseDateExpired(DateTime licenseDate)
{
var oneDayGrace = licenseDate;
Expand Down
4 changes: 1 addition & 3 deletions src/ServiceControl.LicenseManagement/LicenseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LicenseManager
public static DetectedLicense FindLicense()
{
var sources = LicenseSource.GetStandardLicenseSources();
var result = ActiveLicense.Find("ServiceControl", sources.ToArray());
var result = ActiveLicense.Find("ServiceControl", [.. sources]);

var detectedLicense = new DetectedLicense(result.Location, LicenseDetails.FromLicense(result.License))
{
Expand Down Expand Up @@ -50,7 +50,5 @@ public static bool TryImportLicense(string licenseFile, out string errorMessage)
errorMessage = null;
return true;
}

public static DateTime GetReleaseDate() => ReleaseDateReader.GetReleaseDate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,9 @@ CheckLicenseResult CheckLicenseIsValid()
return new CheckLicenseResult(false, "This license edition does not include ServiceControl");
}

var releaseDate = LicenseManager.GetReleaseDate();

if (license.Details.ReleaseNotCoveredByMaintenance(releaseDate))
if (license.Details.Status.Contains("InvalidDueToUpgradeProtectionNoLongerBeingSupported", StringComparison.OrdinalIgnoreCase))
{
return new CheckLicenseResult(false, "License does not cover this release of ServiceControl Monitoring. Upgrade protection expired.");
return new CheckLicenseResult(false, "Licenses with upgrade protection are no longer supported.");
}

return new CheckLicenseResult(true);
Expand All @@ -241,6 +239,7 @@ public CheckLicenseResult(bool valid, string message = null)
}

public bool Valid { get; private set; }

public string Message { get; private set; }
}
}
Expand Down
Loading