Repository: ignite
Updated Branches:
  refs/heads/ignite-8201 [created] 5a1d8a059


IGNITE-8201 WIP


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5a1d8a05
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5a1d8a05
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5a1d8a05

Branch: refs/heads/ignite-8201
Commit: 5a1d8a059276df3ffb709c8b39781b91045ff6fa
Parents: a64b941
Author: Alexey Kuznetsov <akuznet...@apache.org>
Authored: Tue Apr 10 17:37:09 2018 +0700
Committer: Alexey Kuznetsov <akuznet...@apache.org>
Committed: Tue Apr 10 17:37:09 2018 +0700

----------------------------------------------------------------------
 .../processors/rest/GridRestCommand.java        |  3 ++
 .../http/jetty/GridJettyRestHandler.java        | 43 +++++++++++++++-----
 2 files changed, 36 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5a1d8a05/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
index 0b9a662..265fe40 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
@@ -169,6 +169,9 @@ public enum GridRestCommand {
     CLUSTER_CURRENT_STATE("currentstate"),
 
     /** */
+    AUTHENTICATE("authenticate"),
+
+    /** */
     ADD_USER("adduser"),
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a1d8a05/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 b3fbddd..f784492 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
@@ -86,6 +86,12 @@ public class GridJettyRestHandler extends AbstractHandler {
     private static final String CHARSET = StandardCharsets.UTF_8.name();
 
     /** */
+    private static final String  USER_PARAM = "user";
+
+    /** */
+    private static final String  PWD_PARAM = "password";
+
+    /** */
     private static final String  CACHE_NAME_PARAM = "cacheName";
 
     /** */
@@ -100,11 +106,11 @@ public class GridJettyRestHandler extends AbstractHandler 
{
     /** */
     private static final String WRITE_SYNCHRONIZATION_MODE_PARAM = 
"writeSynchronizationMode";
 
-    /** */
-    private static final String IGNITE_LOGIN = "ignite.login";
+    /** @deprecated Use USER_PARAM instead. */
+    private static final String IGNITE_LOGIN_PARAM = "ignite.login";
 
-    /** */
-    private static final String IGNITE_PASSWORD = "ignite.password";
+    /** @deprecated Use PWD_PARAM instead. */
+    private static final String IGNITE_PASSWORD_PARAM = "ignite.password";
 
     /** */
     private static final String  TEMPLATE_NAME_PARAM = "templateName";
@@ -840,12 +846,8 @@ public class GridJettyRestHandler extends AbstractHandler {
 
         restReq.command(cmd);
 
-        if (params.containsKey(IGNITE_LOGIN) || 
params.containsKey(IGNITE_PASSWORD)) {
-            SecurityCredentials cred = new SecurityCredentials(
-                (String)params.get(IGNITE_LOGIN), 
(String)params.get(IGNITE_PASSWORD));
-
-            restReq.credentials(cred);
-        }
+        if (!credentials(params, USER_PARAM, PWD_PARAM, restReq))
+            credentials(params, IGNITE_LOGIN_PARAM, IGNITE_PASSWORD_PARAM, 
restReq);
 
         String clientId = (String)params.get("clientId");
 
@@ -881,6 +883,27 @@ public class GridJettyRestHandler extends AbstractHandler {
     }
 
     /**
+     *
+     * @param params Parameters.
+     * @param userParam Parameter name to take user name.
+     * @param pwdParam Parameter name to take password.
+     * @param restReq Request to add credentials if any.
+     * @return {@code true} If params contains credentials.
+     */
+    private boolean credentials(Map<String, Object> params, String userParam, 
String pwdParam, GridRestRequest restReq) {
+        boolean hasCreds = params.containsKey(userParam) || 
params.containsKey(pwdParam);
+
+        if (hasCreds) {
+            SecurityCredentials cred = new 
SecurityCredentials((String)params.get(userParam),
+                (String)params.get(pwdParam));
+
+            restReq.credentials(cred);
+        }
+
+        return hasCreds;
+    }
+
+    /**
      * Gets values referenced by sequential keys, e.g. {@code key1...keyN}.
      *
      * @param type Optional value type.

Reply via email to