Package com.nimbusds.oauth2.sdk
Class ResponseType
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet<ResponseType.Value>
-
- com.nimbusds.oauth2.sdk.ResponseType
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<ResponseType.Value>
,Collection<ResponseType.Value>
,Set<ResponseType.Value>
@NotThreadSafe public class ResponseType extends HashSet<ResponseType.Value>
Authorisation response type. Can be single-valued or multiple-valued.The following helper methods can be used to find out the OAuth 2.0 protocol flow that a particular response type implies:
Example response type implying an authorisation code flow:
ResponseType() rt = new ResponseType(); rt.add(ResponseType.Value.CODE);
Example response type from OpenID Connect specifying an ID token and an access token (implies implicit flow):
ResponseType() rt = new ResponseType(); rt.add(OIDCResponseTypeValue.ID_TOKEN); rt.add(ResponseType.Value.TOKEN);
Related specifications:
- OAuth 2.0 (RFC 6749), sections 3.1.1 and 4.1.1.
- OAuth 2.0 Multiple Response Type Encoding Practices.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResponseType.Value
Authorisation response type value.
-
Constructor Summary
Constructors Constructor Description ResponseType()
Creates a new empty response type.ResponseType(ResponseType.Value... values)
Creates a new response type with the specified values.ResponseType(String... values)
Creates a new response type with the specified string values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(String value)
Checks if this response type contains the specified string value.static ResponseType
getDefault()
Gets the default response type.boolean
impliesCodeFlow()
Returnstrue
if this response type implies an authorisation code flow.boolean
impliesHybridFlow()
Returnstrue
if this response type implies an OpenID Connect hybrid flow.boolean
impliesImplicitFlow()
Returnstrue
if this response type implies an implicit flow.static ResponseType
parse(String s)
Parses a set of authorisation response types.String
toString()
Returns the string representation of this authorisation response type.-
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size, spliterator
-
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
-
ResponseType
public ResponseType()
Creates a new empty response type.
-
ResponseType
public ResponseType(String... values)
Creates a new response type with the specified string values.- Parameters:
values
- The string values. Must not benull
.
-
ResponseType
public ResponseType(ResponseType.Value... values)
Creates a new response type with the specified values.- Parameters:
values
- The values. Must not benull
.
-
-
Method Detail
-
getDefault
public static ResponseType getDefault()
Gets the default response type.- Returns:
- The default response type, consisting of the value
ResponseType.Value.CODE
.
-
parse
public static ResponseType parse(String s) throws ParseException
Parses a set of authorisation response types.Example serialised response type sets:
code token id_token id_token token code token code id_token code id_token token
- Parameters:
s
- Space-delimited list of one or more authorisation response types.- Returns:
- The authorisation response types set.
- Throws:
ParseException
- If the parsed string isnull
or empty.
-
impliesCodeFlow
public boolean impliesCodeFlow()
Returnstrue
if this response type implies an authorisation code flow.Code flow response_type values: code
- Returns:
true
if a code flow is implied, elsefalse
.
-
impliesImplicitFlow
public boolean impliesImplicitFlow()
Returnstrue
if this response type implies an implicit flow.Implicit flow response_type values: token, id_token token, id_token
- Returns:
true
if an implicit flow is implied, elsefalse
.
-
impliesHybridFlow
public boolean impliesHybridFlow()
Returnstrue
if this response type implies an OpenID Connect hybrid flow.Hybrid flow response_type values: code id_token, code token, code id_token token
- Returns:
true
if a hybrid flow is implied, elsefalse
.
-
contains
public boolean contains(String value)
Checks if this response type contains the specified string value.- Parameters:
value
- The string value. Must not benull
.- Returns:
true
if the value is contained, elsefalse
.
-
toString
public String toString()
Returns the string representation of this authorisation response type.Example serialised response types:
code token id_token id_token token code token code id_token code id_token token
- Overrides:
toString
in classAbstractCollection<ResponseType.Value>
- Returns:
- Space delimited string representing the authorisation response type.
-
-