You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/08/27 00:54:27 UTC
[12/50] [abbrv] tinkerpop git commit: fixed authentification code in
driver_remoteconnection
fixed authentification code in driver_remoteconnection
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/cb9d46a7
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/cb9d46a7
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/cb9d46a7
Branch: refs/heads/master
Commit: cb9d46a754b6d7ec1d6fce4e4626deabcc1c1fc0
Parents: 952c1c7
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Aug 24 15:41:09 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Aug 24 15:41:09 2016 -0600
----------------------------------------------------------------------
.../driver/driver_remote_connection.py | 41 +++++++++-----------
1 file changed, 19 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cb9d46a7/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index 58342a2..3651ec8 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -115,8 +115,7 @@ class DriverRemoteConnection(RemoteConnection):
"aliases": {"g": self.traversal_source}
}
}
- message = self._finalize_message(message)
- return message
+ return DriverRemoteConnection._finalize_message(message)
def _get_sideEffect_keys_message(self, request_id):
message = {
@@ -133,8 +132,7 @@ class DriverRemoteConnection(RemoteConnection):
}
}
}
- message = self._finalize_message(message)
- return message
+ return DriverRemoteConnection._finalize_message(message)
def _get_sideEffect_value_message(self, request_id, key):
message = {
@@ -153,24 +151,10 @@ class DriverRemoteConnection(RemoteConnection):
"aliases": {"g": self.traversal_source}
}
}
- message = self._finalize_message(message)
- return message
+ return DriverRemoteConnection._finalize_message(message)
- def _authenticate(self, username, password, processor):
- auth = b"".join([b"\x00", username.encode("utf-8"),
- b"\x00", password.encode("utf-8")])
- message = {
- "requestId": str(uuid.uuid4()),
- "op": "authentication",
- "processor": "",
- "args": {
- "sasl": base64.b64encode(auth).decode()
- }
- }
- message = self._finalize_message(message)
- self._ws.send_message(message, binary=True)
-
- def _finalize_message(self, message):
+ @staticmethod
+ def _finalize_message(message):
message = json.dumps(message)
mime_type = b"application/vnd.gremlin-v2.0+json"
mime_len = b"\x21"
@@ -184,6 +168,19 @@ class Response:
self._username = username
self._password = password
+ def _authenticate(self, username, password):
+ auth = b"".join([b"\x00", username.encode("utf-8"),
+ b"\x00", password.encode("utf-8")])
+ message = {
+ "requestId": str(uuid.uuid4()),
+ "op": "authentication",
+ "processor": "traversal",
+ "args": {
+ "sasl": base64.b64encode(auth).decode()
+ }
+ }
+ self._ws.send_message(DriverRemoteConnection._finalize_message(message), binary=True)
+
@gen.coroutine
def receive(self):
if self._closed:
@@ -197,7 +194,7 @@ class Response:
aggregateTo = "list" if "aggregateTo" not in meta else meta["aggregateTo"]
if status_code == 407:
- self._authenticate(self._username, self._password, self._processor)
+ self._authenticate(self._username, self._password)
yield self.receive()
elif status_code == 204:
self._closed = True