Skip to content

Commit 16d6a9b

Browse files
Update dependency Particular.Licensing.Sources to v7 (#5602)
* Update dependency Particular.Licensing.Sources to v7 * Adjust code for upgrade protection changes --------- Co-authored-by: dependencyupdates[bot] <218638057+dependencyupdates[bot]@users.noreply.github.com> Co-authored-by: Brandon Ording <bording@gmail.com>
1 parent aa5acd1 commit 16d6a9b

6 files changed

Lines changed: 21 additions & 43 deletions

File tree

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />
6262
<PackageVersion Include="Particular.Approvals" Version="2.0.1" />
6363
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.1.1" />
64-
<PackageVersion Include="Particular.Licensing.Sources" Version="6.2.1" />
64+
<PackageVersion Include="Particular.Licensing.Sources" Version="7.3.0" />
6565
<PackageVersion Include="Particular.Obsoletes" Version="1.1.0" />
6666
<PackageVersion Include="Particular.ServicePulse.Core" Version="2.9.1" />
6767
<PackageVersion Include="Polly.Core" Version="8.7.0" />

src/ServiceControl.Config/UI/License/LicenseComponentFactory.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
static class LicenseComponentFactory
88
{
9-
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.";
109
const string SubscriptionLicenseText = "Please extend your license to continue using the Particular Service Platform.";
1110

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

7574
static LicenseComponent UpgradeProtectionExpiryComponent(LicenseDetails details)
7675
{
77-
if (details.WarnUserUpgradeProtectionHasExpired)
78-
{
79-
return new LicenseComponent
80-
{
81-
Label = "Upgrade protection expiry date:",
82-
Value = $"{details.UpgradeProtectionExpiration:d} - expired",
83-
Importance = Importance.Warning,
84-
ShortText = "Platform license expired",
85-
WarningText = UpgradeProtectionLicenseText
86-
};
87-
}
88-
89-
if (details.WarnUserUpgradeProtectionIsExpiring)
90-
{
91-
var daysRemain = DaysInflector.Inflect(details.DaysUntilUpgradeProtectionExpires ?? 0);
92-
return new LicenseComponent
93-
{
94-
Label = "Upgrade protection expiry date:",
95-
Value = $"{details.UpgradeProtectionExpiration:d} - {daysRemain} left",
96-
Importance = Importance.Warning,
97-
ShortText = $"Warning: Upgrade protection expiring in {daysRemain}",
98-
WarningText = UpgradeProtectionLicenseText
99-
};
100-
}
101-
10276
return new LicenseComponent
10377
{
10478
Label = "Upgrade protection expiry date:",

src/ServiceControl.LicenseManagement/DetectedLicense.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ public DetectedLicense(string licensePath, LicenseDetails details)
99
}
1010

1111
public string Location { get; }
12+
1213
public LicenseDetails Details { get; }
14+
1315
public bool IsEvaluationLicense { get; init; }
1416
}
1517
}

src/ServiceControl.LicenseManagement/LicenseDetails.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,35 @@
88
public class LicenseDetails
99
{
1010
public DateTime? ExpirationDate { get; private init; }
11+
1112
public DateTime? UpgradeProtectionExpiration { get; private init; }
1213

1314
public bool IsTrialLicense { get; private init; }
15+
1416
public bool IsCommercialLicense { get; private init; }
17+
1518
public bool IsExtendedTrial { get; private init; }
19+
1620
public string LicenseType { get; private init; }
21+
1722
public string Edition { get; private init; }
23+
1824
public string RegisteredTo { get; private init; }
25+
1926
public bool ValidForServiceControl { get; private init; }
27+
2028
public int? DaysUntilSubscriptionExpires { get; private init; }
21-
public int? DaysUntilUpgradeProtectionExpires { get; private init; }
29+
2230
public bool WarnUserTrialIsExpiring { get; private init; }
31+
2332
public bool WarnUserTrialHasExpired { get; private init; }
33+
2434
public bool WarnUserSubscriptionIsExpiring { get; private init; }
35+
2536
public bool WarnUserSubscriptionHasExpired { get; private init; }
26-
public bool WarnUserUpgradeProtectionIsExpiring { get; private init; }
27-
public bool WarnUserUpgradeProtectionHasExpired { get; private init; }
37+
2838
public string Status { get; private init; }
39+
2940
public LicensedProduct[] Products { get; private init; }
3041

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

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

88-
public bool ReleaseNotCoveredByMaintenance(DateTime buildTimeStamp) =>
89-
buildTimeStamp > UpgradeProtectionExpiration;
90-
9196
static bool HasLicenseDateExpired(DateTime licenseDate)
9297
{
9398
var oneDayGrace = licenseDate;

src/ServiceControl.LicenseManagement/LicenseManager.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class LicenseManager
88
public static DetectedLicense FindLicense()
99
{
1010
var sources = LicenseSource.GetStandardLicenseSources();
11-
var result = ActiveLicense.Find("ServiceControl", sources.ToArray());
11+
var result = ActiveLicense.Find("ServiceControl", [.. sources]);
1212

1313
var detectedLicense = new DetectedLicense(result.Location, LicenseDetails.FromLicense(result.License))
1414
{
@@ -50,7 +50,5 @@ public static bool TryImportLicense(string licenseFile, out string errorMessage)
5050
errorMessage = null;
5151
return true;
5252
}
53-
54-
public static DateTime GetReleaseDate() => ReleaseDateReader.GetReleaseDate();
5553
}
5654
}

src/ServiceControlInstaller.Engine/Validation/AbstractCommandChecks.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,9 @@ CheckLicenseResult CheckLicenseIsValid()
222222
return new CheckLicenseResult(false, "This license edition does not include ServiceControl");
223223
}
224224

225-
var releaseDate = LicenseManager.GetReleaseDate();
226-
227-
if (license.Details.ReleaseNotCoveredByMaintenance(releaseDate))
225+
if (license.Details.Status.Contains("InvalidDueToUpgradeProtectionNoLongerBeingSupported", StringComparison.OrdinalIgnoreCase))
228226
{
229-
return new CheckLicenseResult(false, "License does not cover this release of ServiceControl Monitoring. Upgrade protection expired.");
227+
return new CheckLicenseResult(false, "Licenses with upgrade protection are no longer supported.");
230228
}
231229

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

243241
public bool Valid { get; private set; }
242+
244243
public string Message { get; private set; }
245244
}
246245
}

0 commit comments

Comments
 (0)