Skip to content

Commit 11bb7f9

Browse files
authored
Merge pull request #100 from DevTrevi/develop
Merge v2.5.4
2 parents f063396 + 74e00bd commit 11bb7f9

File tree

28 files changed

+260
-187
lines changed

28 files changed

+260
-187
lines changed

BlacklistProviders/DgcReader.BlacklistProviders.Italy/DgcReader.BlacklistProviders.Italy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<RepositoryUrl>https://github.com/DevTrevi/DGCReader</RepositoryUrl>
1313
<PackageTags>DGC DCC DigitalGreenCertificate DigitalCovidCertificate Greenpass VerificaC19 Blacklist DRL Covid Covid19</PackageTags>
1414
<Description>Blacklist provider implementation using the official Italian backend APIs. This provider is included in the list of verified SDKs by Italian authorities</Description>
15-
<Version>2.5.3</Version>
15+
<Version>2.5.4</Version>
1616
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
1717
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>

BlacklistProviders/DgcReader.BlacklistProviders.Italy/Utils/HttpClientExtensionMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static string Runtime
6161
/// <summary>
6262
/// The library version
6363
/// </summary>
64-
public static string Version => typeof(ItalianDrlBlacklistProvider).Assembly.GetName().Version.ToString(3);
64+
public static string Version => typeof(ItalianDrlBlacklistProvider).Assembly.GetName().Version?.ToString(3) ?? string.Empty;
6565

6666
/// <summary>
6767
/// The user agent string to be added to each request

Deserializers/DgcReader.Deserializers.Italy/DgcReader.Deserializers.Italy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<RepositoryUrl>https://github.com/DevTrevi/DGCReader</RepositoryUrl>
1111
<PackageTags>DGC DCC DigitalGreenCertificate DigitalCovidCertificate Greenpass VerificaC19 Covid Covid19</PackageTags>
1212
<Description>Deserializer for EuDGC certificates issued by Italy including custom entries</Description>
13-
<Version>2.5.3</Version>
13+
<Version>2.5.4</Version>
1414
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
1515
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1616
<PackageProjectUrl>https://github.com/DevTrevi/DgcReader</PackageProjectUrl>

DgcReader.Providers.Abstractions/DgcReader.Providers.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<RepositoryUrl>https://github.com/DevTrevi/DGCReader</RepositoryUrl>
1111
<PackageTags>DGC DCC DigitalGreenCertificate DigitalCovidCertificate Greenpass Covid Covid19</PackageTags>
1212
<Description>Base classes for implementing providers for DgcReader</Description>
13-
<Version>2.5.3</Version>
13+
<Version>2.5.4</Version>
1414
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
1515
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1616
<PackageProjectUrl>https://github.com/DevTrevi/DgcReader</PackageProjectUrl>

DgcReader/DgcReader.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<RepositoryUrl>https://github.com/DevTrevi/DGCReader</RepositoryUrl>
1111
<PackageTags>DGC DCC DigitalGreenCertificate DigitalCovidCertificate Greenpass Covid Covid19</PackageTags>
1212
<Description>Library for decoding and validating European Digital Green Certificates</Description>
13-
<Version>2.5.3</Version>
13+
<Version>2.5.4</Version>
1414
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
1515
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>

DgcReader/DgcReaderService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,12 @@ private async Task<BlacklistValidationResult> GetBlacklistValidationResult(EuDGC
454454
var certEntry = dgc.GetCertificateEntry();
455455

456456
// Tracking the validated CertificateIdentifier
457-
context.CertificateIdentifier = certEntry.CertificateIdentifier;
457+
context.CertificateIdentifier = certEntry?.CertificateIdentifier ?? string.Empty;
458458
try
459459
{
460460
foreach (var blacklistProvider in BlackListProviders)
461461
{
462-
var blacklisted = await blacklistProvider.IsBlacklisted(certEntry.CertificateIdentifier, cancellationToken);
462+
var blacklisted = await blacklistProvider.IsBlacklisted(context.CertificateIdentifier, cancellationToken);
463463

464464
// At least one check performed
465465
context.BlacklistVerified = true;

RuleValidators/DgcReader.RuleValidators.Germany/DgcReader.RuleValidators.Germany.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<RepositoryUrl>https://github.com/DevTrevi/DGCReader</RepositoryUrl>
1111
<PackageTags>DGC DCC DigitalGreenCertificate DigitalCovidCertificate Greenpass Covid Covid19</PackageTags>
1212
<Description>Unofficial implementation of the German rules for validating a Digital Green Certificate</Description>
13-
<Version>2.5.3</Version>
13+
<Version>2.5.4</Version>
1414
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
1515
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>

RuleValidators/DgcReader.RuleValidators.Italy/Const/SettingNames.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public static class SettingNames
2525
public const string VaccineEndDayCompleteNotIT = "vaccine_end_day_complete_NOT_IT";
2626
public const string VaccineStartDayBoosterNotIT = "vaccine_start_day_booster_NOT_IT";
2727
public const string VaccineEndDayBoosterNotIT = "vaccine_end_day_booster_NOT_IT";
28-
29-
public const string VaccineEndDaySchool = "vaccine_end_day_school";
28+
public const string VaccineEndDayCompleteUnder18 = "vaccine_end_day_complete_under_18";
3029

3130
public const string VaccineEndDayCompleteExtendedEMA = "vaccine_end_day_complete_extended_EMA";
3231
public const string EMAVaccines = "EMA_vaccines";
32+
33+
public const string VaccineCompleteUnder18Offset = "vaccine_complete_under_18_offset";
3334
#endregion
3435

3536
#region Test
@@ -49,8 +50,6 @@ public static class SettingNames
4950
public const string RecoveryCertEndDayIT = "recovery_cert_end_day_IT";
5051
public const string RecoveryCertStartDayNotIT = "recovery_cert_start_day_NOT_IT";
5152
public const string RecoveryCertEndDayNotIT = "recovery_cert_end_day_NOT_IT";
52-
53-
public const string RecoveryCertEndDaySchool = "recovery_cert_end_day_school";
5453
#endregion
5554

5655

RuleValidators/DgcReader.RuleValidators.Italy/DgcItalianRulesValidator.cs

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class DgcItalianRulesValidator : IRulesValidator, IBlacklistProvider, ICu
3636
private readonly ILogger? Logger;
3737
private readonly DgcItalianRulesValidatorOptions Options;
3838
private readonly RulesProvider _rulesProvider;
39+
private readonly LibraryVersionCheckProvider _libraryVersionCheckProvider;
3940

4041
#region Implementation of IRulesValidator
4142

@@ -73,6 +74,7 @@ public async Task<IRulesValidationResult> GetRulesValidationResult(EuDGC? dgc,
7374
dgcJson,
7475
validationInstant,
7576
validationMode,
77+
doubleScanMode: false,
7678
signatureValidationResult,
7779
blacklistValidationResult,
7880
cancellationToken);
@@ -143,6 +145,7 @@ public async Task RefreshBlacklist(CancellationToken cancellationToken = default
143145
/// <param name="dgcJson">The RAW json of the DGC</param>
144146
/// <param name="validationInstant"></param>
145147
/// <param name="validationMode">The Italian validation mode to be used</param>
148+
/// <param name="doubleScanMode">If true, enable rules for double checks in <see cref="ValidationMode.Booster"/> mode for test entries</param>
146149
/// <param name="signatureValidationResult">The result from the signature validation step</param>
147150
/// <param name="blacklistValidationResult">The result from the blacklist validation step</param>
148151
/// <param name="cancellationToken"></param>
@@ -151,6 +154,7 @@ public async Task<IRulesValidationResult> GetRulesValidationResult(EuDGC? dgc,
151154
string dgcJson,
152155
DateTimeOffset validationInstant,
153156
ValidationMode validationMode,
157+
bool doubleScanMode = false,
154158
SignatureValidationResult? signatureValidationResult = null,
155159
BlacklistValidationResult? blacklistValidationResult = null,
156160
CancellationToken cancellationToken = default)
@@ -196,7 +200,7 @@ public async Task<IRulesValidationResult> GetRulesValidationResult(EuDGC? dgc,
196200
}
197201

198202
// Checking min version:
199-
CheckMinSdkVersion(rules, validationInstant, validationMode);
203+
await CheckMinSdkVersion(validationInstant, validationMode);
200204

201205
// Preparing model for validators
202206
var certificateModel = new ValidationCertificateModel
@@ -215,7 +219,14 @@ public async Task<IRulesValidationResult> GetRulesValidationResult(EuDGC? dgc,
215219
return result;
216220
}
217221

218-
return validator.CheckCertificate(certificateModel, rules, validationMode);
222+
// See https://github.com/ministero-salute/it-dgc-verificac19-sdk-android/compare/1.1.5...release/1.1.6
223+
if (doubleScanMode && !certificateModel.Dgc.HasTests())
224+
{
225+
result.StatusMessage = "Double scan mode is supported only by Test entries";
226+
result.ItalianStatus = DgcItalianResultStatus.NotValid;
227+
}
228+
229+
return validator.CheckCertificate(certificateModel, rules, validationMode, doubleScanMode);
219230
}
220231
catch (DgcRulesValidationException e)
221232
{
@@ -239,7 +250,7 @@ public async Task<IRulesValidationResult> GetRulesValidationResult(EuDGC? dgc,
239250
{
240251
if (certificateModel.Dgc.HasVaccinations())
241252
return new VaccinationValidator(Logger);
242-
if(certificateModel.Dgc.HasRecoveries())
253+
if (certificateModel.Dgc.HasRecoveries())
243254
return new RecoveryValidator(Logger);
244255
if (certificateModel.Dgc.HasTests())
245256
return new TestValidator(Logger);
@@ -252,44 +263,37 @@ public async Task<IRulesValidationResult> GetRulesValidationResult(EuDGC? dgc,
252263
/// Check the minimum version of the SDK implementation required.
253264
/// If <see cref="DgcItalianRulesValidatorOptions.IgnoreMinimumSdkVersion"/> is false, an exception will be thrown if the implementation is obsolete
254265
/// </summary>
255-
/// <param name="rules"></param>
256266
/// <param name="validationInstant"></param>
257267
/// <param name="validationMode"></param>
268+
/// <param name="cancellation"></param>
258269
/// <exception cref="DgcRulesValidationException"></exception>
259-
private void CheckMinSdkVersion(IEnumerable<RuleSetting> rules, DateTimeOffset validationInstant, ValidationMode validationMode)
270+
private async Task CheckMinSdkVersion(
271+
DateTimeOffset validationInstant,
272+
ValidationMode validationMode,
273+
CancellationToken cancellation = default)
260274
{
261-
var obsolete = false;
262-
string message = string.Empty;
263-
275+
var assemblyName = this.GetType().Assembly.GetName();
276+
Version? latestVersion = null;
264277

265-
var sdkMinVersion = rules.GetRule(SettingNames.SdkMinVersion, SettingTypes.AppMinVersion);
266-
if (sdkMinVersion != null)
278+
// New check: verify library version by checking the GitHub repository
279+
try
267280
{
268-
if (sdkMinVersion.Value.CompareTo(SdkConstants.ReferenceSdkMinVersion) > 0)
281+
latestVersion = await _libraryVersionCheckProvider.GetValueSet(cancellation);
282+
if (latestVersion == null)
269283
{
270-
obsolete = true;
271-
message = $"The minimum version of the SDK implementation is {sdkMinVersion.Value}. " +
272-
$"Please update the package with the latest implementation in order to get a reliable result";
284+
Logger?.LogWarning("Unable to get library version. Skip check");
285+
return;
273286
}
274287
}
275-
else
288+
catch (Exception e)
276289
{
277-
// Fallback to android app version
278-
var appMinVersion = rules.GetRule(SettingNames.AndroidAppMinVersion, SettingTypes.AppMinVersion);
279-
if (appMinVersion != null)
280-
{
281-
if (appMinVersion.Value.CompareTo(SdkConstants.ReferenceAppMinVersion) > 0)
282-
{
283-
obsolete = true;
284-
message = $"The minimum version of the App implementation is {appMinVersion.Value}. " +
285-
$"Please update the package with the latest implementation in order to get a reliable result";
286-
}
287-
}
290+
Logger?.LogWarning("Failed to check library latest release: {errorMessage}", e.Message);
288291
}
289292

290-
if (obsolete)
293+
var currentVersion = assemblyName.Version;
294+
if (latestVersion > currentVersion)
291295
{
292-
296+
var message = $"The current {assemblyName.Name} version ({currentVersion}) is obsolete. Please update the package to the latest version ({latestVersion}) in order to get a reliable result";
293297
if (Options.IgnoreMinimumSdkVersion)
294298
{
295299
Logger?.LogWarning(message);
@@ -325,6 +329,7 @@ public DgcItalianRulesValidator(HttpClient httpClient,
325329
Logger = logger;
326330

327331
_rulesProvider = new RulesProvider(httpClient, Options, logger);
332+
_libraryVersionCheckProvider = new LibraryVersionCheckProvider(httpClient, logger);
328333
}
329334

330335
/// <summary>
@@ -354,6 +359,7 @@ public DgcItalianRulesValidator(HttpClient httpClient,
354359
Logger = logger;
355360

356361
_rulesProvider = new RulesProvider(httpClient, Options, logger);
362+
_libraryVersionCheckProvider = new LibraryVersionCheckProvider(httpClient, logger);
357363
}
358364

359365
/// <summary>

RuleValidators/DgcReader.RuleValidators.Italy/DgcReader.RuleValidators.Italy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<RepositoryUrl>https://github.com/DevTrevi/DGCReader</RepositoryUrl>
1111
<PackageTags>DGC DCC DigitalGreenCertificate DigitalCovidCertificate Greenpass VerificaC19 Covid Covid19</PackageTags>
1212
<Description>Implementation of the Italian rules for validating Digital Green Certificates. This provider is included in the list of verified SDKs by Italian authorities</Description>
13-
<Version>2.5.3</Version>
13+
<Version>2.5.4</Version>
1414
<PackageLicenseExpression> Apache-2.0</PackageLicenseExpression>
1515
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>

0 commit comments

Comments
 (0)