Table of Contents

Class PersonalDataAttribute

Namespace
Excalibur.Compliance
Assembly
Excalibur.Compliance.Abstractions.dll

Classifies a property as containing personal data subject to GDPR and privacy regulations.

[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class PersonalDataAttribute : Attribute
Inheritance
PersonalDataAttribute
Inherited Members

Examples

 // Encrypted at rest only when crypto-shredding is registered and this type is persisted
 // through one of the framework's encrypting stores. Both annotated properties are writable
 // strings, which is what the encryption path can act on; the subject id names the key.
public class Customer
{
[DataSubjectId]
public Guid Id { get; set; }

[PersonalData(Category = PersonalDataCategory.ContactInfo)]
public string Email { get; set; }

[PersonalData(Category = PersonalDataCategory.Identity)]
public string SocialSecurityNumber { get; set; }

 // Classified, but NOT encrypted: an int is not an encryptable property type.
[PersonalData(Category = PersonalDataCategory.Identity)]
public int NationalIdNumber { get; set; }
}

Remarks

This attribute classifies a property. On its own it changes no behaviour: applying it does not encrypt, mask, audit or erase anything. It is the selector that the features below consult, and each of those features must itself be registered before it reads the annotation.

Encryption at rest is applied by the framework's encrypting store decorators -- the event store, the projection store, the inbox store and the outbox store -- and only when all of the following hold: the declaring type also carries DataSubjectIdAttribute on the property that identifies the subject, whose value is what the per-subject key is derived from; crypto-shredding is registered, so that key exists; the record is written through one of those four stores rather than by your own persistence code; and the annotated property is a readable and writable string or byte array. A property of any other type, or with no setter, is not encrypted and no diagnostic is raised -- for such a property this attribute is classification metadata only. If a type carrying DataSubjectIdAttribute resolves no encryptable annotated property at all, the framework refuses to persist it rather than store personal data in the clear.

Masking in logs and error messages is applied by a registered masker. Retention and right-to-erasure read the annotation to determine which properties of a declared aggregate type are in scope. None of these registers a data location on your behalf: the annotation says a property holds personal data, not where that data is stored.

Properties

Category

Gets or sets the category of personal data for policy selection.

public PersonalDataCategory Category { get; set; }

Property Value

PersonalDataCategory

IsSensitive

Gets or sets a value indicating whether this data is considered sensitive personal data under GDPR Article 9 (racial origin, health data, biometrics, etc.).

public bool IsSensitive { get; set; }

Property Value

bool

LegalBasis

Gets or sets the legal basis for processing this personal data.

public LegalBasis LegalBasis { get; set; }

Property Value

LegalBasis

MaskInLogs

Gets or sets a value indicating whether this data should be masked in logs. Defaults to true.

public bool MaskInLogs { get; set; }

Property Value

bool

Purpose

Gets or sets the purpose for collecting this personal data. Used for GDPR documentation and data subject requests.

public string? Purpose { get; set; }

Property Value

string

RetentionDays

Gets or sets the retention period in days. After this period, the data should be anonymized or deleted. Zero means indefinite retention (not recommended).

public int RetentionDays { get; set; }

Property Value

int