< Summary

Information
Class: AsiBackbone.Core.CapabilityGrants.CapabilityGrantValidationOptions
Assembly: AsiBackbone.Core
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/CapabilityGrants/CapabilityGrantValidationOptions.cs
Line coverage
98%
Covered lines: 179
Uncovered lines: 3
Coverable lines: 182
Total lines: 567
Line coverage: 98.3%
Branch coverage
91%
Covered branches: 22
Total branches: 24
Branch coverage: 91.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor(...)92.86%141495.52%
Create(...)100%11100%
WithExpectedBindings(...)75%44100%
WithExpectedBindingsCore(...)100%11100%
CreateExecutionBoundary(...)100%11100%
CreateBoundExecutionBoundary(...)100%11100%
CreateMetadataValidation(...)100%11100%
NormalizeScopes(...)100%44100%
NormalizeOptional(...)100%22100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/CapabilityGrants/CapabilityGrantValidationOptions.cs

#LineLine coverage
 1using AsiBackbone.Core.Signing;
 2
 3namespace AsiBackbone.Core.CapabilityGrants;
 4
 5/// <summary>
 6/// Describes the expectations a capability grant is validated against by <see cref="CapabilityGrantValidator" />.
 7/// </summary>
 8/// <remarks>
 9/// <para>
 10/// Each optional expectation is checked only when it is set; string comparisons are ordinal, and blank values are
 11/// treated as absent. Choose a factory that matches the validation context:
 12/// <see cref="CreateBoundExecutionBoundary" /> for an execution boundary that requires proof and binds the grant to
 13/// the authenticated subject, <see cref="CreateMetadataValidation" /> for proof-free inspection of grant metadata, and
 14/// <see cref="Create" /> for a fully custom profile.
 15/// </para>
 16/// <para>
 17/// Requiring proof or a use check without an audience expectation is rejected, because proof alone does not establish
 18/// that the grant was issued for this audience.
 19/// </para>
 20/// </remarks>
 21public sealed class CapabilityGrantValidationOptions
 22{
 123    private static readonly string[] EmptyScopes = [];
 24
 25925    private CapabilityGrantValidationOptions(
 25926        string? issuer,
 25927        string? audience,
 25928        IReadOnlyList<string> scopes,
 25929        DateTimeOffset? validationUtc,
 25930        TimeSpan allowedClockSkew,
 25931        string? policyVersion,
 25932        string? policyHash,
 25933        string? acknowledgmentId,
 25934        string? handshakeId,
 25935        string? gatewayBinding,
 25936        string? resourceBinding,
 25937        string? expectedSubjectId,
 25938        string? expectedOperationName,
 25939        bool requireSubjectBinding,
 25940        bool requireProof,
 25941        bool requireAcknowledgmentReference,
 25942        bool requireUseCheck,
 25943        int maxUseCount,
 25944        string? expectedProofKeyId,
 25945        string? expectedProofKeyVersion,
 25946        string? expectedProofPolicyVersion,
 25947        string? expectedProofPolicyHash,
 25948        string? requiredProofProvider,
 25949        string? requiredProofHashAlgorithm,
 25950        CanonicalPayloadOptions? proofPayloadOptions)
 51    {
 25952        if (allowedClockSkew < TimeSpan.Zero)
 53        {
 154            throw new ArgumentOutOfRangeException(
 155                nameof(allowedClockSkew),
 156                allowedClockSkew,
 157                "Allowed clock skew must be greater than or equal to zero.");
 58        }
 59
 25860        if (maxUseCount < 1)
 61        {
 162            throw new ArgumentOutOfRangeException(nameof(maxUseCount), maxUseCount, "Maximum use count must be greater t
 63        }
 64
 65        // A grant can be proof-verified and still be the wrong grant for this caller. Without an audience expectation a
 66        // grant issued for one gateway validates at another, so requiring proof or a use check without stating the
 67        // audience is a configuration that cannot deliver what it appears to promise.
 25768        if ((requireProof || requireUseCheck) && string.IsNullOrWhiteSpace(audience))
 69        {
 370            throw new ArgumentException(
 371                "An audience expectation is required when proof or use checking is required, because proof alone does no
 372                nameof(audience));
 73        }
 74
 25475        Issuer = NormalizeOptional(issuer);
 25476        Audience = NormalizeOptional(audience);
 25477        Scopes = scopes;
 25478        ValidationUtc = validationUtc?.ToUniversalTime();
 25479        AllowedClockSkew = allowedClockSkew;
 25480        PolicyVersion = NormalizeOptional(policyVersion);
 25481        PolicyHash = NormalizeOptional(policyHash);
 25482        AcknowledgmentId = NormalizeOptional(acknowledgmentId);
 25483        HandshakeId = NormalizeOptional(handshakeId);
 25484        GatewayBinding = NormalizeOptional(gatewayBinding);
 25485        ResourceBinding = NormalizeOptional(resourceBinding);
 25486        ExpectedSubjectId = NormalizeOptional(expectedSubjectId);
 25487        if (requireSubjectBinding && ExpectedSubjectId is null)
 88        {
 089            throw new ArgumentException(
 090                "A subject expectation is required for this validation profile.",
 091                nameof(expectedSubjectId));
 92        }
 93
 25494        ExpectedOperationName = NormalizeOptional(expectedOperationName);
 25495        RequireSubjectBinding = requireSubjectBinding;
 25496        RequireProof = requireProof;
 25497        RequireAcknowledgmentReference = requireAcknowledgmentReference;
 25498        RequireUseCheck = requireUseCheck;
 25499        MaxUseCount = maxUseCount;
 254100        ExpectedProofKeyId = NormalizeOptional(expectedProofKeyId);
 254101        ExpectedProofKeyVersion = NormalizeOptional(expectedProofKeyVersion);
 254102        ExpectedProofPolicyVersion = NormalizeOptional(expectedProofPolicyVersion);
 254103        ExpectedProofPolicyHash = NormalizeOptional(expectedProofPolicyHash);
 254104        RequiredProofProvider = NormalizeOptional(requiredProofProvider);
 254105        RequiredProofHashAlgorithm = NormalizeOptional(requiredProofHashAlgorithm);
 254106        ProofPayloadOptions = proofPayloadOptions;
 254107    }
 108
 109    /// <summary>
 110    /// Gets the issuer the grant must name, when an issuer expectation is configured.
 111    /// </summary>
 112    public string? Issuer { get; }
 113
 114    /// <summary>
 115    /// Gets the audience the grant must name, when an audience expectation is configured.
 116    /// </summary>
 117    /// <remarks>
 118    /// An audience is required whenever <see cref="RequireProof" /> or <see cref="RequireUseCheck" /> is set.
 119    /// </remarks>
 120    public string? Audience { get; }
 121
 122    /// <summary>
 123    /// Gets the scopes the grant must contain, trimmed, de-duplicated, and sorted ordinally.
 124    /// </summary>
 125    /// <remarks>
 126    /// The grant may carry additional scopes. An empty list disables the scope check.
 127    /// </remarks>
 128    public IReadOnlyList<string> Scopes { get; }
 129
 130    /// <summary>
 131    /// Gets the UTC instant used to evaluate the grant validity window, or <see langword="null" /> to use the current
 132    /// time.
 133    /// </summary>
 134    public DateTimeOffset? ValidationUtc { get; }
 135
 136    /// <summary>
 137    /// Gets the non-negative tolerance applied to the grant not-before and expiry times.
 138    /// </summary>
 139    public TimeSpan AllowedClockSkew { get; }
 140
 141    /// <summary>
 142    /// Gets the policy version the grant must carry, when a policy version expectation is configured.
 143    /// </summary>
 144    public string? PolicyVersion { get; }
 145
 146    /// <summary>
 147    /// Gets the policy hash the grant must carry, when a policy hash expectation is configured.
 148    /// </summary>
 149    public string? PolicyHash { get; }
 150
 151    /// <summary>
 152    /// Gets the acknowledgment identifier the grant must reference, when an acknowledgment expectation is configured.
 153    /// </summary>
 154    public string? AcknowledgmentId { get; }
 155
 156    /// <summary>
 157    /// Gets the liability handshake identifier the grant must reference, when a handshake expectation is configured.
 158    /// </summary>
 159    public string? HandshakeId { get; }
 160
 161    /// <summary>
 162    /// Gets the gateway binding the grant must carry, when a gateway expectation is configured.
 163    /// </summary>
 164    public string? GatewayBinding { get; }
 165
 166    /// <summary>
 167    /// Gets the resource binding the grant must carry, when a resource expectation is configured.
 168    /// </summary>
 169    public string? ResourceBinding { get; }
 170
 171    /// <summary>
 172    /// Gets the authenticated subject that the grant must identify, when subject binding is configured.
 173    /// </summary>
 174    public string? ExpectedSubjectId { get; }
 175
 176    /// <summary>
 177    /// Gets the requested operation that the grant must identify, when operation binding is configured.
 178    /// </summary>
 179    public string? ExpectedOperationName { get; }
 180
 181    /// <summary>
 182    /// Gets a value indicating whether the grant must carry a signature that verifies and is bound to the grant
 183    /// content.
 184    /// </summary>
 185    /// <remarks>
 186    /// When set, validation requires an <see cref="IGovernanceSignatureVerificationService" /> and rebuilds the
 187    /// canonical payload from the grant using <see cref="ProofPayloadOptions" />.
 188    /// </remarks>
 189    public bool RequireProof { get; }
 190
 191    /// <summary>
 192    /// Gets a value indicating whether the grant must reference a handshake acknowledgment.
 193    /// </summary>
 194    /// <remarks>
 195    /// A grant without an acknowledgment reference fails with <see cref="VerificationPolicyAction.RequireAcknowledgment
 196    /// </remarks>
 197    public bool RequireAcknowledgmentReference { get; }
 198
 199    /// <summary>
 200    /// Gets a value indicating whether validation must consume a grant use through an
 201    /// <see cref="ICapabilityGrantUseStore" />.
 202    /// </summary>
 203    public bool RequireUseCheck { get; }
 204
 205    /// <summary>
 206    /// Gets the maximum use count allowed by this validation context.
 207    /// </summary>
 208    /// <remarks>
 209    /// When the grant carries its own signed use limit, the narrower of the two applies, so local policy can tighten
 210    /// but never widen what was issued.
 211    /// </remarks>
 212    public int MaxUseCount { get; }
 213
 214    /// <summary>
 215    /// Gets the signing key identifier the grant proof must use, when configured.
 216    /// </summary>
 217    public string? ExpectedProofKeyId { get; }
 218
 219    /// <summary>
 220    /// Gets the signing key version the grant proof must use, when configured.
 221    /// </summary>
 222    public string? ExpectedProofKeyVersion { get; }
 223
 224    /// <summary>
 225    /// Gets the policy version the grant proof must carry, when configured.
 226    /// </summary>
 227    public string? ExpectedProofPolicyVersion { get; }
 228
 229    /// <summary>
 230    /// Gets the policy hash the grant proof must carry, when configured.
 231    /// </summary>
 232    public string? ExpectedProofPolicyHash { get; }
 233
 234    /// <summary>
 235    /// Gets the signing provider that must have produced the grant proof, when configured.
 236    /// </summary>
 237    public string? RequiredProofProvider { get; }
 238
 239    /// <summary>
 240    /// Gets the hash algorithm the grant proof must use, when configured.
 241    /// </summary>
 242    public string? RequiredProofHashAlgorithm { get; }
 243
 244    /// <summary>
 245    /// Gets the canonical payload options used to rebuild the grant payload when proof is required.
 246    /// </summary>
 247    /// <remarks>
 248    /// Proof validation recomputes the canonical payload from the grant and compares its hash to the signed hash, so th
 249    /// options must match the options the issuer signed with. The default options bind every grant field except metadat
 250    /// whose allow-list is empty until a host opts a key in.
 251    /// </remarks>
 252    public CanonicalPayloadOptions? ProofPayloadOptions { get; }
 253
 254    /// <summary>
 255    /// Creates a custom validation profile from the supplied expectations.
 256    /// </summary>
 257    /// <remarks>
 258    /// This factory does not bind the grant to an authenticated subject. At an execution boundary, prefer
 259    /// <see cref="CreateBoundExecutionBoundary" />, or call <see cref="WithExpectedBindings" /> on the result.
 260    /// </remarks>
 261    /// <param name="issuer">The issuer the grant must name, or <see langword="null" /> to skip the issuer check.</param
 262    /// <param name="audience">The audience the grant must name; required when proof or a use check is required.</param>
 263    /// <param name="scopes">The scopes the grant must contain; blank entries are ignored.</param>
 264    /// <param name="validationUtc">The instant used for the validity window; defaults to the current time.</param>
 265    /// <param name="policyVersion">The policy version the grant must carry, when set.</param>
 266    /// <param name="policyHash">The policy hash the grant must carry, when set.</param>
 267    /// <param name="acknowledgmentId">The acknowledgment identifier the grant must reference, when set.</param>
 268    /// <param name="handshakeId">The handshake identifier the grant must reference, when set.</param>
 269    /// <param name="gatewayBinding">The gateway binding the grant must carry, when set.</param>
 270    /// <param name="resourceBinding">The resource binding the grant must carry, when set.</param>
 271    /// <param name="requireProof">Whether the grant must carry verified proof bound to its content.</param>
 272    /// <param name="requireAcknowledgmentReference">Whether the grant must reference a handshake acknowledgment.</param
 273    /// <param name="requireUseCheck">Whether validation must consume a grant use through a use store.</param>
 274    /// <param name="maxUseCount">The maximum use count for this validation context; must be at least one.</param>
 275    /// <param name="allowedClockSkew">The non-negative tolerance applied to the validity window.</param>
 276    /// <param name="expectedProofKeyId">The signing key identifier the proof must use, when set.</param>
 277    /// <param name="expectedProofKeyVersion">The signing key version the proof must use, when set.</param>
 278    /// <param name="expectedProofPolicyVersion">The policy version the proof must carry, when set.</param>
 279    /// <param name="expectedProofPolicyHash">The policy hash the proof must carry, when set.</param>
 280    /// <param name="requiredProofProvider">The signing provider that must have produced the proof, when set.</param>
 281    /// <param name="requiredProofHashAlgorithm">The hash algorithm the proof must use, when set.</param>
 282    /// <param name="proofPayloadOptions">The canonical payload options the issuer signed with; defaults apply when <see
 283    /// <returns>The validation options.</returns>
 284    /// <exception cref="ArgumentOutOfRangeException">
 285    /// <paramref name="allowedClockSkew" /> is negative, or <paramref name="maxUseCount" /> is less than one.
 286    /// </exception>
 287    /// <exception cref="ArgumentException">
 288    /// <paramref name="requireProof" /> or <paramref name="requireUseCheck" /> is set without an <paramref name="audien
 289    /// </exception>
 290    public static CapabilityGrantValidationOptions Create(
 291        string? issuer = null,
 292        string? audience = null,
 293        IEnumerable<string>? scopes = null,
 294        DateTimeOffset? validationUtc = null,
 295        string? policyVersion = null,
 296        string? policyHash = null,
 297        string? acknowledgmentId = null,
 298        string? handshakeId = null,
 299        string? gatewayBinding = null,
 300        string? resourceBinding = null,
 301        bool requireProof = false,
 302        bool requireAcknowledgmentReference = false,
 303        bool requireUseCheck = false,
 304        int maxUseCount = 1,
 305        TimeSpan allowedClockSkew = default,
 306        string? expectedProofKeyId = null,
 307        string? expectedProofKeyVersion = null,
 308        string? expectedProofPolicyVersion = null,
 309        string? expectedProofPolicyHash = null,
 310        string? requiredProofProvider = null,
 311        string? requiredProofHashAlgorithm = null,
 312        CanonicalPayloadOptions? proofPayloadOptions = null)
 313    {
 146314        return new CapabilityGrantValidationOptions(
 146315            issuer,
 146316            audience,
 146317            NormalizeScopes(scopes),
 146318            validationUtc,
 146319            allowedClockSkew,
 146320            policyVersion,
 146321            policyHash,
 146322            acknowledgmentId,
 146323            handshakeId,
 146324            gatewayBinding,
 146325            resourceBinding,
 146326            expectedSubjectId: null,
 146327            expectedOperationName: null,
 146328            requireSubjectBinding: false,
 146329            requireProof,
 146330            requireAcknowledgmentReference,
 146331            requireUseCheck,
 146332            maxUseCount,
 146333            expectedProofKeyId,
 146334            expectedProofKeyVersion,
 146335            expectedProofPolicyVersion,
 146336            expectedProofPolicyHash,
 146337            requiredProofProvider,
 146338            requiredProofHashAlgorithm,
 146339            proofPayloadOptions);
 340    }
 341
 342    /// <summary>
 343    /// Creates a copy with optional host expectations for the authenticated subject and requested operation.
 344    /// </summary>
 345    public CapabilityGrantValidationOptions WithExpectedBindings(
 346        string? expectedSubjectId = null,
 347        string? expectedOperationName = null)
 348    {
 49349        string? normalizedSubjectId = NormalizeOptional(expectedSubjectId);
 49350        if (RequireSubjectBinding && normalizedSubjectId is null)
 351        {
 2352            normalizedSubjectId = ExpectedSubjectId;
 353        }
 354
 49355        return WithExpectedBindingsCore(
 49356            normalizedSubjectId,
 49357            expectedOperationName,
 49358            RequireSubjectBinding);
 359    }
 360
 361    private CapabilityGrantValidationOptions WithExpectedBindingsCore(
 362        string? expectedSubjectId,
 363        string? expectedOperationName,
 364        bool requireSubjectBinding)
 365    {
 113366        return new CapabilityGrantValidationOptions(
 113367            Issuer,
 113368            Audience,
 113369            Scopes,
 113370            ValidationUtc,
 113371            AllowedClockSkew,
 113372            PolicyVersion,
 113373            PolicyHash,
 113374            AcknowledgmentId,
 113375            HandshakeId,
 113376            GatewayBinding,
 113377            ResourceBinding,
 113378            expectedSubjectId,
 113379            expectedOperationName,
 113380            requireSubjectBinding,
 113381            RequireProof,
 113382            RequireAcknowledgmentReference,
 113383            RequireUseCheck,
 113384            MaxUseCount,
 113385            ExpectedProofKeyId,
 113386            ExpectedProofKeyVersion,
 113387            ExpectedProofPolicyVersion,
 113388            ExpectedProofPolicyHash,
 113389            RequiredProofProvider,
 113390            RequiredProofHashAlgorithm,
 113391            ProofPayloadOptions);
 392    }
 393
 394    /// <summary>
 395    /// Obsolete. Retains the legacy execution-boundary signature for binary compatibility and always fails closed.
 396    /// </summary>
 397    /// <remarks>
 398    /// This method is retained only for compatibility and always throws <see cref="InvalidOperationException" />.
 399    /// Replace calls with <c>CreateBoundExecutionBoundary(CapabilityGrantBindingExpectations, ...)</c>, whose required
 400    /// first argument supplies the authoritative subject and optional operation binding. The warning remains non-error
 401    /// in the 7.x line; removal is planned for the next permitted major version.
 402    /// </remarks>
 403    [Obsolete(
 404        "CreateExecutionBoundary always fails closed and is retained only for binary compatibility. Use CreateBoundExecu
 405        DiagnosticId = "ASIB901",
 406        UrlFormat = "https://asibackbone.github.io/AsiBackbone/articles/asib901-create-execution-boundary.html")]
 407    public static CapabilityGrantValidationOptions CreateExecutionBoundary(
 408        string? issuer = null,
 409        string? audience = null,
 410        IEnumerable<string>? scopes = null,
 411        DateTimeOffset? validationUtc = null,
 412        string? policyVersion = null,
 413        string? policyHash = null,
 414        string? acknowledgmentId = null,
 415        string? handshakeId = null,
 416        string? gatewayBinding = null,
 417        string? resourceBinding = null,
 418        bool requireAcknowledgmentReference = false,
 419        bool requireUseCheck = true,
 420        int maxUseCount = 1,
 421        TimeSpan allowedClockSkew = default,
 422        string? expectedProofKeyId = null,
 423        string? expectedProofKeyVersion = null,
 424        string? expectedProofPolicyVersion = null,
 425        string? expectedProofPolicyHash = null,
 426        string? requiredProofProvider = null,
 427        string? requiredProofHashAlgorithm = null,
 428        CanonicalPayloadOptions? proofPayloadOptions = null)
 429    {
 2430        throw new InvalidOperationException(
 2431            "Execution-boundary validation requires subject binding expectations. Use CreateBoundExecutionBoundary.");
 432    }
 433
 434    /// <summary>
 435    /// Creates a proof-verifying execution-boundary profile with authoritative host binding expectations.
 436    /// </summary>
 437    public static CapabilityGrantValidationOptions CreateBoundExecutionBoundary(
 438        CapabilityGrantBindingExpectations bindingExpectations,
 439        string? issuer = null,
 440        string? audience = null,
 441        IEnumerable<string>? scopes = null,
 442        DateTimeOffset? validationUtc = null,
 443        string? policyVersion = null,
 444        string? policyHash = null,
 445        string? acknowledgmentId = null,
 446        string? handshakeId = null,
 447        string? gatewayBinding = null,
 448        string? resourceBinding = null,
 449        bool requireAcknowledgmentReference = false,
 450        bool requireUseCheck = true,
 451        int maxUseCount = 1,
 452        TimeSpan allowedClockSkew = default,
 453        string? expectedProofKeyId = null,
 454        string? expectedProofKeyVersion = null,
 455        string? expectedProofPolicyVersion = null,
 456        string? expectedProofPolicyHash = null,
 457        string? requiredProofProvider = null,
 458        string? requiredProofHashAlgorithm = null,
 459        CanonicalPayloadOptions? proofPayloadOptions = null)
 460    {
 65461        ArgumentNullException.ThrowIfNull(bindingExpectations);
 462
 64463        return Create(
 64464            issuer: issuer,
 64465            audience: audience,
 64466            scopes: scopes,
 64467            validationUtc: validationUtc,
 64468            policyVersion: policyVersion,
 64469            policyHash: policyHash,
 64470            acknowledgmentId: acknowledgmentId,
 64471            handshakeId: handshakeId,
 64472            gatewayBinding: gatewayBinding,
 64473            resourceBinding: resourceBinding,
 64474            requireProof: true,
 64475            requireAcknowledgmentReference: requireAcknowledgmentReference,
 64476            requireUseCheck: requireUseCheck,
 64477            maxUseCount: maxUseCount,
 64478            allowedClockSkew: allowedClockSkew,
 64479            expectedProofKeyId: expectedProofKeyId,
 64480            expectedProofKeyVersion: expectedProofKeyVersion,
 64481            expectedProofPolicyVersion: expectedProofPolicyVersion,
 64482            expectedProofPolicyHash: expectedProofPolicyHash,
 64483            requiredProofProvider: requiredProofProvider,
 64484            requiredProofHashAlgorithm: requiredProofHashAlgorithm,
 64485            proofPayloadOptions: proofPayloadOptions)
 64486            .WithExpectedBindingsCore(
 64487                bindingExpectations.SubjectId,
 64488                bindingExpectations.OperationName,
 64489                requireSubjectBinding: true);
 490    }
 491
 492    /// <summary>
 493    /// Creates a metadata-only profile that checks grant claims without requiring proof or consuming a use.
 494    /// </summary>
 495    /// <remarks>
 496    /// Because the grant signature is not verified, a valid result only means the grant claims match the expectations.
 497    /// Do not use this profile to authorize execution; use <see cref="CreateBoundExecutionBoundary" /> instead.
 498    /// </remarks>
 499    /// <param name="issuer">The issuer the grant must name, or <see langword="null" /> to skip the issuer check.</param
 500    /// <param name="audience">The audience the grant must name, or <see langword="null" /> to skip the audience check.<
 501    /// <param name="scopes">The scopes the grant must contain; blank entries are ignored.</param>
 502    /// <param name="validationUtc">The instant used for the validity window; defaults to the current time.</param>
 503    /// <param name="policyVersion">The policy version the grant must carry, when set.</param>
 504    /// <param name="policyHash">The policy hash the grant must carry, when set.</param>
 505    /// <param name="acknowledgmentId">The acknowledgment identifier the grant must reference, when set.</param>
 506    /// <param name="handshakeId">The handshake identifier the grant must reference, when set.</param>
 507    /// <param name="gatewayBinding">The gateway binding the grant must carry, when set.</param>
 508    /// <param name="resourceBinding">The resource binding the grant must carry, when set.</param>
 509    /// <param name="requireAcknowledgmentReference">Whether the grant must reference a handshake acknowledgment.</param
 510    /// <param name="allowedClockSkew">The non-negative tolerance applied to the validity window.</param>
 511    /// <returns>The validation options.</returns>
 512    /// <exception cref="ArgumentOutOfRangeException"><paramref name="allowedClockSkew" /> is negative.</exception>
 513    public static CapabilityGrantValidationOptions CreateMetadataValidation(
 514        string? issuer = null,
 515        string? audience = null,
 516        IEnumerable<string>? scopes = null,
 517        DateTimeOffset? validationUtc = null,
 518        string? policyVersion = null,
 519        string? policyHash = null,
 520        string? acknowledgmentId = null,
 521        string? handshakeId = null,
 522        string? gatewayBinding = null,
 523        string? resourceBinding = null,
 524        bool requireAcknowledgmentReference = false,
 525        TimeSpan allowedClockSkew = default)
 526    {
 3527        return Create(
 3528            issuer: issuer,
 3529            audience: audience,
 3530            scopes: scopes,
 3531            validationUtc: validationUtc,
 3532            policyVersion: policyVersion,
 3533            policyHash: policyHash,
 3534            acknowledgmentId: acknowledgmentId,
 3535            handshakeId: handshakeId,
 3536            gatewayBinding: gatewayBinding,
 3537            resourceBinding: resourceBinding,
 3538            requireProof: false,
 3539            requireAcknowledgmentReference: requireAcknowledgmentReference,
 3540            requireUseCheck: false,
 3541            maxUseCount: 1,
 3542            allowedClockSkew: allowedClockSkew);
 543    }
 544
 545    private static IReadOnlyList<string> NormalizeScopes(IEnumerable<string>? scopes)
 546    {
 146547        if (scopes is null)
 548        {
 23549            return EmptyScopes;
 550        }
 551
 123552        string[] normalized = [.. scopes
 123553            .Where(scope => !string.IsNullOrWhiteSpace(scope))
 123554            .Select(scope => scope.Trim())
 123555            .Distinct(StringComparer.Ordinal)
 123556            .OrderBy(scope => scope, StringComparer.Ordinal)];
 557
 123558        return normalized.Length == 0 ? EmptyScopes : Array.AsReadOnly(normalized);
 559    }
 560
 561    private static string? NormalizeOptional(string? value)
 562    {
 4113563        return string.IsNullOrWhiteSpace(value) ? null : value.Trim();
 564    }
 565
 566    private bool RequireSubjectBinding { get; }
 567}

Methods/Properties

.cctor()
.ctor(System.String,System.String,System.Collections.Generic.IReadOnlyList`1<System.String>,System.Nullable`1<System.DateTimeOffset>,System.TimeSpan,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Int32,System.String,System.String,System.String,System.String,System.String,System.String,AsiBackbone.Core.Signing.CanonicalPayloadOptions)
Create(System.String,System.String,System.Collections.Generic.IEnumerable`1<System.String>,System.Nullable`1<System.DateTimeOffset>,System.String,System.String,System.String,System.String,System.String,System.String,System.Boolean,System.Boolean,System.Boolean,System.Int32,System.TimeSpan,System.String,System.String,System.String,System.String,System.String,System.String,AsiBackbone.Core.Signing.CanonicalPayloadOptions)
WithExpectedBindings(System.String,System.String)
WithExpectedBindingsCore(System.String,System.String,System.Boolean)
CreateExecutionBoundary(System.String,System.String,System.Collections.Generic.IEnumerable`1<System.String>,System.Nullable`1<System.DateTimeOffset>,System.String,System.String,System.String,System.String,System.String,System.String,System.Boolean,System.Boolean,System.Int32,System.TimeSpan,System.String,System.String,System.String,System.String,System.String,System.String,AsiBackbone.Core.Signing.CanonicalPayloadOptions)
CreateBoundExecutionBoundary(AsiBackbone.Core.CapabilityGrants.CapabilityGrantBindingExpectations,System.String,System.String,System.Collections.Generic.IEnumerable`1<System.String>,System.Nullable`1<System.DateTimeOffset>,System.String,System.String,System.String,System.String,System.String,System.String,System.Boolean,System.Boolean,System.Int32,System.TimeSpan,System.String,System.String,System.String,System.String,System.String,System.String,AsiBackbone.Core.Signing.CanonicalPayloadOptions)
CreateMetadataValidation(System.String,System.String,System.Collections.Generic.IEnumerable`1<System.String>,System.Nullable`1<System.DateTimeOffset>,System.String,System.String,System.String,System.String,System.String,System.String,System.Boolean,System.TimeSpan)
NormalizeScopes(System.Collections.Generic.IEnumerable`1<System.String>)
NormalizeOptional(System.String)