Class McpScopeAccumulator
insufficient_scope challenge.
The mandated minimum union (SEP-2350 "Step-Up Authorization Flow" step 2) is
{previously-requested} ∪ {challenge scopes}, which preserves previously-granted permissions when
servers emit per-operation challenges. union(Collection, Collection) computes exactly that. The broader
overload union(Collection, Collection, Collection, Collection, Collection) additionally folds in the
opt-in contributors the spec permits a client to consult (granted-token scopes, cached PRM
scopes_supported, and client-metadata scope) — supplying them widens the union; omitting them keeps the
default at the mandated minimum.
The union is order-preserving (LinkedHashSet) with exact-string dedup only — scopes are
opaque strings, so repo and repo:read are both retained (no hierarchy-aware dedup client-side;
hierarchy reasoning is the server's MUST).
As an instance, this class also maintains per-(resource, issuer) accumulated state so a step-up driver
can carry the growing union across successive challenges for the same resource/AS. Thread-safe.
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccumulate(URI resource, URI issuer, Collection<String> challengeScopes) Unions the given challenge scopes into the accumulated state for the(resource, issuer)key and returns the updated union.Returns a copy of the currently-accumulated union for the(resource, issuer)key.seed(URI resource, URI issuer, Collection<String> previouslyRequested) Seeds the accumulated state for a(resource, issuer)key with the client's previously-requested scopes, unioning into any existing entry for that key rather than replacing it.union(Collection<String> previouslyRequested, Collection<String> challengeScopes) Computes the mandated-minimum step-up union:previouslyRequested ∪ challengeScopes, order-preserving with exact-string dedup.union(Collection<String> previouslyRequested, Collection<String> challengeScopes, Collection<String> grantedTokenScopes, Collection<String> prmScopesSupported, Collection<String> clientMetadataScope) Computes the broadened step-up union, folding in the opt-in contributors the SEP-2350 Scope Selection Strategy permits a client to consult.
-
Constructor Details
-
McpScopeAccumulator
public McpScopeAccumulator()
-
-
Method Details
-
union
public static Set<String> union(Collection<String> previouslyRequested, Collection<String> challengeScopes) Computes the mandated-minimum step-up union:previouslyRequested ∪ challengeScopes, order-preserving with exact-string dedup.- Parameters:
previouslyRequested- The scope set the client previously requested (may benull/ empty).challengeScopes- The scopes from the server'sinsufficient_scopechallenge (may benull/ empty).- Returns:
- A new order-preserving union set. Never
null.
-
union
public static Set<String> union(Collection<String> previouslyRequested, Collection<String> challengeScopes, Collection<String> grantedTokenScopes, Collection<String> prmScopesSupported, Collection<String> clientMetadataScope) Computes the broadened step-up union, folding in the opt-in contributors the SEP-2350 Scope Selection Strategy permits a client to consult. Order-preserving; exact-string dedup. Anynullcontributor is treated as empty.- Parameters:
previouslyRequested- The scope set the client previously requested.challengeScopes- The scopes from the server'sinsufficient_scopechallenge.grantedTokenScopes- The scopes on the currently-held token (opt-in).prmScopesSupported- The cached PRMscopes_supported(opt-in).clientMetadataScope- The scope declared in client metadata (opt-in).- Returns:
- A new order-preserving union set. Never
null.
-
seed
Seeds the accumulated state for a(resource, issuer)key with the client's previously-requested scopes, unioning into any existing entry for that key rather than replacing it.Unioning (not overwriting) matters when a shared accumulator is seeded more than once for the same key — e.g. two
buildsagainst one shared accumulator, or a re-seed after some challenge scopes were alreadyaccumulated— so no previously-tracked scope is ever lost.- Parameters:
resource- The RFC 8707 resource indicator. Must not benull .issuer- The authorization server issuer. Must not benull .previouslyRequested- The previously-requested scopes. May benull/ empty.- Returns:
- This object.
-
accumulate
Unions the given challenge scopes into the accumulated state for the(resource, issuer)key and returns the updated union.- Parameters:
resource- The RFC 8707 resource indicator. Must not benull .issuer- The authorization server issuer. Must not benull .challengeScopes- The scopes from the latestinsufficient_scopechallenge. May benull/ empty.- Returns:
- A copy of the updated accumulated union for the key. Never
null.
-
current
Returns a copy of the currently-accumulated union for the(resource, issuer)key.- Parameters:
resource- The RFC 8707 resource indicator. Must not benull .issuer- The authorization server issuer. Must not benull .- Returns:
- A copy of the current accumulated union (empty if the key was never seeded/accumulated).
-