Class SecureApiRest
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,BasicUniversalConfig,DefaultConfig,DefaultHtmlConfig
Every op is gated by a fail-closed BearerTokenGuard backed by StubBearerTokenValidator: no token
or an unknown token is a 401 with a WWW-Authenticate: Bearer realm="petstore" challenge. On
success the resolved Principal reaches ops as an @Auth parameter.
Why a guard rather than a filter chain? AuthFilterChain composes several mechanisms and is
fail-open by design, so a downstream guard decides. With one mechanism, the op-level guard is the whole story.
Example:
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestServlet
RestServlet.Builder<R extends RestServlet,SELF extends RestServlet.Builder<R, SELF>>, RestServlet.DefaultBuilder<R extends RestServlet> -
Field Summary
Fields inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
PAGE_HEADER, TEMPLATESFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
builder, freemarker, store, twinMethods inherited from class org.apache.juneau.rest.server.servlet.RestServlet
builder, createAuthenticator, destroy, doLog, getContext, getPath, getPaths, getRequest, getResponse, getRestBuilder, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
SecureApiRest
public SecureApiRest()
-
-
Method Details
-
guards
Gates every op on this resource with a bearer-token guard.- Parameters:
bs- The bean store.- Returns:
- The guard list.
-
pets
- Returns:
- All pets.
-
pet
- Parameters:
id- The pet id.- Returns:
- The pet.
- Throws:
NotFound- If there is no such pet.
-
whoami
- Parameters:
caller- The authenticated principal (nevernull : the guard rejects anonymous calls first).- Returns:
{name: <principal>}.
-