public interface ScopeMap
A Map of scopes which can be used to verify scopes requested by OAuth clients as well as obtain sub-sets of scope configurations that belong to different Sets (e.g. OAuth profile and client scope config).

Verified scopes, which are passed in as simple Strings, are returned as ScopeValue instances, which keep a link to the @link{ScopeConfig} which matched it when checked against this Map.

Since:
4.0.0
  • Method Details

    • contains

      boolean contains(String requestedScope)
      Check whether this scopes Map includes a match for the single requested scope.
      Parameters:
      requestedScope - a single scope requested by a client
      Returns:
      true if the scope is included in this scopes map, false otherwise
    • containsAll

      boolean containsAll(@Nullable String requestedScopes)
      Check whether this scopes Map includes matches for all of the requested scopes.
      Parameters:
      requestedScopes - whitespace-separated scopes requested by a client
      Returns:
      true if all of the scopes are included in this scopes map, false otherwise
    • getRawSpecificationsMatching

      ScopeMap getRawSpecificationsMatching(Collection<String> scopes)
      Keep all scopes that have the exact same specification as the ones in the given Set.

      Notice that this means that prefix scopes, for example, should be matched exactly (i.e. direct String comparison), not as prefixes.

      Parameters:
      scopes - scopes specifications, usually from configuration
      Returns:
      a map containing only those scopes that match exactly the raw specification of the given scopes
    • intersection

      ScopeMap intersection(ScopeMap other)
      Compute the intersection between this map and the other map.

      The result of this operation is a map that contains only the scope configurations that are present in both maps.

      Parameters:
      other - scopes map
      Returns:
      a scopes map that contains all scopes that are both in this map and in the other map.
    • union

      ScopeMap union(ScopeMap other)
      Compute the union of this map and the other map.

      The result of this operation is a map that contains only the scope configurations that are present in both maps.

      Parameters:
      other - scopes map
      Returns:
      a scopes map that contains all scopes that are both in this map and in the other map.
    • getAll

      Set<ScopeConfig> getAll()
      Returns:
      all ScopeConfig in this Map.
    • getScopeValues

      Set<ScopeValue> getScopeValues()
      Returns:
      all as ScopeValue in this Map
    • getAllMatching

      Set<ScopeValue> getAllMatching(String requestedScopes)
      Get a Set of all scope values that match at least one scope within this map.
      Parameters:
      requestedScopes - the requested scope names (whitespace separated list)
      Returns:
      scope values for those requested scopes that match a scope in this map
    • getAllForClaim

      Set<ScopeValue> getAllForClaim(String claimName)
      Parameters:
      claimName - name of the claim
      Returns:
      all scopes mapped to the given claim
      Since:
      4.0.0
    • getAllMatching

      Set<ScopeValue> getAllMatching(Collection<String> requestedScopeNames)
      Get a Set of all scope values that match at least one scope within this map.
      Parameters:
      requestedScopeNames - the requested scope names
      Returns:
      scope values for those requested scopes that match a scope in this map
    • getOnlyRequiredScopes

      ScopeMap getOnlyRequiredScopes()
      Get a scopes Map containing only required scopes, as defined by ScopeConfig.isRequired().
      Returns:
      required scopes
    • size

      int size()
      Returns:
      number of scopes in this map
    • isEmpty

      boolean isEmpty()
      Returns:
      true if this Map is empty, false otherwise
    • areAllIn

      boolean areAllIn(Collection<String> requestedScopes)
      Check if the scopes in this map are all included in the given Set of requested scopes.
      Parameters:
      requestedScopes - the requested scopes
      Returns:
      true if this scopes map is a subSet of the requested scopes
    • with

      ScopeMap with(ScopeConfig scopeConfig)
      Create a copy of this scopes map that includes the provided scope.
      Parameters:
      scopeConfig - to add to the Map
      Returns:
      copy of this Map with the given scope included
    • findMatching

      @Nullable @Nullable ScopeConfig findMatching(String requestedScope)
      Find a scope that matches the given scope name.
      Parameters:
      requestedScope - single scope name
      Returns:
      the scope, or null if none is found.
    • asRawScopeSpecifications

      Set<String> asRawScopeSpecifications()
      Get the raw scope specifications.

      Do not use this method to check requested scopes!

      Returns:
      the raw scope specifications contained in this Map.
    • getClaims

      Set<String> getClaims()
      Returns the set of all claims entitled by this set of scopes.
      Returns:
      claim names
    • filter

      ScopeMap filter(Set<ScopeValue> scopeValues)
      Filter only those scopes that are present in the given Set.
      Parameters:
      scopeValues - scope values to keep
      Returns:
      filtered ScopeMap
    • filtered

      ScopeMap filtered(Predicate<ScopeConfig> predicate)
      Filter only those scopes that satisfy the provided filter function. All scope types are evaluated, OAuthScopes as well as Prefix Scopes
      Parameters:
      predicate - filter method, that returns true when the ScopeConfig must be present in the output
      Returns:
      filtered ScopeMap
    • filterContainingAllClaims

      ScopeMap filterContainingAllClaims(ClaimSet claims)
      Filter only those scopes that contain all the claims of the provided claimset
      Parameters:
      claims - claims to find scopes of
      Returns:
      a scopemap with only the scopes that have all their claims present in the provided claimset