Class LogoutRequest

  • All Implemented Interfaces:
    Message, Request

    @Immutable
    public class LogoutRequest
    extends AbstractRequest
    Logout request initiated by an OpenID relying party (RP). Supports HTTP GET and POST. HTTP POST is the recommended method to protect the optional ID token hint parameter from potentially getting recorded in access logs.

    Example HTTP POST request:

     POST /op/logout HTTP/1.1
     Host: server.example.com
     Content-Type: application/x-www-form-urlencoded
    
     id_token_hint=eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
     &post_logout_redirect_uri=https%3A%2F%2Fclient.example.org%2Fpost-logout
     &state=af0ifjsldkj
     

    Example URL for an HTTP GET request:

     https://server.example.com/op/logout?
     id_token_hint=eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
     &post_logout_redirect_uri=https%3A%2F%2Fclient.example.org%2Fpost-logout
     &state=af0ifjsldkj
     

    Related specifications:

    • OpenID Connect RP-Initiated Logout 1.0, section 2.
    • Constructor Detail

      • LogoutRequest

        public LogoutRequest​(URI uri,
                             com.nimbusds.jwt.JWT idTokenHint,
                             String logoutHint,
                             ClientID clientID,
                             URI postLogoutRedirectURI,
                             State state,
                             List<com.nimbusds.langtag.LangTag> uiLocales)
        Creates a new OpenID Connect logout request.
        Parameters:
        uri - The URI of the end-session endpoint. May be null if the toHTTPRequest() method will not be used.
        idTokenHint - The ID token hint (recommended), null if not specified.
        logoutHint - The optional logout hint, null if not specified.
        clientID - The optional client ID, null if not specified.
        postLogoutRedirectURI - The optional post-logout redirection URI, null if not specified.
        state - The optional state parameter for the post-logout redirection URI, null if not specified.
        uiLocales - The optional end-user's preferred languages and scripts for the user interface, ordered by preference.
      • LogoutRequest

        public LogoutRequest​(URI uri,
                             com.nimbusds.jwt.JWT idTokenHint,
                             URI postLogoutRedirectURI,
                             State state)
        Creates a new OpenID Connect logout request.
        Parameters:
        uri - The URI of the end-session endpoint. May be null if the toHTTPRequest() method will not be used.
        idTokenHint - The ID token hint (recommended), null if not specified.
        postLogoutRedirectURI - The optional post-logout redirection URI, null if not specified.
        state - The optional state parameter for the post-logout redirection URI, null if not specified.
      • LogoutRequest

        public LogoutRequest​(URI uri,
                             com.nimbusds.jwt.JWT idTokenHint)
        Creates a new OpenID Connect logout request without a post-logout redirection.
        Parameters:
        uri - The URI of the end-session endpoint. May be null if the toHTTPRequest() method will not be used.
        idTokenHint - The ID token hint (recommended), null if not specified.
      • LogoutRequest

        public LogoutRequest​(URI uri)
        Creates a new OpenID Connect logout request without a post-logout redirection.
        Parameters:
        uri - The URI of the end-session endpoint. May be null if the toHTTPRequest() method will not be used.
    • Method Detail

      • getIDTokenHint

        public com.nimbusds.jwt.JWT getIDTokenHint()
        Returns the ID token hint. Corresponds to the optional id_token_hint parameter.
        Returns:
        The ID token hint, null if not specified.
      • getLogoutHint

        public String getLogoutHint()
        Returns the logout hint. Corresponds to the optional logout_hint parameter.
        Returns:
        The logout hint, null if not specified.
      • getClientID

        public ClientID getClientID()
        Returns the client ID. Corresponds to the optional client_id parameter.
        Returns:
        The client ID, null if not specified.
      • getPostLogoutRedirectionURI

        public URI getPostLogoutRedirectionURI()
        Return the post-logout redirection URI.
        Returns:
        The post-logout redirection URI, null if not specified.
      • getState

        public State getState()
        Returns the state parameter for a post-logout redirection URI. Corresponds to the optional state parameter.
        Returns:
        The state parameter, null if not specified.
      • getUILocales

        public List<com.nimbusds.langtag.LangTag> getUILocales()
        Returns the end-user's preferred languages and scripts for the user interface, ordered by preference. Corresponds to the optional ui_locales parameter.
        Returns:
        The preferred UI locales, null if not specified.
      • toParameters

        public Map<String,​List<String>> toParameters()
        Returns the parameters for this logout request.

        Example parameters:

         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         post_logout_redirect_uri = https://client.example.com/post-logout
         state = af0ifjsldkj
         
        Returns:
        The parameters.
      • toQueryString

        public String toQueryString()
        Returns the URI query string for this logout request.

        Note that the '?' character preceding the query string in a URI is not included in the returned string.

        Example URI query string:

         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         &post_logout_redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fpost-logout
         &state=af0ifjsldkj
         
        Returns:
        The URI query string.
      • toURI

        public URI toURI()
        Returns the complete URI representation for this logout request, consisting of the end-session endpoint URI with the query string appended.

        Example URI:

         https://server.example.com/logout?
         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         &post_logout_redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fpost-logout
         &state=af0ifjsldkj
         
        Returns:
        The URI representation.
      • toHTTPRequest

        public HTTPRequest toHTTPRequest()
        Description copied from interface: Request
        Returns the matching HTTP request.
        Returns:
        The HTTP request.
      • parse

        public static LogoutRequest parse​(Map<String,​List<String>> params)
                                   throws ParseException
        Parses a logout request from the specified parameters.

        Example parameters:

         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         post_logout_redirect_uri = https://client.example.com/post-logout
         state = af0ifjsldkj
         
        Parameters:
        params - The parameters, empty map if none. Must not be null.
        Returns:
        The logout request.
        Throws:
        ParseException - If the parameters couldn't be parsed to a logout request.
      • parse

        public static LogoutRequest parse​(URI uri,
                                          Map<String,​List<String>> params)
                                   throws ParseException
        Parses a logout request from the specified URI and query parameters.

        Example parameters:

         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         post_logout_redirect_uri = https://client.example.com/post-logout
         state = af0ifjsldkj
         
        Parameters:
        uri - The URI of the end-session endpoint. May be null if the toHTTPRequest() method will not be used.
        params - The parameters, empty map if none. Must not be null.
        Returns:
        The logout request.
        Throws:
        ParseException - If the parameters couldn't be parsed to a logout request.
      • parse

        public static LogoutRequest parse​(String query)
                                   throws ParseException
        Parses a logout request from the specified URI query string.

        Example URI query string:

         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         &post_logout_redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fpost-logout
         &state=af0ifjsldkj
         
        Parameters:
        query - The URI query string, null if none.
        Returns:
        The logout request.
        Throws:
        ParseException - If the query string couldn't be parsed to a logout request.
      • parse

        public static LogoutRequest parse​(URI uri,
                                          String query)
                                   throws ParseException
        Parses a logout request from the specified URI query string.

        Example URI query string:

         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         &post_logout_redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fpost-logout
         &state=af0ifjsldkj
         
        Parameters:
        uri - The URI of the end-session endpoint. May be null if the toHTTPRequest() method will not be used.
        query - The URI query string, null if none.
        Returns:
        The logout request.
        Throws:
        ParseException - If the query string couldn't be parsed to a logout request.
      • parse

        public static LogoutRequest parse​(URI uri)
                                   throws ParseException
        Parses a logout request from the specified URI.

        Example URI:

         https://server.example.com/logout?
         id_token_hint = eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         &post_logout_redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fpost-logout
         &state=af0ifjsldkj
         
        Parameters:
        uri - The URI. Must not be null.
        Returns:
        The logout request.
        Throws:
        ParseException - If the URI couldn't be parsed to a logout request.
      • parse

        public static LogoutRequest parse​(HTTPRequest httpRequest)
                                   throws ParseException
        Parses a logout request from the specified HTTP GET or POST request.

        Example HTTP POST request:

         POST /op/logout HTTP/1.1
         Host: server.example.com
         Content-Type: application/x-www-form-urlencoded
        
         id_token_hint=eyJhbGciOiJSUzI1NiJ9.eyJpc3Mi...
         &post_logout_redirect_uri=https%3A%2F%2Fclient.example.org%2Fpost-logout
         &state=af0ifjsldkj
         
        Parameters:
        httpRequest - The HTTP request. Must not be null.
        Returns:
        The logout request.
        Throws:
        ParseException - If the HTTP request couldn't be parsed to a logout request.