
public class RestHandlerHook extends Object implements io.cdap.http.HandlerHook
AbstractRestDbHandler when a
request is made. These hooks check the user authentication and privileges, as
well as the request content
type.| Constructor and Description |
|---|
RestHandlerHook(boolean authenticated,
HmacSha256 hmac,
long delay)
Creates a HandlerHook which will check for authentication and signature
on incoming request depending on
the parameters.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkAuthorization(String user,
Method method)
Checks if the user given as argument is authorized to call the given
method.
|
protected String |
checkCredentials(io.netty.handler.codec.http.HttpRequest request)
Checks if the user making the request does exist.
|
void |
postCall(io.netty.handler.codec.http.HttpRequest httpRequest,
io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus,
io.cdap.http.internal.HandlerInfo handlerInfo)
Hook called after a request handler is called.
|
boolean |
preCall(io.netty.handler.codec.http.HttpRequest request,
io.cdap.http.HttpResponder responder,
io.cdap.http.internal.HandlerInfo handlerInfo)
Hook called before a request handler is called.
|
protected void |
validateHMACCredentials(Host host,
String authDate,
String authUser,
String authKey) |
public RestHandlerHook(boolean authenticated,
HmacSha256 hmac,
long delay)
authenticated - specifies if the HandlerHook will check
authenticationhmac - the key used for HMAC authenticationdelay - the delay for which a HMAC signed request is validpublic final boolean preCall(io.netty.handler.codec.http.HttpRequest request,
io.cdap.http.HttpResponder responder,
io.cdap.http.internal.HandlerInfo handlerInfo)
preCall in interface io.cdap.http.HandlerHookrequest - the HttpRequest currently being processedresponder - the HttpResponder sending the responsehandlerInfo - the information about the handler to which the
request will be sent for processingtrue if the request can be handed to the handler, or
false if an error occurred and
a response must be sent immediately.protected final String checkCredentials(io.netty.handler.codec.http.HttpRequest request)
NotAllowedException.request - the request currently being processedInternalServerErrorException - if an unexpected error
occurredNotAllowedException - if the user making the request does
not existprotected final void validateHMACCredentials(Host host, String authDate, String authUser, String authKey) throws InternalServerErrorException
InternalServerErrorExceptionprotected final boolean checkAuthorization(String user, Method method)
user - the name of the user making the requestmethod - the method called by the requesttrue if the user is authorized to make the request,
false otherwise.public final void postCall(io.netty.handler.codec.http.HttpRequest httpRequest,
io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus,
io.cdap.http.internal.HandlerInfo handlerInfo)
postCall in interface io.cdap.http.HandlerHookhttpRequest - the request currently being processedhttpResponseStatus - the status of the http response
generated by the request handlerhandlerInfo - information about the handler to which the
request was sentCopyright © 2009–2022 Waarp. All rights reserved.