Package gofer :: Package messaging :: Module transport
[hide private]
[frames] | no frames]

Source Code for Module gofer.messaging.transport

 1  # 
 2  # Copyright (c) 2011 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU Lesser General Public 
 5  # License as published by the Free Software Foundation; either version 
 6  # 2 of the License (LGPLv2) or (at your option) any later version. 
 7  # There is NO WARRANTY for this software, express or implied, 
 8  # including the implied warranties of MERCHANTABILITY, 
 9  # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should 
10  # have received a copy of LGPLv2 along with this software; if not, see 
11  # http://www.gnu.org/licenses/old-licenses/lgpl-2.0.txt. 
12  # 
13  # Jeff Ortel <jortel@redhat.com> 
14  # 
15   
16  """ 
17  Contains custom QPID transport classes. 
18  """ 
19   
20  import ssl 
21  from gofer.messaging.broker import Broker 
22  from qpid.messaging.transports import connect, TRANSPORTS, tls 
23  from logging import getLogger 
24   
25  log = getLogger(__name__) 
26   
27   
28 -class SSL(tls):
29 """ 30 SSL Transport. 31 Extends L{tls} to support client certificates. 32 """ 33
34 - def __init__(self, *args):
35 """ 36 @param args: The argument list. 37 Using arglist for compatability with many versions 38 For <= 0.8 passed (host, port) 39 For 0.10 (el6) passed (con, host, port) 40 @type args: list 41 """ 42 host, port = args[-2:] 43 url = ':'.join((host,str(port))) 44 broker = Broker(url) 45 if broker.cacert: 46 reqcert = ssl.CERT_REQUIRED 47 else: 48 reqcert = ssl.CERT_NONE 49 self.socket = connect(host, port) 50 self.tls = \ 51 ssl.wrap_socket( 52 self.socket, 53 cert_reqs=reqcert, 54 ca_certs=broker.cacert, 55 certfile=broker.clientcert) 56 self.socket.setblocking(0) 57 self.state = None
58 59 # 60 # Install the transport. 61 # 62 TRANSPORTS['ssl'] = SSL 63