Repository: incubator-ignite Updated Branches: refs/heads/ignite-gg-10561 55806b9f0 -> dbe2798cb
# gg-10561: self-review Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/dbe2798c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/dbe2798c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/dbe2798c Branch: refs/heads/ignite-gg-10561 Commit: dbe2798cb0370a5ce24a651909ed36ed94f2d14c Parents: 55806b9 Author: ashutak <ashu...@gridgain.com> Authored: Thu Jul 23 20:12:38 2015 +0300 Committer: ashutak <ashu...@gridgain.com> Committed: Thu Jul 23 20:12:38 2015 +0300 ---------------------------------------------------------------------- .../processors/rest/GridRestProcessor.java | 31 +++++--------------- .../http/jetty/GridJettyRestHandler.java | 9 ------ 2 files changed, 7 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbe2798c/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java index fcdc579..99e3a8a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java @@ -64,7 +64,7 @@ public class GridRestProcessor extends GridProcessorAdapter { /** Delay between sessions timeout checks*/ private static final int SES_TIMEOUT_CHECK_DELAY = 1_000; - /** */ + /** Default session timout */ private static final int DEFAULT_SES_TIMEOUT = 30_000; /** Protocols. */ @@ -185,9 +185,9 @@ public class GridRestProcessor extends GridProcessorAdapter { if (log.isDebugEnabled()) log.debug("Received request from client: " + req); - Session ses = null; - if (ctx.security().enabled()) { + Session ses; + try { ses = session(req); } @@ -203,7 +203,7 @@ public class GridRestProcessor extends GridProcessorAdapter { req.sessionToken(ses.sesTok()); if (log.isDebugEnabled()) - log.debug("Next clientId and sessionToken were extracted from request: " + + log.debug("Next clientId and sessionToken were extracted according to request: " + "[clientId="+req.clientId()+", sessionToken="+Arrays.toString(req.sessionToken())+"]"); try { @@ -236,8 +236,6 @@ public class GridRestProcessor extends GridProcessorAdapter { return new GridFinishedFuture<>( new IgniteCheckedException("Failed to find registered handler for command: " + req.command())); - final SecurityContext subjCtx0 = ses == null ? null : ses.secCtx; - return res.chain(new C1<IgniteInternalFuture<GridRestResponse>, GridRestResponse>() { @Override public GridRestResponse apply(IgniteInternalFuture<GridRestResponse> f) { GridRestResponse res; @@ -257,11 +255,8 @@ public class GridRestProcessor extends GridProcessorAdapter { assert res != null; - if (ctx.security().enabled()) { - // TODO review. Why we update it here, not earlier? -// updateSession(req, subjCtx0); + if (ctx.security().enabled()) res.sessionTokenBytes(req.sessionToken()); - } interceptResponse(res, req); @@ -621,7 +616,8 @@ public class GridRestProcessor extends GridProcessorAdapter { * @throws IgniteCheckedException If authentication failed. */ private SecurityContext authenticate(GridRestRequest req) throws IgniteCheckedException { - // Authenticate client if invalid session. + assert req.clientId() != null; + AuthenticationContext authCtx = new AuthenticationContext(); authCtx.subjectType(REMOTE_CLIENT); @@ -652,7 +648,6 @@ public class GridRestProcessor extends GridProcessorAdapter { SecurityContext subjCtx = ctx.security().authenticate(authCtx); - // TODO review if (subjCtx == null) { if (req.credentials() == null) throw new IgniteCheckedException("Failed to authenticate remote client (secure session SPI not set?): " + req); @@ -664,18 +659,6 @@ public class GridRestProcessor extends GridProcessorAdapter { } /** - * Update session. - * @param req REST request. - * @param sCtx Security context. - */ - private void updateSession(GridRestRequest req, SecurityContext sCtx) { -// if (sCtx != null) { -// sesMap.put(req.clientId(), sCtx); -// -// } - } - - /** * @param req REST request. * @param sCtx Security context. * @throws SecurityException If authorization failed. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbe2798c/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java ---------------------------------------------------------------------- diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java index 8af0832..fac9818 100644 --- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java +++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java @@ -249,25 +249,18 @@ public class GridJettyRestHandler extends AbstractHandler { Map<String, Object> params = parameters(req); try { - U.dumpStack("JettyHandler#processRequest cmd=" + cmd + ", params=" + params + " req=" + req); - GridRestRequest cmdReq = createRequest(cmd, params, req); if (log.isDebugEnabled()) log.debug("Initialized command request: " + cmdReq); - U.dumpStack(">>>>> Before handle"); - cmdRes = hnd.handle(cmdReq); if (cmdRes == null) throw new IllegalStateException("Received null result from handler: " + hnd); - // TODO review. byte[] sesTok = cmdRes.sessionTokenBytes(); - U.dumpStack(">>>>> TODO review. sesTok=" + Arrays.toString(sesTok)); - if (sesTok != null) cmdRes.setSessionToken(U.byteArray2HexString(sesTok)); @@ -474,8 +467,6 @@ public class GridJettyRestHandler extends AbstractHandler { try { if (clientId != null) restReq.clientId(UUID.fromString(clientId)); -// else -// restReq.clientId(UUID.randomUUID()); } catch (Exception ignored) { // Ignore invalid client id. Rest handler will process this logic.