You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2015/10/02 20:59:39 UTC
qpid-proton git commit: PROTON-1008: add toggle for sasl layer
Repository: qpid-proton
Updated Branches:
refs/heads/master fe0817e2a -> baaf74ab7
PROTON-1008: add toggle for sasl layer
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/baaf74ab
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/baaf74ab
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/baaf74ab
Branch: refs/heads/master
Commit: baaf74ab7ab4ff699cbde374db1fdc2006eede0a
Parents: fe0817e
Author: Gordon Sim <gs...@redhat.com>
Authored: Tue Sep 29 22:48:37 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri Oct 2 20:02:06 2015 +0100
----------------------------------------------------------------------
proton-c/bindings/python/proton/reactor.py | 54 +++++++++++++++++++------
1 file changed, 42 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/baaf74ab/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 8de5d89..b8e4b6a 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -497,6 +497,7 @@ class Connector(Handler):
self.ssl_domain = None
self.allow_insecure_mechs = True
self.allowed_mechs = None
+ self.sasl_enabled = True
def _connect(self, connection):
url = self.address.next()
@@ -505,17 +506,15 @@ class Connector(Handler):
logging.info("connecting to %s..." % connection.hostname)
transport = Transport()
- sasl = None
- if url.username:
- connection.user = url.username
+ if self.sasl_enabled:
sasl = transport.sasl()
sasl.allow_insecure_mechs = self.allow_insecure_mechs
- if url.password:
- connection.password = url.password
- if self.allowed_mechs:
- if sasl == None:
- sasl = transport.sasl()
- sasl.allowed_mechs(self.allowed_mechs)
+ if url.username:
+ connection.user = url.username
+ if url.password:
+ connection.password = url.password
+ if self.allowed_mechs:
+ sasl.allowed_mechs(self.allowed_mechs)
transport.bind(connection)
if self.heartbeat:
transport.idle_timeout = self.heartbeat
@@ -623,19 +622,50 @@ class Container(Reactor):
self.container_id = str(generate_uuid())
self.allow_insecure_mechs = True
self.allowed_mechs = None
+ self.sasl_enabled = True
Wrapper.__setattr__(self, 'subclass', self.__class__)
- def connect(self, url=None, urls=None, address=None, handler=None, reconnect=None, heartbeat=None, ssl_domain=None):
+ def connect(self, url=None, urls=None, address=None, handler=None, reconnect=None, heartbeat=None, ssl_domain=None, **kwargs):
"""
Initiates the establishment of an AMQP connection. Returns an
instance of proton.Connection.
+
+ @param url: URL string of process to connect to
+
+ @param urls: list of URL strings of process to try to connect to
+
+ Only one of url or urls should be specified.
+
+ @param reconnect: A value of False will prevent the library
+ form automatically trying to reconnect if the underlying
+ socket is disconnected before the connection has been closed.
+
+ @param heartbeat: A value in milliseconds indicating the
+ desired frequency of heartbeats used to test the underlying
+ socket is alive.
+
+ @param ssl_domain: SSL configuration in the form of an
+ instance of proton.SSLdomain.
+
+ @param handler: a connection scoped handler that will be
+ called to process any events in the scope of this connection
+ or its child links
+
+ @param kwargs: sasl_enabled, which determines whether a sasl
+ layer is used for the connection; allowed_mechs an optional
+ list of SASL mechanisms to allow if sasl is enabled;
+ allow_insecure_mechs a flag indicating whether insecure
+ mechanisms, such as PLAIN over a non-encrypted socket, are
+ allowed. These options can also be set at container scope.
+
"""
conn = self.connection(handler)
conn.container = self.container_id or str(generate_uuid())
connector = Connector(conn)
- connector.allow_insecure_mechs = self.allow_insecure_mechs
- connector.allowed_mechs = self.allowed_mechs
+ connector.allow_insecure_mechs = kwargs.get('allow_insecure_mechs', self.allow_insecure_mechs)
+ connector.allowed_mechs = kwargs.get('allowed_mechs', self.allowed_mechs)
+ connector.sasl_enabled = kwargs.get('sasl_enabled', self.sasl_enabled)
conn._overrides = connector
if url: connector.address = Urls([url])
elif urls: connector.address = Urls(urls)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org