[CalendarServer-changes] [10999] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 4 13:12:06 PDT 2013


Revision: 10999
          http://trac.calendarserver.org//changeset/10999
Author:   cdaboo at apple.com
Date:     2013-04-04 13:12:06 -0700 (Thu, 04 Apr 2013)
Log Message:
-----------
Allow sharees to change only per-user data on scheduled events.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/method/put_common.py
    CalendarServer/trunk/twistedcaldav/scheduling/implicit.py

Modified: CalendarServer/trunk/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put_common.py	2013-04-04 20:11:17 UTC (rev 10998)
+++ CalendarServer/trunk/twistedcaldav/method/put_common.py	2013-04-04 20:12:06 UTC (rev 10999)
@@ -1038,11 +1038,14 @@
                 # Cannot do implicit in sharee's shared calendar
                 isShareeCollection = self.destinationparent.isShareeCollection()
                 if isShareeCollection:
-                    raise HTTPError(ErrorResponse(
-                        responsecode.FORBIDDEN,
-                        (calendarserver_namespace, "sharee-privilege-needed",),
-                        description="Sharee's cannot schedule"
-                    ))
+                    scheduler.setSchedulingNotAllowed(
+                        HTTPError,
+                        ErrorResponse(
+                            responsecode.FORBIDDEN,
+                            (calendarserver_namespace, "sharee-privilege-needed",),
+                            description="Sharee's cannot schedule",
+                        ),
+                    )
 
                 new_calendar = (yield scheduler.doImplicitScheduling(self.schedule_tag_match))
                 if new_calendar:

Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2013-04-04 20:11:17 UTC (rev 10998)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2013-04-04 20:12:06 UTC (rev 10999)
@@ -35,6 +35,8 @@
 from twistedcaldav.scheduling.utils import getCalendarObjectForPrincipals
 from twistedcaldav.config import config
 
+import collections
+
 __all__ = [
     "ImplicitScheduler",
 ]
@@ -57,8 +59,34 @@
     def __init__(self):
 
         self.return_status = ImplicitScheduler.STATUS_OK
+        self.allowed_to_schedule = True
 
+    NotAllowedExceptionDetails = collections.namedtuple("NotAllowedExceptionDetails", ("type", "args", "kwargs",))
 
+    def setSchedulingNotAllowed(self, ex, *ex_args, **ex_kwargs):
+        """
+        Set indicator that scheduling is not actually allowed. Pass in exception details to raise.
+
+        @param ex: the exception class to raise
+        @type ex: C{class}
+        @param ex_args: the list of arguments for the exception
+        @type ex_args: C{list}
+        """
+
+        self.not_allowed = ImplicitScheduler.NotAllowedExceptionDetails(ex, ex_args, ex_kwargs)
+        self.allowed_to_schedule = False
+
+
+    def testSchedulingAllowed(self):
+        """
+        Called to raise an exception if scheduling is not allowed. This method should be called
+        any time a valid scheduling operation needs to occur.
+        """
+
+        if not self.allowed_to_schedule:
+            raise self.not_allowed.type(*self.not_allowed.args, **self.not_allowed.kwargs)
+
+
     @inlineCallbacks
     def testImplicitSchedulingPUT(self, request, resource, resource_uri, calendar, internal_request=False):
 
@@ -545,10 +573,6 @@
     @inlineCallbacks
     def doImplicitOrganizer(self):
 
-        # Do access control
-        if not self.internal_request:
-            yield self.doAccessControl(self.organizerPrincipal, True)
-
         self.oldcalendar = None
         self.changed_rids = None
         self.cancelledAttendees = ()
@@ -933,6 +957,13 @@
     @inlineCallbacks
     def scheduleWithAttendees(self):
 
+        # First make sure we are allowed to schedule
+        self.testSchedulingAllowed()
+
+        # Do access control
+        if not self.internal_request:
+            yield self.doAccessControl(self.organizerPrincipal, True)
+
         # First process cancelled attendees
         total = (yield self.processCancels())
 
@@ -1052,10 +1083,6 @@
     @inlineCallbacks
     def doImplicitAttendee(self):
 
-        # Do access control
-        if not self.internal_request:
-            yield self.doAccessControl(self.attendeePrincipal, False)
-
         # Check SCHEDULE-AGENT
         doScheduling = self.checkOrganizerScheduleAgent()
 
@@ -1283,8 +1310,16 @@
         return differ.attendeeMerge(self.attendee)
 
 
+    @inlineCallbacks
     def scheduleWithOrganizer(self, changedRids=None):
 
+        # First make sure we are allowed to schedule
+        self.testSchedulingAllowed()
+
+        # Do access control
+        if not self.internal_request:
+            yield self.doAccessControl(self.attendeePrincipal, False)
+
         if not hasattr(self.request, "extendedLogItems"):
             self.request.extendedLogItems = {}
         self.request.extendedLogItems["itip.reply"] = "reply"
@@ -1292,11 +1327,19 @@
         itipmsg = iTipGenerator.generateAttendeeReply(self.calendar, self.attendee, changedRids=changedRids)
 
         # Send scheduling message
-        return self.sendToOrganizer("REPLY", itipmsg)
+        yield self.sendToOrganizer("REPLY", itipmsg)
 
 
+    @inlineCallbacks
     def scheduleCancelWithOrganizer(self):
 
+        # First make sure we are allowed to schedule
+        self.testSchedulingAllowed()
+
+        # Do access control
+        if not self.internal_request:
+            yield self.doAccessControl(self.attendeePrincipal, False)
+
         if not hasattr(self.request, "extendedLogItems"):
             self.request.extendedLogItems = {}
         self.request.extendedLogItems["itip.reply"] = "cancel"
@@ -1304,7 +1347,7 @@
         itipmsg = iTipGenerator.generateAttendeeReply(self.calendar, self.attendee, force_decline=True)
 
         # Send scheduling message
-        return self.sendToOrganizer("CANCEL", itipmsg)
+        yield self.sendToOrganizer("CANCEL", itipmsg)
 
 
     def sendToOrganizer(self, action, itipmsg):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130404/d4d2b3fd/attachment.html>


More information about the calendarserver-changes mailing list