Interface OAuth2Request


  • @Supported
    public interface OAuth2Request
    An abstraction of the actual request so as to allow the core of the OAuth2 provider to be agnostic of the library used to translate the HTTP request.
    Since:
    7.0.0
    • Method Detail

      • getRequest

        @Supported
        Request getRequest()
        Gets the actual underlying request.
        Returns:
        The underlying request.
      • getParameter

        @Supported
        <T> T getParameter​(String name)
        Gets the specified parameter from the request.
        Used to call the overloaded getParameter method with checkQueryParam set to true. The checkQueryParam enables us to prevent checking the query parameters from the request.
        Type Parameters:
        T - The type of the parameter.
        Parameters:
        name - The name of the parameter.
        Returns:
        The parameter value or null if no parameter found.
      • getParameter

        @Supported
        <T> T getParameter​(String name,
                           boolean checkQueryParam)
        Gets the specified parameter from the request.

        This method will first check the attributes then query string if checkQueryParam == true, then move onto check entity values if it is a post.

        Historically the request's realm would be obtained from this method but as this now comes from the CHF context, the getRealm() and getClientRealm() should be used instead.

        Type Parameters:
        T - The type of the parameter.
        Parameters:
        name - The name of the parameter. "realm" is not accepted.
        checkQueryParam - boolean value indicating if the query parameter should be checked.
        Returns:
        The parameter value or null if no parameter found.
      • getParameterCount

        @Supported
        int getParameterCount​(String name)
        Gets the count of the parameter present in the request with the given name
        Parameters:
        name - The name of the parameter
        Returns:
        The count of the the parameter with the given name
      • getParameterNames

        @Supported
        Set<String> getParameterNames()
        Gets the name of the parameters in the current request
        Returns:
        The parameter names in the request
      • getAttribute

        @Supported
        Object getAttribute​(String name)
        Gets the value for an attribute from the request with the specified name.
        Parameters:
        name - The name.
        Returns:
        The attribute value, may be null
      • getQueryParameter

        @Supported
        String getQueryParameter​(String name)
        Gets the value for a query parameter from the request with the specified name.
        Parameters:
        name - The name.
        Returns:
        The query parameter value, may be null.
      • getBody

        @Supported
        JsonValue getBody()
        Gets the body of the request.
        Note: reading of the body maybe a one time only operation, so the implementation needs to cache the content of the body so multiple calls to this method do not behave differently.
        This method should only ever be called for access and refresh token request and requests to the userinfo and tokeninfo endpoints.
        Returns:
        The body of the request.
      • setToken

        @Supported
        <T extends Token> void setToken​(Class<T> tokenClass,
                                        T token)
        Set a Token that is in play for this request.
        Type Parameters:
        T - The type of token.
        Parameters:
        tokenClass - The token type.
        token - The token instance.
      • getToken

        @Supported
        <T extends Token> T getToken​(Class<T> tokenClass)
        Get a Token that is in play for this request.
        Type Parameters:
        T - The type of token.
        Parameters:
        tokenClass - The token type.
        Returns:
        The token instance.
      • getTokens

        @Supported
        Collection<Token> getTokens()
        Get all the tokens that have been used in this request.
        Returns:
        The token instances.
      • setSession

        @Supported
        void setSession​(String sessionId)
        Sets the user's session for this request.
        Parameters:
        sessionId - The user's session.
      • getSession

        @Supported
        String getSession()
        Gets the user's session for this request.
        Returns:
        The user's session.
      • setOps

        @Supported
        void setOps​(String ops)
        Sets the user's session public reference for this request.
        Parameters:
        ops - The user's session public reference.
      • getOps

        @Supported
        String getOps()
        Gets the user's session public reference for this request.
        Returns:
        The user's session public reference.
      • getLocale

        @Supported
        Locale getLocale()
        Get the request locale.
        Returns:
        The Locale object.
      • getClientRegistration

        @Supported
        ClientRegistration getClientRegistration()
        Get the OAuth2 client registration of the request.
        Returns:
        The client registration.
      • setConsentResponseJwt

        @Supported
        void setConsentResponseJwt​(SignedJwt jwt)
        Parameters:
        jwt - A possibly null consent response to assign to this request.
      • setClientRegistration

        @Supported
        void setClientRegistration​(ClientRegistration clientRegistration)
        Set the OAuth2 client registration.
        Parameters:
        clientRegistration - The client registration.
      • getClient

        @Supported
        org.forgerock.oauth2.core.Client getClient()
        Gets the client associated with this request, or null if not yet set. Use ClientDAO.read(String, OAuth2Request) if not yet set.
        Returns:
        the client associated with this request.
      • setClient

        @Supported
        void setClient​(org.forgerock.oauth2.core.Client client)
        Sets the client associated with this request.
        Parameters:
        client - the client to associate with this request.