Table of Contents

Interface IElasticsearchFieldEncryption

Namespace
Excalibur.Data.ElasticSearch.Security
Assembly
Excalibur.Data.ElasticSearch.dll

Defines core field-level encryption and decryption operations for Elasticsearch documents.

public interface IElasticsearchFieldEncryption

Remarks

Documents and field values cross this contract as object, so every implementation has to serialize a value whose type is not known until run time. That is reflection-based serialization, and the members below are annotated accordingly: the requirement belongs to the contract, not to one implementation, and a caller resolving this interface from the container is told about it at the call site.

Properties

SupportedAlgorithms

Gets the encryption algorithms supported by this encryptor.

IReadOnlyCollection<string> SupportedAlgorithms { get; }

Property Value

IReadOnlyCollection<string>

A collection of supported encryption algorithm names.

Methods

DecryptDocumentAsync(object, CancellationToken)

Decrypts encrypted field values within an Elasticsearch document to restore original data.

[RequiresUnreferencedCode("Restoring field values requires reflection over the document's members, which trimming may remove.")]
[RequiresDynamicCode("Restoring field values generates deserialization code for the document's types at run time.")]
Task<object> DecryptDocumentAsync(object encryptedDocument, CancellationToken cancellationToken)

Parameters

encryptedDocument object

The document containing encrypted fields to be decrypted.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<object>

A task that represents the asynchronous operation. The task result contains the document with encrypted fields decrypted to their original values.

Exceptions

SecurityException

Thrown when decryption fails due to security constraints.

ArgumentNullException

Thrown when the document is null.

DecryptFieldAsync(string, EncryptedFieldResult, CancellationToken)

Decrypts a specific encrypted field value to restore the original data.

[RequiresUnreferencedCode("Restoring the field value requires reflection over its type's members, which trimming may remove.")]
[RequiresDynamicCode("Restoring the field value generates deserialization code for its type at run time.")]
Task<object> DecryptFieldAsync(string fieldName, EncryptedFieldResult encryptedField, CancellationToken cancellationToken)

Parameters

fieldName string

The name of the field being decrypted.

encryptedField EncryptedFieldResult

The encrypted field data containing the encrypted value and metadata.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<object>

A task that represents the asynchronous operation. The task result contains the decrypted original value.

Exceptions

SecurityException

Thrown when field decryption fails due to security constraints.

ArgumentException

Thrown when field name or encrypted data is invalid.

EncryptDocumentAsync(object, CancellationToken)

Encrypts sensitive field values within an Elasticsearch document based on data classification rules.

[RequiresUnreferencedCode("Serializing the document requires reflection over its members, which trimming may remove.")]
[RequiresDynamicCode("Serializing the document generates serialization code for its type at run time.")]
Task<object> EncryptDocumentAsync(object document, CancellationToken cancellationToken)

Parameters

document object

The document containing fields to be encrypted.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<object>

A task that represents the asynchronous operation. The task result contains the document with sensitive fields encrypted according to security policies.

Exceptions

SecurityException

Thrown when encryption fails due to security constraints.

ArgumentNullException

Thrown when the document is null.

EncryptFieldAsync(string, object, ElasticSearchDataClassification, CancellationToken)

Encrypts a specific field value using the appropriate encryption algorithm and key.

[RequiresUnreferencedCode("Serializing the field value requires reflection over its type's members, which trimming may remove.")]
[RequiresDynamicCode("Serializing the field value generates serialization code for its type at run time.")]
Task<EncryptedFieldResult> EncryptFieldAsync(string fieldName, object fieldValue, ElasticSearchDataClassification classification, CancellationToken cancellationToken)

Parameters

fieldName string

The name of the field being encrypted.

fieldValue object

The value to encrypt.

classification ElasticSearchDataClassification

The data classification level for the field.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<EncryptedFieldResult>

A task that represents the asynchronous operation. The task result contains the encrypted field result including the encrypted value and metadata.

Exceptions

SecurityException

Thrown when field encryption fails due to security constraints.

ArgumentException

Thrown when field name or value is invalid.