Class IsolatingOutboxStoreDecorator
Base class for outbox store decorators that impose an invariant on the messages passing through them -- encryption, redaction, tenant scoping -- and must therefore never hand a caller unmediated access to the store they wrap.
public abstract class IsolatingOutboxStoreDecorator : OutboxStoreDecorator, IOutboxStore, IServiceProvider
- Inheritance
-
IsolatingOutboxStoreDecorator
- Implements
- Inherited Members
- Extension Methods
Remarks
OutboxStoreDecorator forwards every capability it does not itself implement to the decorated store. For an observational decorator, one whose invariant is empty, that is correct and safe: a telemetry decorator has nothing to protect, so passing a capability through preserves it losslessly. For a transforming decorator the same forwarding is a bypass. A caller that asks a decorated store for a capability and receives the undecorated store beneath it has been handed the plaintext the decorator exists to prevent, and has been handed it by the very object that promised to prevent it.
Capability resolution here is therefore deny-by-default. A capability is reachable through this decorator only when the decorator has explicitly said how: either it wraps the capability, by returning a view that upholds the invariant (see WrapCapability(Type)), or it forwards the capability, by naming it in ForwardableCapabilities as one whose surface cannot carry a protected payload. Everything else resolves to null.
The default is empty, and the failure mode is loud. A capability that is neither wrapped nor forwarded becomes unobtainable rather than unprotected: the caller sees null and cannot proceed, instead of seeing a working object that quietly returns ciphertext or accepts plaintext. A confidentiality boundary is not a place to trade a silent leak for a silent absence of one.
GetService(Type) is sealed. A derived decorator cannot reopen unconditional forwarding by overriding it, so "I forgot to wrap the ninth capability" is expressible only as a null, never as a leak. The next capability added to this codebase is denied by this type before anyone has read it.
Constructors
IsolatingOutboxStoreDecorator(IOutboxStore)
Base class for outbox store decorators that impose an invariant on the messages passing through them -- encryption, redaction, tenant scoping -- and must therefore never hand a caller unmediated access to the store they wrap.
protected IsolatingOutboxStoreDecorator(IOutboxStore inner)
Parameters
innerIOutboxStoreThe store being decorated.
Remarks
OutboxStoreDecorator forwards every capability it does not itself implement to the decorated store. For an observational decorator, one whose invariant is empty, that is correct and safe: a telemetry decorator has nothing to protect, so passing a capability through preserves it losslessly. For a transforming decorator the same forwarding is a bypass. A caller that asks a decorated store for a capability and receives the undecorated store beneath it has been handed the plaintext the decorator exists to prevent, and has been handed it by the very object that promised to prevent it.
Capability resolution here is therefore deny-by-default. A capability is reachable through this decorator only when the decorator has explicitly said how: either it wraps the capability, by returning a view that upholds the invariant (see WrapCapability(Type)), or it forwards the capability, by naming it in ForwardableCapabilities as one whose surface cannot carry a protected payload. Everything else resolves to null.
The default is empty, and the failure mode is loud. A capability that is neither wrapped nor forwarded becomes unobtainable rather than unprotected: the caller sees null and cannot proceed, instead of seeing a working object that quietly returns ciphertext or accepts plaintext. A confidentiality boundary is not a place to trade a silent leak for a silent absence of one.
GetService(Type) is sealed. A derived decorator cannot reopen unconditional forwarding by overriding it, so "I forgot to wrap the ninth capability" is expressible only as a null, never as a leak. The next capability added to this codebase is denied by this type before anyone has read it.
Properties
ForwardableCapabilities
Gets the capabilities this decorator permits to be resolved directly from the decorated store, without mediation.
protected virtual IReadOnlySet<Type> ForwardableCapabilities { get; }
Property Value
- IReadOnlySet<Type>
The set of capability interfaces whose every member is free of protected payload. Empty by default: a capability is forwarded only when a derived decorator has affirmatively established that passing it through cannot breach the decorator's invariant.
Remarks
Establish this per member, not per name. An interface qualifies only when no member of it -- including members it inherits from base interfaces, which GetMethods() does not report -- accepts or returns a protected payload.
Methods
GetService(Type)
Resolves a capability, denying by default anything this decorator neither wraps nor has declared forwardable.
public override sealed object? GetService(Type serviceType)
Parameters
serviceTypeTypeThe capability interface to resolve.
Returns
- object
This decorator when it implements
serviceType; a mediating view when this decorator wraps it; the decorated store's capability when it is forwardable; otherwise null.
Exceptions
- ArgumentNullException
Thrown when
serviceTypeis null.
WrapCapability(Type)
Returns a view over the decorated store's capability that upholds this decorator's invariant, when the decorator knows how to build one.
protected virtual object? WrapCapability(Type serviceType)
Parameters
serviceTypeTypeThe capability interface being resolved.
Returns
- object
A mediating view over the decorated store's capability; or null when this decorator does not wrap
serviceType, or when the decorated store does not provide it.
Remarks
Return null when the decorated store lacks the capability -- never a view over nothing. A caller reads a non-null result as a promise that the operation will be performed.