Table of Contents

Class CapabilityGrantValidationResult

Namespace
AsiBackbone.Core.CapabilityGrants
Assembly
AsiBackbone.Core.dll

Represents the outcome of validating a capability grant, including the policy action the host should take.

public sealed class CapabilityGrantValidationResult
Inheritance
CapabilityGrantValidationResult
Inherited Members

Remarks

Hosts should gate execution on ShouldAllow rather than IsValid alone, and act on Action for failed results, because some failures defer or require acknowledgment instead of denying.

Properties

Action

Gets the policy action the host should take for this result.

public VerificationPolicyAction Action { get; }

Property Value

VerificationPolicyAction

Category

Gets the validation category that describes why the grant passed or failed.

public CapabilityGrantValidationCategory Category { get; }

Property Value

CapabilityGrantValidationCategory

FailureCode

Gets the machine-readable failure code, such as capability.expired, when validation failed.

public string? FailureCode { get; }

Property Value

string

FailureMessage

Gets the human-readable failure message, when one was supplied.

public string? FailureMessage { get; }

Property Value

string

IsValid

Gets a value indicating whether the grant satisfied every configured validation check.

public bool IsValid { get; }

Property Value

bool

SafeMetadata

Gets non-secret grant and outcome metadata, such as issuer, audience, policy action, and failure code, that is safe to log or attach to audit records.

public IReadOnlyDictionary<string, string> SafeMetadata { get; }

Property Value

IReadOnlyDictionary<string, string>

ShouldAllow

Gets a value indicating whether the host may proceed with the governed operation.

public bool ShouldAllow { get; }

Property Value

bool

Status

Gets the result status, either Valid or Failed.

public string Status { get; }

Property Value

string

TokenId

Gets the token identifier of the validated grant.

public string TokenId { get; }

Property Value

string

Methods

Failed(CapabilityGrant, CapabilityGrantValidationCategory, VerificationPolicyAction, string, string?)

Creates a failed result with the category and policy action the host should apply.

public static CapabilityGrantValidationResult Failed(CapabilityGrant grant, CapabilityGrantValidationCategory category, VerificationPolicyAction action, string failureCode, string? failureMessage = null)

Parameters

grant CapabilityGrant

The grant that failed validation.

category CapabilityGrantValidationCategory

The validation category that describes the failure.

action VerificationPolicyAction

The policy action the host should take, such as deny, defer, or require acknowledgment.

failureCode string

The machine-readable failure code.

failureMessage string

An optional human-readable failure message.

Returns

CapabilityGrantValidationResult

A failed result.

Exceptions

ArgumentNullException

grant or failureCode is null.

ArgumentException

failureCode is empty or whitespace.

ArgumentOutOfRangeException

category or action is not a defined value.

Valid(CapabilityGrant)

Creates a successful result that allows the governed operation.

public static CapabilityGrantValidationResult Valid(CapabilityGrant grant)

Parameters

grant CapabilityGrant

The grant that passed validation.

Returns

CapabilityGrantValidationResult

A valid result with Allow.

Exceptions

ArgumentNullException

grant is null.