You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by da...@apache.org on 2017/01/16 16:18:02 UTC

tinkerpop git commit: updated auth code in protocol

Repository: tinkerpop
Updated Branches:
  refs/heads/python_driver 3b1a347c7 -> 44050ecfa


updated auth code in protocol


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/44050ecf
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/44050ecf
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/44050ecf

Branch: refs/heads/python_driver
Commit: 44050ecfa8853c9f1e247a81c3e002f7815a4ff3
Parents: 3b1a347
Author: davebshow <da...@gmail.com>
Authored: Mon Jan 16 11:17:50 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Mon Jan 16 11:17:50 2017 -0500

----------------------------------------------------------------------
 .../jython/gremlin_python/driver/protocol.py     | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/44050ecf/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index a8f183b..75cf684 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -23,7 +23,7 @@ import uuid
 
 import six
 
-from gremlin_python.driver import serializer
+from gremlin_python.driver import serializer, request
 
 
 @six.add_metaclass(abc.ABCMeta)
@@ -65,11 +65,15 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
         aggregate_to = data['result']['meta'].get('aggregateTo', 'list')
         result_set._aggregate_to = aggregate_to
         if status_code == 407:
-            self._authenticate(request_id)
+            auth = b''.join([b'\x00', self.username.encode('utf-8'),
+                             b'\x00', self.password.encode('utf-8')])
+            request_message = request.RequestMessage(
+                'traversal', 'authentication',
+                {'sasl': base64.b64encode(auth).decode()})
+            self.write(request_id, request_message)
             data = self._transport.read()
             self.data_received(data, results_dict)
         elif status_code == 204:
-            # result_set.stream.put_nowait([None])
             result_set.done.set_result(None)
             del results_dict[request_id]
         elif status_code in [200, 206]:
@@ -89,12 +93,3 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
                 "{0}: {1}".format(status_code, data["status"]["message"])))
             result_set.done.set_result(None)
             del results_dict[request_id]
-
-    def _authenticate(self, request_id):
-        auth = b''.join([b'\x00', self.username.encode('utf-8'),
-                         b'\x00', self.password.encode('utf-8')])
-        args = {'sasl': base64.b64encode(auth).decode(),
-                'saslMechanism': 'PLAIN'}
-        message = self._message_serializer.serialize_message(
-            request_id, '', 'authentication', **args)
-        self._transport.write(message)