Class SecureRest

java.lang.Object
jakarta.servlet.GenericServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable, BasicUniversalConfig, DefaultConfig, DefaultHtmlConfig

public class SecureRest extends PetstoreConsolePage
Secure: an open console page demonstrating the bearer-token guarded SecureApiRest.

The page's "Try it" card calls /console/dev/secure/api/whoami from the browser with no token, the demo token or a wrong token, and shows the status and body inline. The demo tokens come from StubBearerTokenValidator: petstore-user (alice) and petstore-admin (admin).

Example:

<@page tab="dev/secure" init=["/console/dev/secure/secure.js"]> <@card id="try" title="Try it"> <button type="button" data-secure-call="petstore-user">With the demo token</button> <output id="secure-result"></output> </@card> </@page>

See Also:
  • Constructor Details

  • Method Details

    • page

      public View page(RestRequest req)
      The Secure page.
      Parameters:
      req - The request; ?builder renders the builder twin.
      Returns:
      The page.
    • script

      public void script(RestResponse res) throws IOException
      Serves the page-local script.
      Parameters:
      res - The response.
      Throws:
      IOException - If the bundled script can't be read.