Interface ILegalHoldService
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Service for managing legal holds that block erasure. Implements GDPR Article 17(3) exceptions.
public interface ILegalHoldService
Remarks
Legal holds prevent erasure when data must be retained for:
- Legal claims defense
- Regulatory investigation
- Litigation holds
- Legal obligations under EU/Member State law
Methods
CheckHoldsAsync(string, DataSubjectIdType, string?, CancellationToken)
Checks if a data subject has any active legal holds.
Task<LegalHoldCheckResult> CheckHoldsAsync(string dataSubjectId, DataSubjectIdType idType, string? tenantId, CancellationToken cancellationToken)
Parameters
dataSubjectIdstringThe data subject identifier.
idTypeDataSubjectIdTypeType of the identifier.
tenantIdstringOptional tenant ID.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<LegalHoldCheckResult>
Check result including active holds.
CheckHoldsByHashAsync(string, string?, CancellationToken)
Checks for active holds using an ALREADY-HASHED data-subject identifier.
Task<LegalHoldCheckResult> CheckHoldsByHashAsync(string dataSubjectIdHash, string? tenantId, CancellationToken cancellationToken)
Parameters
dataSubjectIdHashstringThe hashed data-subject identifier, exactly as stored.
tenantIdstringThe tenant, or null to consult every tenant-wide hold.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<LegalHoldCheckResult>
The holds active for that subject, plus any tenant-wide holds.
Remarks
Use this whenever the only identifier you hold is a hash. CheckHoldsAsync(string, DataSubjectIdType, string?, CancellationToken) hashes its argument unconditionally, so passing it a hash queries for a DOUBLE hash against a store keyed on a single one. The hash is HMAC-SHA256 and is not idempotent, so the two can never match and the mismatch is SILENT in the unsafe direction: a subject-specific hold reports as absent and an irreversible erasure proceeds over it.
This is not hypothetical. An erasure retains only the subject HASH once a request is recorded -- the raw identifier is deliberately not kept, because keeping it would defeat the erasure -- so every execute-time hold check has a hash and nothing else. Two members exist so that constraint is visible at the call site instead of being carried in a comment nobody reads.
Both members share one query path, so a hold found by one is found by the other.
CreateHoldAsync(LegalHoldRequest, CancellationToken)
Creates a legal hold for a data subject or tenant.
Task<LegalHold> CreateHoldAsync(LegalHoldRequest request, CancellationToken cancellationToken)
Parameters
requestLegalHoldRequestThe legal hold request details.
cancellationTokenCancellationTokenCancellation token.
Returns
GetHoldAsync(Guid, CancellationToken)
Gets a specific legal hold.
Task<LegalHold?> GetHoldAsync(Guid holdId, CancellationToken cancellationToken)
Parameters
holdIdGuidThe hold ID.
cancellationTokenCancellationTokenCancellation token.
Returns
ListActiveHoldsAsync(string?, CancellationToken)
Lists all active legal holds.
Task<IReadOnlyList<LegalHold>> ListActiveHoldsAsync(string? tenantId, CancellationToken cancellationToken)
Parameters
tenantIdstringOptional tenant filter.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<LegalHold>>
List of active legal holds.
ReleaseHoldAsync(Guid, string, string, CancellationToken)
Releases a legal hold.
Task ReleaseHoldAsync(Guid holdId, string reason, string releasedBy, CancellationToken cancellationToken)
Parameters
holdIdGuidThe hold ID to release.
reasonstringReason for release.
releasedBystringWho is releasing the hold.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Releasing is a read-modify-write, and it refuses to write over a hold that changed underneath it. If the hold was modified between this call reading it and writing the release — most importantly, if its expiry was extended — the release is not applied and LegalHoldConcurrencyException is raised. Re-read the hold and decide again; a hold that is no longer due for release should not be released.
Exceptions
- KeyNotFoundException
No hold with that identifier exists, or it was deleted while this call was releasing it.
- InvalidOperationException
The hold has already been released.
- LegalHoldConcurrencyException
The hold was modified concurrently. Nothing was written.