Class TokenRequestHandler


  • public class TokenRequestHandler
    extends Object
    Handler for token requests to a token endpoint of OAuth 2.0 (RFC 6749).

    In an implementation of token endpoint, call one of handle() method variants and use the response as the response from the endpoint to the client application. handle() method calls Authlete's /auth/token API, receives a response from the API, and dispatches processing according to the action parameter in the response.

    Author:
    Takahiko Kawasaki
    See Also:
    RFC 6749: The OAuth 2.0 Authorization Framework
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.authlete.jaxrs.AuthleteApiCaller getApiCaller()  
      javax.ws.rs.core.Response handle​(TokenRequestHandler.Params params)
      Handle a token request.
      javax.ws.rs.core.Response handle​(TokenRequestHandler.Params params, com.authlete.common.api.Options tokenOptions, com.authlete.common.api.Options tokenIssueOptions, com.authlete.common.api.Options tokenFailOptions)
      Handle a token request.
      javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters, String authorization)
      Handle a token request.
      javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters, String authorization, com.authlete.common.api.Options tokenOptions, com.authlete.common.api.Options tokenIssueOptions, com.authlete.common.api.Options tokenFailOptions)
      Handle a token request.
      javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters, String authorization, String[] clientCertificatePath)
      Handle a token request.
      javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters, String authorization, String[] clientCertificatePath, com.authlete.common.api.Options tokenOptions, com.authlete.common.api.Options tokenIssueOptions, com.authlete.common.api.Options tokenFailOptions)
      Handle a token request.
      protected javax.ws.rs.InternalServerErrorException unexpected​(String message, Throwable cause)  
    • Constructor Detail

      • TokenRequestHandler

        public TokenRequestHandler​(com.authlete.common.api.AuthleteApi api,
                                   TokenRequestHandlerSpi spi)
        Constructor with an implementation of AuthleteApi interface and an implementation of TokenRequestHandlerSpi interface.
        Parameters:
        api - Implementation of AuthleteApi interface.
        spi - Implementation of TokenRequestHandlerSpi interface.
    • Method Detail

      • handle

        public javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters,
                                                String authorization)
                                         throws javax.ws.rs.WebApplicationException
        Handle a token request. This method is an alias of the handle(Params) method.
        Parameters:
        parameters - Request parameters of a token request.
        authorization - The value of Authorization header in the token request. A client application may embed its pair of client ID and client secret in a token request using Basic Authentication.
        Returns:
        A response that should be returned from the endpoint to the client application.
        Throws:
        javax.ws.rs.WebApplicationException - An error occurred.
      • handle

        public javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters,
                                                String authorization,
                                                com.authlete.common.api.Options tokenOptions,
                                                com.authlete.common.api.Options tokenIssueOptions,
                                                com.authlete.common.api.Options tokenFailOptions)
                                         throws javax.ws.rs.WebApplicationException
        Handle a token request. This method is an alias of handle (parameters, authorization, null, tokenOptions, tokenIssueOptions, tokenFailOptions).
        Parameters:
        parameters - The request parameters of a token request.
        authorization - The value of Authorization header in the token request. A client application may embed its pair of client ID and client secret in a token request using Basic Authentication.
        tokenOptions - The request options for the /api/auth/token API.
        tokenIssueOptions - The request options for the /api/auth/token/issue API.
        tokenFailOptions - The request options for the /api/auth/token/fail API.
        Returns:
        A response that should be returned from the endpoint to the client application.
        Throws:
        javax.ws.rs.WebApplicationException - An error occurred.
        Since:
        2.82
      • handle

        public javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters,
                                                String authorization,
                                                String[] clientCertificatePath)
                                         throws javax.ws.rs.WebApplicationException
        Handle a token request. This method is an alias of the handle(Params) method.
        Parameters:
        parameters - Request parameters of a token request.
        authorization - The value of Authorization header in the token request. A client application may embed its pair of client ID and client secret in a token request using Basic Authentication.
        clientCertificatePath - The path of the client's certificate, each in PEM format. The first item in the array is the client's certificate itself. May be null if the client did not send a certificate or path.
        Returns:
        A response that should be returned from the endpoint to the client application.
        Throws:
        javax.ws.rs.WebApplicationException - An error occurred.
        Since:
        2.8
      • handle

        public javax.ws.rs.core.Response handle​(javax.ws.rs.core.MultivaluedMap<String,​String> parameters,
                                                String authorization,
                                                String[] clientCertificatePath,
                                                com.authlete.common.api.Options tokenOptions,
                                                com.authlete.common.api.Options tokenIssueOptions,
                                                com.authlete.common.api.Options tokenFailOptions)
                                         throws javax.ws.rs.WebApplicationException
        Handle a token request. This method is an alias of the handle(Params, Options, Options, Options) method.
        Parameters:
        parameters - The request parameters of a token request.
        authorization - The value of Authorization header in the token request. A client application may embed its pair of client ID and client secret in a token request using Basic Authentication.
        clientCertificatePath - The path of the client's certificate, each in PEM format. The first item in the array is the client's certificate itself. May be null if the client did not send a certificate or path.
        tokenOptions - The request options for the /api/auth/token API.
        tokenIssueOptions - The request options for the /api/auth/token/issue API.
        tokenFailOptions - The request options for the /api/auth/token/fail API.
        Returns:
        A response that should be returned from the endpoint to the client application.
        Throws:
        javax.ws.rs.WebApplicationException - An error occurred.
        Since:
        2.82
      • handle

        public javax.ws.rs.core.Response handle​(TokenRequestHandler.Params params)
                                         throws javax.ws.rs.WebApplicationException
        Handle a token request. This method is an alias of handle(params, null, null, null).
        Parameters:
        params - Parameters needed to handle the token request. Must not be null.
        Returns:
        A response that should be returned from the endpoint to the client application.
        Throws:
        javax.ws.rs.WebApplicationException - An error occurred.
        Since:
        2.27
      • handle

        public javax.ws.rs.core.Response handle​(TokenRequestHandler.Params params,
                                                com.authlete.common.api.Options tokenOptions,
                                                com.authlete.common.api.Options tokenIssueOptions,
                                                com.authlete.common.api.Options tokenFailOptions)
                                         throws javax.ws.rs.WebApplicationException
        Handle a token request.
        Parameters:
        params - Parameters needed to handle the token request. Must not be null.
        tokenOptions - The request options for the /api/auth/token API.
        tokenIssueOptions - The request options for the /api/auth/token/issue API.
        tokenFailOptions - The request options for the /api/auth/token/fail API.
        Returns:
        A response that should be returned from the endpoint to the client application.
        Throws:
        javax.ws.rs.WebApplicationException - An error occurred.
        Since:
        2.82
      • getApiCaller

        protected com.authlete.jaxrs.AuthleteApiCaller getApiCaller()
      • unexpected

        protected javax.ws.rs.InternalServerErrorException unexpected​(String message,
                                                                      Throwable cause)