Package com.nimbusds.oauth2.sdk
Class Scope
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet<E>
-
- java.util.LinkedHashSet<Scope.Value>
-
- com.nimbusds.oauth2.sdk.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), section 3.3.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScope.ValueAuthorisation scope value.
-
Constructor Summary
Constructors Constructor Description Scope()Creates a new empty authorisation scope.Scope(Scope scope)Creates a new scope from the specified scope.Scope(Scope.Value... values)Creates a new authorisation scope with the specified values.Scope(String... values)Creates a new authorisation scope with the specified string values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(String value)Adds the specified string value to this scope.booleancontains(String value)Checks if this scope contains the specified string value.static Scopeparse(String s)Parses a scope from the specified string representation.static Scopeparse(Collection<String> collection)Parses a scope from the specified string collection representation.StringtoString()Returns the string representation of this scope.List<String>toStringList()Returns the string list representation of this scope.-
Methods inherited from class java.util.LinkedHashSet
spliterator
-
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size
-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Constructor Detail
-
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 benull.
-
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 Detail
-
add
public boolean add(String value)
Adds the specified string value to this scope.- Parameters:
value- The string value. Must not benull.- Returns:
trueif 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 benull.- Returns:
trueif the value is contained, elsefalse.
-
toString
public String toString()
Returns the string representation of this scope. The scope values will be serialised in the order they were added.- Overrides:
toStringin classAbstractCollection<Scope.Value>- Returns:
- The string representation.
-
toStringList
public List<String> 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,nullif not specified.- Returns:
- The scope,
nullif not specified.
-
-