Class 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
    • 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 be null.
      • ResponseType

        public ResponseType​(ResponseType.Value... values)
        Creates a new response type with the specified values.
        Parameters:
        values - The values. Must not be null.
    • Method Detail

      • 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 is null or empty.
      • impliesCodeFlow

        public boolean impliesCodeFlow()
        Returns true if this response type implies an authorisation code flow.

        Code flow response_type values: code

        Returns:
        true if a code flow is implied, else false.
      • impliesImplicitFlow

        public boolean impliesImplicitFlow()
        Returns true 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, else false.
      • impliesHybridFlow

        public boolean impliesHybridFlow()
        Returns true 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, else false.
      • contains

        public boolean contains​(String value)
        Checks if this response type 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 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 class AbstractCollection<ResponseType.Value>
        Returns:
        Space delimited string representing the authorisation response type.