summaryrefslogtreecommitdiffstats
path: root/src/console/zmq/auth/ioloop.py
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2015-08-23 15:26:27 +0300
committerHanoh Haim <hhaim@cisco.com>2015-08-23 15:26:27 +0300
commit449198c97d2794b44b461093265637522b7a64b4 (patch)
tree36eb68c83b907474f507f5e8cde72856e29414bb /src/console/zmq/auth/ioloop.py
parentb156bb3ae7382481ed5f15e42d87cd3012870da5 (diff)
parent8384612b8493a4a896e91e3bb9d5d25689a87c12 (diff)
rpc integration
Diffstat (limited to 'src/console/zmq/auth/ioloop.py')
-rwxr-xr-xsrc/console/zmq/auth/ioloop.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/console/zmq/auth/ioloop.py b/src/console/zmq/auth/ioloop.py
new file mode 100755
index 00000000..1f448b47
--- /dev/null
+++ b/src/console/zmq/auth/ioloop.py
@@ -0,0 +1,34 @@
+"""ZAP Authenticator integrated with the tornado IOLoop.
+
+.. versionadded:: 14.1
+"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+from zmq.eventloop import ioloop, zmqstream
+from .base import Authenticator
+
+
+class IOLoopAuthenticator(Authenticator):
+ """ZAP authentication for use in the tornado IOLoop"""
+
+ def __init__(self, context=None, encoding='utf-8', log=None, io_loop=None):
+ super(IOLoopAuthenticator, self).__init__(context)
+ self.zap_stream = None
+ self.io_loop = io_loop or ioloop.IOLoop.instance()
+
+ def start(self):
+ """Start ZAP authentication"""
+ super(IOLoopAuthenticator, self).start()
+ self.zap_stream = zmqstream.ZMQStream(self.zap_socket, self.io_loop)
+ self.zap_stream.on_recv(self.handle_zap_message)
+
+ def stop(self):
+ """Stop ZAP authentication"""
+ if self.zap_stream:
+ self.zap_stream.close()
+ self.zap_stream = None
+ super(IOLoopAuthenticator, self).stop()
+
+__all__ = ['IOLoopAuthenticator']