[CalendarServer-changes] [3504] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 10 12:55:35 PST 2008
Revision: 3504
http://trac.macosforge.org/projects/calendarserver/changeset/3504
Author: sagen at apple.com
Date: 2008-12-10 12:55:34 -0800 (Wed, 10 Dec 2008)
Log Message:
-----------
Fix to allow the XMPP notifier to connect to chat server using TLS/SASL (or plain-old SSL if port 5223 is specified in plist)
Modified Paths:
--------------
CalendarServer/trunk/lib-patches/Twisted/twisted.words.protocols.jabber.sasl_mechanisms.patch
CalendarServer/trunk/twistedcaldav/notify.py
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.words.protocols.jabber.sasl_mechanisms.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.words.protocols.jabber.sasl_mechanisms.patch 2008-12-10 19:16:36 UTC (rev 3503)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.words.protocols.jabber.sasl_mechanisms.patch 2008-12-10 20:55:34 UTC (rev 3504)
@@ -17,16 +17,68 @@
from zope.interface import Interface, Attribute, implements
class ISASLMechanism(Interface):
-@@ -153,7 +158,7 @@
+@@ -108,16 +113,43 @@
+ @return: challenge directives and their values.
+ @rtype: L{dict} of L{str} to L{str}.
"""
+- directive_list = challenge.split(',')
+- directives = {}
+- for directive in directive_list:
+- name, value = directive.split('=')
+- value = value.replace("'","")
+- value = value.replace('"','')
+- directives[name] = value
+- return directives
++ s = challenge
++ paramDict = {}
++ cur = 0
++ remainingParams = True
++ while remainingParams:
++ # Parse a param. We can't just split on commas, because there can
++ # be some commas inside (quoted) param values, e.g.:
++ # qop="auth,auth-int"
++ middle = s.index("=", cur)
++ name = s[cur:middle].lstrip()
++ middle += 1
++ if s[middle] == '"':
++ middle += 1
++ end = s.index('"', middle)
++ value = s[middle:end]
++ cur = s.find(',', end) + 1
++ if cur == 0:
++ remainingParams = False
++ else:
++ end = s.find(',', middle)
++ if end == -1:
++ value = s[middle:].rstrip()
++ remainingParams = False
++ else:
++ value = s[middle:end].rstrip()
++ cur = end + 1
++ paramDict[name] = value
+
++ for param in ('qop', 'cipher'):
++ if param in paramDict:
++ paramDict[param] = paramDict[param].split(',')
++
++ return paramDict
++
++
++
+ def _unparse(self, directives):
+ """
+ Create message string from directives.
+@@ -153,7 +185,7 @@
+ """
+
def H(s):
- return md5.new(s).digest()
+ return md5(s).digest()
def HEX(n):
return binascii.b2a_hex(n)
-@@ -196,4 +201,4 @@
+@@ -196,4 +228,4 @@
def _gen_nonce(self):
Modified: CalendarServer/trunk/twistedcaldav/notify.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/notify.py 2008-12-10 19:16:36 UTC (rev 3503)
+++ CalendarServer/trunk/twistedcaldav/notify.py 2008-12-10 20:55:34 UTC (rev 3504)
@@ -37,6 +37,7 @@
from twisted.internet.protocol import ReconnectingClientFactory, ServerFactory
from twisted.internet.address import IPv4Address
+from twisted.internet.ssl import ClientContextFactory
from twisted.internet.defer import inlineCallbacks, Deferred
from twisted.protocols.basic import LineReceiver
from twisted.plugin import IPlugin
@@ -45,7 +46,7 @@
from twisted.python.reflect import namedClass
from twisted.words.protocols.jabber import xmlstream
from twisted.words.protocols.jabber.jid import JID
-from twisted.words.protocols.jabber.client import BasicAuthenticator
+from twisted.words.protocols.jabber.client import XMPPAuthenticator, IQAuthInitializer
from twisted.words.protocols.jabber.xmlstream import IQ
from twisted.words.xish import domish
from twistedcaldav.log import LoggingMixIn
@@ -1089,16 +1090,16 @@
self.reactor = reactor
xmlstream.XmlStreamFactory.__init__(self,
- BasicAuthenticator(JID(self.jid), settings['Password']))
+ XMPPAuthenticator(JID(self.jid), settings['Password']))
self.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT, self.connected)
self.addBootstrap(xmlstream.STREAM_END_EVENT, self.disconnected)
self.addBootstrap(xmlstream.INIT_FAILED_EVENT, self.initFailed)
self.addBootstrap(xmlstream.STREAM_AUTHD_EVENT, self.authenticated)
- self.addBootstrap(BasicAuthenticator.INVALID_USER_EVENT,
+ self.addBootstrap(IQAuthInitializer.INVALID_USER_EVENT,
self.authFailed)
- self.addBootstrap(BasicAuthenticator.AUTH_FAILED_EVENT,
+ self.addBootstrap(IQAuthInitializer.AUTH_FAILED_EVENT,
self.authFailed)
def connected(self, xmlStream):
@@ -1327,9 +1328,16 @@
def __init__(self, settings):
self.notifier = XMPPNotifier(settings)
- self.client = internet.TCPClient(settings["Host"], settings["Port"],
- XMPPNotificationFactory(self.notifier, settings))
+ if settings["Port"] == 5223: # use old SSL method
+ self.client = internet.SSLClient(settings["Host"], settings["Port"],
+ XMPPNotificationFactory(self.notifier, settings),
+ ClientContextFactory())
+ else:
+ # TLS and SASL
+ self.client = internet.TCPClient(settings["Host"], settings["Port"],
+ XMPPNotificationFactory(self.notifier, settings))
+
def enqueue(self, op, uri):
self.notifier.enqueue(op, uri)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081210/440db903/attachment.html>
More information about the calendarserver-changes
mailing list