authorize(req, subjCtx);
}
catch (GridSecurityException e) {
assert subjCtx != null;
GridRestResponse res = new GridRestResponse(STATUS_SECURITY_CHECK_FAILED, e.getMessage());
if (ctx.isEnterprise()) {
try {
res.sessionTokenBytes(updateSessionToken(req, subjCtx));
}
catch (GridException e1) {
U.warn(log, "Cannot update response session token: " + e1.getMessage());
}
}
return new GridFinishedFuture<>(ctx, res);
}
catch (GridException e) {
return new GridFinishedFuture<>(ctx, new GridRestResponse(STATUS_AUTH_FAILED, e.getMessage()));
}
interceptRequest(req);
GridRestCommandHandler hnd = handlers.get(req.command());
GridFuture<GridRestResponse> res = hnd == null ? null : hnd.handleAsync(req);
if (res == null)
return new GridFinishedFuture<>(ctx,
new GridException("Failed to find registered handler for command: " + req.command()));
final GridSecurityContext subjCtx0 = subjCtx;
return res.chain(new C1<GridFuture<GridRestResponse>, GridRestResponse>() {
@Override public GridRestResponse apply(GridFuture<GridRestResponse> f) {
GridRestResponse res;
try {
res = f.get();
}
catch (Exception e) {
LT.error(log, e, "Failed to handle request: " + req.command());
if (log.isDebugEnabled())
log.debug("Failed to handle request [req=" + req + ", e=" + e + "]");
res = new GridRestResponse(STATUS_FAILED, e.getMessage());
}
assert res != null;
if (ctx.secureSession().enabled()) {
try {
res.sessionTokenBytes(updateSessionToken(req, subjCtx0));
}
catch (GridException e) {
U.warn(log, "Cannot update response session token: " + e.getMessage());
}
}