public abstract class RestGuard extends Object
Guards are applied to REST methods declaratively through the @RestResource.guards()
or
@RestMethod.guards()
annotations.
If multiple guards are specified, ALL guards must pass in order for the request to proceed.
Implementers should simply throw a RestException
from the guard(RestRequest, RestResponse)
method to abort processing on the current request.
Guards must implement a no-args constructor.
Constructor and Description |
---|
RestGuard() |
Modifier and Type | Method and Description |
---|---|
boolean |
guard(RestRequest req,
RestResponse res)
Checks the current HTTP request and throws a
RestException if the guard does not permit the request. |
abstract boolean |
isRequestAllowed(RestRequest req)
Returns
|
public RestGuard()
public boolean guard(RestRequest req, RestResponse res) throws RestException
RestException
if the guard does not permit the request.
By default, throws an isRequestAllowed(RestRequest)
returns
Subclasses are free to override this method to tailor the behavior of how to handle unauthorized requests.
req
- The servlet request.res
- The servlet response.RestException
- Thrown to abort processing on current request.public abstract boolean isRequestAllowed(RestRequest req)
req
- The servlet request.Copyright © 2018 Apache. All rights reserved.