Class Scope

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Scope.Value>, Collection<Scope.Value>, Set<Scope.Value>

@NotThreadSafe public class Scope extends LinkedHashSet<Scope.Value>
Authorisation scope.

Example scope from OpenID Connect indicating access to the user's email and profile details:

 Scope scope = new Scope();
 scope.add(OIDCScopeValue.OPENID);
 scope.add(OIDCScopeValue.EMAIL);
 scope.add(OIDCScopeValue.PROFILE);
 

Related specifications:

  • OAuth 2.0 (RFC 6749)
See Also:
  • Constructor Details

    • Scope

      public Scope()
      Creates a new empty authorisation scope.
    • Scope

      public Scope(Scope scope)
      Creates a new scope from the specified scope.
      Parameters:
      scope - The scope. May be null.
    • Scope

      public Scope(String... values)
      Creates a new authorisation scope with the specified string values.
      Parameters:
      values - The string values.
    • Scope

      public Scope(Scope.Value... values)
      Creates a new authorisation scope with the specified values.
      Parameters:
      values - The values.
  • Method Details

    • add

      public boolean add(String value)
      Adds the specified string value to this scope.
      Parameters:
      value - The string value. Must not be null.
      Returns:
      true if this scope did not already contain the specified value.
    • contains

      public boolean contains(String value)
      Checks if this scope contains the specified string value.
      Parameters:
      value - The string value. Must not be null.
      Returns:
      true if the value is contained, else false.
    • toString

      public String toString()
      Returns the string representation of this scope. The scope values will be serialised in the order they were added.
      Overrides:
      toString in class AbstractCollection<Scope.Value>
      Returns:
      The string representation.
    • toStringList

      Returns the string list representation of this scope. The scope values will be serialised in the order they were added.
      Returns:
      The string list representation.
    • parse

      public static Scope parse(Collection<String> collection)
      Parses a scope from the specified string collection representation.
      Parameters:
      collection - The string collection, null if not specified.
      Returns:
      The scope, null if not specified.
    • parse

      public static Scope parse(String s)
      Parses a scope from the specified string representation.
      Parameters:
      s - The scope string, null if not specified.
      Returns:
      The scope, null if not specified.