diff options
author | Gordon Sim <gsim@apache.org> | 2008-05-09 11:15:35 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-05-09 11:15:35 +0000 |
commit | 539672f9fa39dd22bb68fc50c22608aec2bdfe22 (patch) | |
tree | 5c78311f958e5bc45d90d02cb61c3274a0de651b /python/qpid/delegates.py | |
parent | 53428ae6d4d2705a5df7eda2d43fdfbc92da3670 (diff) | |
download | qpid-python-539672f9fa39dd22bb68fc50c22608aec2bdfe22.tar.gz |
Enabled PLAIN authentication and setting of username and password for 0-10 python client.
Added options to all command line tools to allow a username and password to be specified.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@654759 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/delegates.py')
-rw-r--r-- | python/qpid/delegates.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/python/qpid/delegates.py b/python/qpid/delegates.py index f31d9a0f09..cdff132219 100644 --- a/python/qpid/delegates.py +++ b/python/qpid/delegates.py @@ -52,6 +52,9 @@ class Delegate: def connection_close(self, ch, close): ch.connection_close_ok() self.connection.sock.close() + if not self.connection.opened: + self.connection.failed = True + notify(self.connection.condition) def connection_close_ok(self, ch, close_ok): self.connection.opened = False @@ -124,12 +127,19 @@ class Client(Delegate): "version": "development", "platform": os.name} + def __init__(self, connection, args={}): + Delegate.__init__(self, connection) + self.username = args.get('username', 'guest') + self.password = args.get('password', 'guest') + self.mechanism = args.get('mechanism', 'PLAIN') + def start(self): self.connection.write_header(self.spec.major, self.spec.minor) self.connection.read_header() def connection_start(self, ch, start): - ch.connection_start_ok(client_properties=Client.PROPERTIES, mechanism="ANONYMOUS") + r = "\0%s\0%s" % (self.username, self.password) + ch.connection_start_ok(client_properties=Client.PROPERTIES, mechanism=self.mechanism, response=r) def connection_tune(self, ch, tune): ch.connection_tune_ok() |