Class ActivityGroupGrantSnapshot
- Namespace
- Excalibur.A3.Authorization
- Assembly
- Excalibur.A3.Abstractions.dll
A validated set of activity-group grants that IActivityGroupGrantReplacement makes current.
public sealed class ActivityGroupGrantSnapshot
- Inheritance
-
ActivityGroupGrantSnapshot
- Inherited Members
Remarks
Construction is the validation. A store is only ever handed a snapshot whose every term has already been checked, so no store can apply an input another store would refuse, and nothing is checked after a lock has been taken or a row removed.
- Every required term is present and carries no leading or trailing whitespace.
SQL Server ignores trailing spaces when it compares keys, so
"Support"and"Support "are one qualifier there and two everywhere else. Refusing the whitespace makes a snapshot mean the same thing on every provider. FullName and GrantedBy are the two optional terms — neither is part of a grant's identity, and an authority that sends no display name is not sending a malformed row. - It is a set. A repeated (user, tenant, grant type, qualifier) key — the identity every store writes a grant under — is kept once, in the order it first appeared, rather than refused.
Emptiness is NOT decided here, because it does not have one answer. An empty ESTATE-WIDE snapshot is far more likely a failed fetch than a true state, and applying it would revoke every user's activity-group grants at once; an empty PER-USER snapshot is an ordinary state — that user now holds none, and every one of theirs must be revoked. The two replaces therefore validate the snapshot differently, through ValidateAsEstateReplacement(ActivityGroupGrantSnapshot, string) and ValidateAsUserReplacement(ActivityGroupGrantSnapshot, string, string), which is where that asymmetry is written down once instead of being re-derived per store.
Constructors
ActivityGroupGrantSnapshot(IEnumerable<ActivityGroupGrantEntry>)
Initializes a new instance of the ActivityGroupGrantSnapshot class.
public ActivityGroupGrantSnapshot(IEnumerable<ActivityGroupGrantEntry> entries)
Parameters
entriesIEnumerable<ActivityGroupGrantEntry>The grants that are to be current after the replace. May be empty.
Exceptions
- ArgumentNullException
Thrown when
entriesis null.- ArgumentException
Thrown when any entry has a missing or whitespace-padded term, or a tenant longer than MaxLength. The message names the entry and the term.
Properties
Entries
Gets the snapshot's entries.
public IReadOnlyList<ActivityGroupGrantEntry> Entries { get; }
Property Value
- IReadOnlyList<ActivityGroupGrantEntry>
Each distinct grant once, in the order it first appeared. May be empty.
UserIds
Gets the distinct users the snapshot grants to.
public IReadOnlyCollection<string> UserIds { get; }
Property Value
- IReadOnlyCollection<string>
Each user once, in the order it first appears. May be empty.
Methods
ValidateAsEstateReplacement(ActivityGroupGrantSnapshot, string)
Checks the preconditions of an ESTATE-WIDE replace, before any lock is taken or row removed.
public static void ValidateAsEstateReplacement(ActivityGroupGrantSnapshot snapshot, string grantType)
Parameters
snapshotActivityGroupGrantSnapshotThe snapshot the replace was given.
grantTypestringThe grant type the replace is scoped to.
Remarks
Empty is refused. An estate-wide replace with nothing in it revokes every user's grants of that type, and an empty result from an authority cannot be told apart from an upstream filter, an authorization scope or a schema change returning nothing. Emptying the estate is an explicit act — the caller deletes by name — and never the result of passing nothing.
A mixed snapshot is refused whole. The replace removes the rows carrying
grantType and writes the snapshot in their place, so a row of another type would be
written without its own type's rows having been removed — a partial application of two replaces at
once. Refusing here means nothing is deleted.
Exceptions
- ArgumentNullException
Thrown when
snapshotis null.- ArgumentException
Thrown when
grantTypeis missing, when the snapshot is empty, or when any entry carries a different grant type.
ValidateAsUserReplacement(ActivityGroupGrantSnapshot, string, string)
Checks the preconditions of a PER-USER replace, before any lock is taken or row removed.
public static void ValidateAsUserReplacement(ActivityGroupGrantSnapshot snapshot, string userId, string grantType)
Parameters
snapshotActivityGroupGrantSnapshotThe snapshot the replace was given.
userIdstringThe user the replace is scoped to.
grantTypestringThe grant type the replace is scoped to.
Remarks
Empty is ACCEPTED here, and that difference is deliberate. A user who now holds no activity-group grants is an ordinary state, and every grant they held must be revoked; refusing the empty snapshot would keep revoked access alive. What must never reach this method is a FETCH THAT FAILED — that is a failure and its caller must raise it as one, never hand it on as an empty set.
Exceptions
- ArgumentNullException
Thrown when
snapshotis null.- ArgumentException
Thrown when
userIdorgrantTypeis missing, or when any entry carries a different user or grant type.