|
| 1 | +namespace Sigtran.NET.Core.Utilities; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Describes filesystem-backed commercial evidence publication attachment execution. |
| 5 | +/// </summary> |
| 6 | +public sealed class SigtranCommercialEvidenceFileSystemPublicationAttachmentExecution |
| 7 | +{ |
| 8 | + /// <summary>Creates filesystem-backed publication attachment execution.</summary> |
| 9 | + /// <param name="sealExecution">The filesystem-backed integrity seal execution.</param> |
| 10 | + /// <param name="attachmentManifest">The publication attachment manifest created from the seal.</param> |
| 11 | + public SigtranCommercialEvidenceFileSystemPublicationAttachmentExecution( |
| 12 | + SigtranCommercialEvidenceFileSystemIntegritySealExecution sealExecution, |
| 13 | + SigtranCommercialEvidencePublicationAttachmentManifest attachmentManifest) |
| 14 | + { |
| 15 | + SealExecution = sealExecution ?? throw new ArgumentNullException(nameof(sealExecution)); |
| 16 | + AttachmentManifest = attachmentManifest ?? throw new ArgumentNullException(nameof(attachmentManifest)); |
| 17 | + } |
| 18 | + |
| 19 | + /// <summary>The filesystem-backed integrity seal execution.</summary> |
| 20 | + public SigtranCommercialEvidenceFileSystemIntegritySealExecution SealExecution { get; } |
| 21 | + |
| 22 | + /// <summary>The publication attachment manifest created from the seal.</summary> |
| 23 | + public SigtranCommercialEvidencePublicationAttachmentManifest AttachmentManifest { get; } |
| 24 | + |
| 25 | + /// <summary>Whether the source integrity seal execution is ready.</summary> |
| 26 | + public bool SealReady => SealExecution.IsReady; |
| 27 | + |
| 28 | + /// <summary>Whether the attachment manifest references the current filesystem-backed seal.</summary> |
| 29 | + public bool UsesCurrentIntegritySeal => string.Equals(AttachmentManifest.Seal.SealId, SealExecution.Seal.SealId, StringComparison.Ordinal) |
| 30 | + && string.Equals(AttachmentManifest.Seal.AggregateSha256, SealExecution.Seal.AggregateSha256, StringComparison.OrdinalIgnoreCase); |
| 31 | + |
| 32 | + /// <summary>Whether attachments cover every sealed ledger entry.</summary> |
| 33 | + public bool CoversSealedLedgerEntries => AttachmentManifest.CoversSealedLedgerEntries; |
| 34 | + |
| 35 | + /// <summary>Whether trace-bearing attachments have approved redaction state.</summary> |
| 36 | + public bool ProtectsTraceBearingArtifacts => AttachmentManifest.ProtectsTraceBearingArtifacts; |
| 37 | + |
| 38 | + /// <summary>Whether all attachments are safe for publication.</summary> |
| 39 | + public bool AllAttachmentsSafeForPublication => AttachmentManifest.AllAttachmentsSafeForPublication; |
| 40 | + |
| 41 | + /// <summary>Whether filesystem-backed publication attachment execution is ready for promotion evaluation.</summary> |
| 42 | + public bool IsReady => SealReady |
| 43 | + && UsesCurrentIntegritySeal |
| 44 | + && AttachmentManifest.IsReady |
| 45 | + && CoversSealedLedgerEntries |
| 46 | + && ProtectsTraceBearingArtifacts |
| 47 | + && AllAttachmentsSafeForPublication; |
| 48 | + |
| 49 | + /// <summary>Formats a compact filesystem publication attachment execution summary.</summary> |
| 50 | + /// <returns>The filesystem publication attachment execution summary.</returns> |
| 51 | + public string Describe() |
| 52 | + { |
| 53 | + return $"commercialEvidenceFileSystemPublicationAttachmentsReady={IsReady} attachments={AttachmentManifest.Attachments.Count}"; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +/// <summary> |
| 58 | +/// Provides filesystem-backed commercial evidence publication attachment helpers. |
| 59 | +/// </summary> |
| 60 | +public static class SigtranCommercialEvidenceFileSystemPublicationAttachments |
| 61 | +{ |
| 62 | + /// <summary>Creates publication attachments from a filesystem-backed integrity seal execution.</summary> |
| 63 | + /// <param name="sealExecution">The filesystem-backed integrity seal execution.</param> |
| 64 | + /// <param name="publishable">Whether attachments can be included in a release dossier.</param> |
| 65 | + /// <param name="redactionApproved">Whether trace-bearing attachment redaction is approved.</param> |
| 66 | + /// <returns>The filesystem-backed publication attachment execution.</returns> |
| 67 | + public static SigtranCommercialEvidenceFileSystemPublicationAttachmentExecution Create( |
| 68 | + SigtranCommercialEvidenceFileSystemIntegritySealExecution sealExecution, |
| 69 | + bool publishable = true, |
| 70 | + bool redactionApproved = true) |
| 71 | + { |
| 72 | + ArgumentNullException.ThrowIfNull(sealExecution); |
| 73 | + SigtranCommercialEvidencePublicationAttachmentManifest manifest = SigtranCommercialEvidencePublicationAttachments.CreateDefault( |
| 74 | + sealExecution.Seal, |
| 75 | + publishable, |
| 76 | + redactionApproved); |
| 77 | + |
| 78 | + return new(sealExecution, manifest); |
| 79 | + } |
| 80 | +} |
0 commit comments