Class PushHttpHandler
POST /iizi-push/<func> endpoints of WIRE-CONTRACT §1, implemented to the client as it is: keys, get_subs, subscribe, unsubscribe and push.The common front door (§0.3, §4.1): POST only; the X-iizi header is the device UUID and must parse, else 400; the body is JSON, else 400; a reply is application/json;charset=utf-8 with no caching, always a non-empty object, because the client treats an empty 200 as a failure. A failure carries its status and an error member the client never shows (§7.27) but a log or a curl does.
Authentication is delegated to an PushHttpHandler.Authenticator: Authorization: Basic (the header the client sends; the severed handler read Authentication, §7.7) against the server's users. What happens when the client sends no credentials over plain http (§7.5) is the authenticator's policy.
Names: application ID and Topic are validated with Utilities.getValidName and the returned string is what is stored and looked up (ruling S-C11). * is the iiziRun application; the empty Topic is the application-level subscription (§7.11: the client sends "", and that is what is stored).
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAuthenticates a request and decides who may push.static final classA refused authentication, with the HTTP status to answer.static final recordAn authenticated caller.Field Summary
FieldsConstructor Summary
ConstructorsConstructorDescriptionPushHttpHandler(PushEngine engine, PushHttpHandler.Authenticator authenticator) Constructor.Method Summary
Modifier and TypeMethodDescriptionvoidhandle(String func, HttpServletRequest request, HttpServletResponse response, PrintWriter out) Handles one request.
Field Details
HEADER_DEVICE
Constructor Details
PushHttpHandler
Constructor.- Parameters:
engine- The started engine.authenticator- The authenticator.
Method Details
handle
public void handle(String func, HttpServletRequest request, HttpServletResponse response, PrintWriter out) throws IOException Handles one request.- Parameters:
func- The endpoint name:keys,get_subs,subscribe,unsubscribeorpush.request- The request.response- The response.out- The writer of the response.- Throws:
IOException- For I/O errors.