use of it.unibo.arces.wot.sepa.commons.security.ClientAuthorization in project SEPA by arces-wot.
the class Gate method onMessage.
public final void onMessage(String message) throws SEPAProtocolException, SEPASecurityException, SEPASparqlParsingException {
// Authorize the request
ClientAuthorization auth = authorize(message);
if (!auth.isAuthorized()) {
ErrorResponse error = new ErrorResponse(401, auth.getError(), auth.getDescription());
setAliasIfPresent(error, message);
sendResponse(error);
return;
}
// Parse the request
InternalRequest req = parseRequest(message, auth);
if (req instanceof InternalDiscardRequest) {
logger.error("@onMessage " + getGID() + " failed to parse message: " + message);
setAliasIfPresent(((InternalDiscardRequest) req).getError(), message);
sendResponse(((InternalDiscardRequest) req).getError());
return;
}
// Schedule the request
logger.trace("@onMessage: " + getGID() + " schedule request: " + req);
ScheduledRequest request = scheduler.schedule(req, this);
// Request not scheduled
if (request == null) {
logger.error("@onMessage: " + getGID() + " out of tokens");
ErrorResponse response = new ErrorResponse(500, "too_many_requests", "Too many pending requests");
setAliasIfPresent(response, message);
sendResponse(response);
}
}
Aggregations