Package pyxmpp :: Package sasl :: Module external
[hide private]

Source Code for Module pyxmpp.sasl.external

 1  # 
 2  # (C) Copyright 2009 Michal Witkowski <neuro@o2.pl> 
 3  # 
 4  # This program is free software; you can redistribute it and/or modify 
 5  # it under the terms of the GNU Lesser General Public License Version 
 6  # 2.1 as published by the Free Software Foundation. 
 7  # 
 8  # This program is distributed in the hope that it will be useful, 
 9  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
11  # GNU Lesser General Public License for more details. 
12  # 
13  # You should have received a copy of the GNU Lesser General Public 
14  # License along with this program; if not, write to the Free Software 
15  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
16  # 
17  """External SASL authentication mechanism for PyXMPP SASL implementation. 
18   
19  Normative reference: 
20    - `RFC 3920bis <http://xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-08.html#security>`__ 
21    - `XEP-0178 <http://xmpp.org/extensions/xep-0178.html#c2s>__` 
22  """ 
23   
24  __docformat__="restructuredtext en" 
25   
26  import base64 
27   
28  import logging 
29   
30  from pyxmpp.sasl.core import (ClientAuthenticator,Failure,Response,Challenge,Success) 
31   
32 -class ExternalClientAuthenticator(ClientAuthenticator):
33 """Provides client-side External SASL (TLS-Identify) authentication.""" 34 35
36 - def __init__(self,password_manager):
37 ClientAuthenticator.__init__(self, password_manager) 38 self.password_manager = password_manager 39 self.__logger = logging.getLogger("pyxmpp.sasl.external.ExternalClientAuthenticator")
40
41 - def start(self, username, authzid):
42 self.username = username 43 self.authzid = authzid 44 # TODO: This isn't very XEP-0178'ish. 45 # XEP-0178 says "=" should be sent when only one id-on-xmppAddr is 46 # in the cert, but we don't know that. Still, this conforms to the 47 # standard and works. 48 return Response(self.authzid, encode = True)
49 #return Response("=", encode = False) 50
51 - def finish(self,data):
52 """Handle authentication success information from the server. 53 54 :Parameters: 55 - `data`: the optional additional data returned with the success. 56 :Types: 57 - `data`: `str` 58 59 :return: a success indicator. 60 :returntype: `Success`""" 61 _unused = data 62 return Success(self.username,None,self.authzid)
63 64 # vi: sts=4 et sw=4 65