| | 1 | | using System.Diagnostics.CodeAnalysis; |
| | 2 | | using System.Text.Json.Serialization; |
| | 3 | | using Spdx3.Model.Core.Enums; |
| | 4 | | using Spdx3.Serialization; |
| | 5 | | using Spdx3.Utility; |
| | 6 | |
|
| | 7 | | namespace Spdx3.Model.Core.Classes; |
| | 8 | |
|
| | 9 | | /// <summary> |
| | 10 | | /// A verification method for software packages. |
| | 11 | | /// See https://spdx.github.io/spdx-spec/v3.0.1/model/Core/Classes/PackageVerificationCode/ |
| | 12 | | /// </summary> |
| | 13 | | public class PackageVerificationCode : IntegrityMethod |
| | 14 | | { |
| | 15 | | [JsonPropertyName("algorithm")] |
| | 16 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 20 | 17 | | public HashAlgorithm Algorithm { get; set; } |
| | 18 | |
|
| | 19 | | [JsonPropertyName("hashValue")] |
| | 20 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 20 | 21 | | public string HashValue { get; set; } |
| | 22 | |
|
| | 23 | | [JsonPropertyName("packageVerificationCodeExcludedFile")] |
| | 24 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 15 | 25 | | public IList<string> PackageVerificationCodeExcludedFile { get; } = new List<string>(); |
| | 26 | |
|
| | 27 | | // protected internal no-parm constructor required for deserialization |
| | 28 | | // ReSharper disable once UnusedMember.Global |
| | 29 | | #pragma warning disable CS8618, CS9264 |
| 2 | 30 | | protected internal PackageVerificationCode() |
| | 31 | | { |
| 2 | 32 | | } |
| | 33 | | #pragma warning restore CS8618, CS9264 |
| | 34 | |
|
| | 35 | | [SetsRequiredMembers] |
| 5 | 36 | | public PackageVerificationCode(Catalog catalog, HashAlgorithm algorithm, string hashValue) : base(catalog) |
| | 37 | | { |
| 5 | 38 | | Algorithm = algorithm; |
| 5 | 39 | | HashValue = hashValue; |
| 5 | 40 | | } |
| | 41 | |
|
| | 42 | | public override void Validate() |
| | 43 | | { |
| 5 | 44 | | base.Validate(); |
| 4 | 45 | | ValidateRequiredProperty(nameof(Algorithm)); |
| 4 | 46 | | ValidateRequiredProperty(nameof(HashValue)); |
| 2 | 47 | | } |
| | 48 | | } |