Class SecureHandler
java.lang.Object
io.helidon.webserver.http.SecureHandler
- All Implemented Interfaces:
Handler, ProtocolUpgradeHandler, ServerLifecycle
A handler that enforces authentication and/or authorization.
When configured, it just validates that security was processed. If not, appropriate exception is thrown.
-
Method Summary
Modifier and TypeMethodDescriptionAdd authentication requirement and create a new handler with combined setup.andAuthorize(String... roleHint) Add authorization requirement and create a new handler with combined setup.static SecureHandlerCreate a security handler that enforces authentication.static SecureHandlerCreate a security handler that enforces authorization.voidhandle(ServerRequest req, ServerResponse res) Handle request.voidhandleProtocolUpgrade(ServerRequest req, ServerResponse res) Handle an HTTP/1 protocol upgrade request before the protocol switch.Creates a new handler that uses the configured security requirements and wraps an existing handler to be executed when security is checked.wrapLocator(HttpServiceLocator locator) Creates a new service locator that applies the configured security requirements to each located service.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ServerLifecycle
afterStart, afterStop, beforeStartModifier and TypeMethodDescriptiondefault voidafterStart(WebServer webServer) After server start.default voidAfter server stop.default voidBefore server start.
-
Method Details
-
authenticate
Create a security handler that enforces authentication.- Returns:
- a new handler that requires authentication
-
authorize
Create a security handler that enforces authorization.- Parameters:
roleHint- optional role names; when specified, the built-in security feature requires the user to be in at least one of these roles- Returns:
- a new handler that requires authorization
-
andAuthenticate
Add authentication requirement and create a new handler with combined setup.- Returns:
- a new handler that combines the existing authorization requirements and adds authentication requirement
-
andAuthorize
Add authorization requirement and create a new handler with combined setup.- Parameters:
roleHint- optional role names; when specified, the built-in security feature requires the user to be in at least one of these roles- Returns:
- a new handler that combines the existing authentication requirements and adds authorization requirement
-
wrap
-
wrapLocator
Creates a new service locator that applies the configured security requirements to each located service.WebServer uses the located service's original identity together with the complete security handler chain as the cache identity. The same service wrapped by different security handler instances therefore uses separate entries in the locator's cache, all bounded by
HttpServiceLocator.maxServiceCacheSize().- Parameters:
locator- service locator to wrap- Returns:
- a new wrapped service locator
-
handle
Description copied from interface:HandlerHandle request. This method must not return before the response is completed. If the method does asynchronous operations, it must wait for them to complete before returning. -
handleProtocolUpgrade
Description copied from interface:ProtocolUpgradeHandlerHandle an HTTP/1 protocol upgrade request before the protocol switch. The handler follows the same response contract as ordinary routing: callServerResponse.next()to allow the protocol switch, send a response to reject the switch, or reroute the request back to ordinary HTTP routing.- Specified by:
handleProtocolUpgradein interfaceProtocolUpgradeHandler- Parameters:
req- server requestres- server response- Throws:
Exception- in case of a processing error
-