Struct KeySubject
- Namespace
- Stratara.Abstractions.Security
- Assembly
- Stratara.Abstractions.dll
A tenant or a user whose erasure a key store records, so that it creates no key for the subject afterwards. Covers(KeyScope) decides which scopes that is — the same keys the subject's erasure shreds.
public readonly record struct KeySubject : IEquatable<KeySubject>
- Implements
- Inherited Members
- Extension Methods
Remarks
Two subjects are equal when their kind matches and their ids match without regard to case, the same comparison Covers(KeyScope) uses, so a set of subjects holds each one once.
Properties
Id
The subject's id, as it appears in a KeyScope; empty on the default value, which names no subject.
public string Id { get; }
Property Value
Kind
Whether the subject is a tenant or a user.
public KeySubjectKind Kind { get; }
Property Value
Methods
Covers(KeyScope)
Whether the subject's erasure covers a scope: for a tenant, a scope of any level that names the tenant; for a user, a UserScoped scope that names the user, and a scope of any level that names the user and no tenant of theirs — no tenant, or the reserved default tenant (Empty) under which data owned by the user alone is written. Ids compare without regard to case, so a GUID written in either case is matched. The default value names no subject and covers nothing.
public bool Covers(KeyScope scope)
Parameters
scopeKeyScopeThe scope to test.
Returns
Equals(KeySubject)
Whether both name the same subject: the same kind, and ids equal without regard to case.
public bool Equals(KeySubject other)
Parameters
otherKeySubjectThe subject to compare with.
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Tenant(string)
Names a tenant.
public static KeySubject Tenant(string tenantId)
Parameters
Returns
- KeySubject
The tenant subject.
Exceptions
- ArgumentException
tenantIdis empty or white space.- ArgumentNullException
tenantIdis null.
ThrowIfDefault(string)
Throws when the value is the default one, which names no subject.
public void ThrowIfDefault(string paramName)
Parameters
paramNamestringThe name of the parameter that carried the subject.
Exceptions
- ArgumentException
The subject was not created through Tenant(string) or User(string).
User(string)
Names a user.
public static KeySubject User(string userId)
Parameters
Returns
- KeySubject
The user subject.
Exceptions
- ArgumentException
userIdis empty or white space.- ArgumentNullException
userIdis null.