[CalendarServer-changes] [367] CalendarServer/trunk/twistedcaldav/directory/cred.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 3 15:14:20 PST 2006


Revision: 367
          http://trac.macosforge.org/projects/calendarserver/changeset/367
Author:   wsanchez at apple.com
Date:     2006-11-03 15:14:20 -0800 (Fri, 03 Nov 2006)

Log Message:
-----------
Go with the old implementation for now, so we have a working version.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/cred.py

Modified: CalendarServer/trunk/twistedcaldav/directory/cred.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cred.py	2006-11-03 23:13:50 UTC (rev 366)
+++ CalendarServer/trunk/twistedcaldav/directory/cred.py	2006-11-03 23:14:20 UTC (rev 367)
@@ -32,26 +32,45 @@
 from twistedcaldav import customxml
 
 class DirectoryCredentialsChecker (TwistedPropertyChecker):
-    def __init__(self, service):
-        """
-        @param service: an L{IDirectoryService} provider.
-        """
-        self.service = service
 
     def requestAvatarId(self, credentials):
+
         # If there is no calendar principal URI then the calendar user is disabled.
-        credentials = IPrincipalCredentials(credentials)
-        if not credentials.authnPrincipal.hasDeadProperty(customxml.TwistedCalendarPrincipalURI):
+        pcreds = IPrincipalCredentials(credentials)
+        if not pcreds.authnPrincipal.hasDeadProperty(customxml.TwistedCalendarPrincipalURI):
             # Try regular password check
             return TwistedPropertyChecker.requestAvatarId(self, credentials)
 
-        user = self.service.userWithShortName(credentials.credentials.username)
-        raise UnauthorizedLogin("Unknown credentials type for principal: %s" % (credentials.authnURI,))
+        creds = pcreds.credentials
+        if isinstance(creds, UsernamePassword):
+            user = creds.username
+            pswd = creds.password
+            if opendirectory.authenticateUser(pcreds.authnPrincipal.directory(), user, pswd):
+                return succeed((pcreds.authnURI, pcreds.authzURI,))
+        
+        raise error.UnauthorizedLogin("Bad credentials for: %s" % (pcreds.authnURI,))
 
-        if not user:
-            raise UnauthorizedLogin("No such user: %s" % (user,))
-
-        if user.authenticate(credentials.credentials):
-            return succeed((credentials.authnURI, credentials.authzURI))
-        else:
-            raise UnauthorizedLogin("Incorrect credentials for user: %s" % (user,)) 
+#class DirectoryCredentialsChecker (TwistedPropertyChecker):
+#    def __init__(self, service):
+#        """
+#        @param service: an L{IDirectoryService} provider.
+#        """
+#        self.service = service
+#
+#    def requestAvatarId(self, credentials):
+#        # If there is no calendar principal URI then the calendar user is disabled.
+#        credentials = IPrincipalCredentials(credentials)
+#        if not credentials.authnPrincipal.hasDeadProperty(customxml.TwistedCalendarPrincipalURI):
+#            # Try regular password check
+#            return TwistedPropertyChecker.requestAvatarId(self, credentials)
+#
+#        user = self.service.userWithShortName(credentials.credentials.username)
+#        raise UnauthorizedLogin("Unknown credentials type for principal: %s" % (credentials.authnURI,))
+#
+#        if not user:
+#            raise UnauthorizedLogin("No such user: %s" % (user,))
+#
+#        if user.authenticate(credentials.credentials):
+#            return succeed((credentials.authnURI, credentials.authzURI))
+#        else:
+#            raise UnauthorizedLogin("Incorrect credentials for user: %s" % (user,)) 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061103/6ed8eb46/attachment.html


More information about the calendarserver-changes mailing list