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.Example response type implying an authorisation code flow:
ResponseType rt = ResponseType.CODE;
Example response type from OpenID Connect specifying an ID token and an access token (implies implicit flow):
ResponseType rt = ResponseType.IDTOKEN_TOKEN);
The following helper methods can be used to find out the implied OAuth 2.0 protocol flow for a response type:
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 classResponseType.ValueAuthorisation response type value.
-
Field Summary
Fields Modifier and Type Field Description static ResponseTypeCODEConstant forresponse_type=code.static ResponseTypeCODE_IDTOKENConstant forresponse_type=code id_token.static ResponseTypeCODE_IDTOKEN_TOKENConstant forresponse_type=code id_token token.static ResponseTypeCODE_TOKENConstant forresponse_type=code token.static ResponseTypeIDTOKENConstant forresponse_type=id_token.static ResponseTypeIDTOKEN_TOKENConstant forresponse_type=id_token token.static ResponseTypeTOKENConstant forresponse_type=token.
-
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 booleanadd(ResponseType.Value value)booleanaddAll(Collection<? extends ResponseType.Value> c)voidclear()booleancontains(String value)Checks if this response type contains the specified string value.static ResponseTypegetDefault()Gets the default response type.booleanimpliesCodeFlow()Returnstrueif this response type implies an authorisation code flow.booleanimpliesHybridFlow()Returnstrueif this response type implies an OpenID Connect hybrid flow.booleanimpliesImplicitFlow()Returnstrueif this response type implies an implicit flow.static ResponseTypeparse(String s)Parses a set of authorisation response types.booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)StringtoString()Returns the string representation of this authorisation response type.-
Methods inherited from class java.util.HashSet
clone, contains, isEmpty, iterator, size, spliterator
-
Methods inherited from class java.util.AbstractSet
equals, hashCode
-
Methods inherited from class java.util.AbstractCollection
containsAll, 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
-
-
-
-
Field Detail
-
CODE
public static final ResponseType CODE
Constant forresponse_type=code.
-
TOKEN
public static final ResponseType TOKEN
Constant forresponse_type=token.
-
IDTOKEN_TOKEN
public static final ResponseType IDTOKEN_TOKEN
Constant forresponse_type=id_token token.
-
IDTOKEN
public static final ResponseType IDTOKEN
Constant forresponse_type=id_token.
-
CODE_IDTOKEN
public static final ResponseType CODE_IDTOKEN
Constant forresponse_type=code id_token.
-
CODE_TOKEN
public static final ResponseType CODE_TOKEN
Constant forresponse_type=code token.
-
CODE_IDTOKEN_TOKEN
public static final ResponseType CODE_IDTOKEN_TOKEN
Constant forresponse_type=code id_token token.
-
-
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.- Parameters:
s- Space-delimited list of one or more authorisation response types.- Returns:
- The authorisation response types set.
- Throws:
ParseException- If the parsed string isnullor empty.
-
impliesCodeFlow
public boolean impliesCodeFlow()
Returnstrueif this response type implies an authorisation code flow.Code flow response_type values: code
- Returns:
trueif a code flow is implied, elsefalse.
-
impliesImplicitFlow
public boolean impliesImplicitFlow()
Returnstrueif this response type implies an implicit flow.Implicit flow response_type values: token, id_token token, id_token
- Returns:
trueif an implicit flow is implied, elsefalse.
-
impliesHybridFlow
public boolean impliesHybridFlow()
Returnstrueif this response type implies an OpenID Connect hybrid flow.Hybrid flow response_type values: code id_token, code token, code id_token token
- Returns:
trueif 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:
trueif 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:
toStringin classAbstractCollection<ResponseType.Value>- Returns:
- Space delimited string representing the authorisation response type.
-
add
public boolean add(ResponseType.Value value)
- Specified by:
addin interfaceCollection<ResponseType.Value>- Specified by:
addin interfaceSet<ResponseType.Value>- Overrides:
addin classHashSet<ResponseType.Value>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<ResponseType.Value>- Specified by:
removein interfaceSet<ResponseType.Value>- Overrides:
removein classHashSet<ResponseType.Value>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<ResponseType.Value>- Specified by:
clearin interfaceSet<ResponseType.Value>- Overrides:
clearin classHashSet<ResponseType.Value>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<ResponseType.Value>- Specified by:
removeAllin interfaceSet<ResponseType.Value>- Overrides:
removeAllin classAbstractSet<ResponseType.Value>
-
addAll
public boolean addAll(Collection<? extends ResponseType.Value> c)
- Specified by:
addAllin interfaceCollection<ResponseType.Value>- Specified by:
addAllin interfaceSet<ResponseType.Value>- Overrides:
addAllin classAbstractCollection<ResponseType.Value>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<ResponseType.Value>- Specified by:
retainAllin interfaceSet<ResponseType.Value>- Overrides:
retainAllin classAbstractCollection<ResponseType.Value>
-
-