Interface OAuthApplication

  • All Superinterfaces:
    org.eclipse.lyo.server.oauth.core.Application
    All Known Implementing Classes:
    AbstractOAuthApplication

    public interface OAuthApplication
    extends org.eclipse.lyo.server.oauth.core.Application
    Handles authentication with the backend system.

    An instance of OAuthApplication is created by OAuthFilter when the server is initialized. It is then accessible using OAuthConfiguration.getInstance().getApplication().

    Clients may implement this interface.

    Since:
    1.3.0
    See Also:
    OAuthFilter.createOAuthApplication(ServletContext)
    • Method Detail

      • logout

        Response logout​(HttpServletRequest request)
        Logs out the currently connected user.

        Note this method is not called by the OAuthFilter class. If logout is to be supported by a server application, the application must define a logout servlet on its own calling this method.

        Parameters:
        request - the servlet request.
        Returns:
        the response of the logout.
      • sendUnauthorized

        void sendUnauthorized​(HttpServletRequest request,
                              HttpServletResponse response)
                       throws IOException,
                              ServletException
        Sends an authorize response, in the event the the user is not yet connected to the application. Implementation is recommended to send WWW-Authenticate headers or to forward to a login page if HTML content is requested.
        Parameters:
        request - the servlet request.
        response - the servlet response.
        Throws:
        IOException - if an error occurs while writing the response.
        ServletException - if an error occurs while producing the response.
      • getTwoLeggedOAuthIdentity

        Optional<OAuthIdentity> getTwoLeggedOAuthIdentity​(HttpServletRequest request,
                                                          org.eclipse.lyo.server.oauth.core.consumer.LyoOAuthConsumer consumer)
                                                   throws org.eclipse.lyo.server.oauth.core.utils.UnauthorizedException
        Gets the OAuthIdentity for a consumer's functional user if it has one.
        Parameters:
        request - the servlet request.
        consumer - the consumer used for two legged OAuth.
        Returns:
        an OAuthIdentity representing the functional user associated to the consumer, Optional.empty() if no functional user is associated to the consumer.
        Throws:
        org.eclipse.lyo.server.oauth.core.utils.UnauthorizedException - if a functional user is associated to the consumer but this user cannot be found
        Since:
        3.1.0