Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Support DPS with the ACL optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrusdaboo committed Dec 14, 2016
1 parent 9008867 commit 600fdef
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
20 changes: 19 additions & 1 deletion txdav/dps/client.py
Expand Up @@ -45,7 +45,7 @@
StatsCommand, ExternalDelegatesCommand, ExpandedMemberUIDsCommand,
AddMembersCommand, RemoveMembersCommand,
UpdateRecordsCommand, ExpandedMembersCommand, FlushCommand,
SetAutoScheduleModeCommand
SetAutoScheduleModeCommand, ContainsUIDsCommand
)
from txdav.who.delegates import RecordType as DelegatesRecordType
from txdav.who.directory import (
Expand Down Expand Up @@ -548,6 +548,24 @@ def expandedMemberUIDs(self):
else:
return succeed([])

def containsUID(self, uid):
"""
Is the supplied UID an expanded member of this proxy group.
@param uid: UID to test
@type uid: L{str}
@return: result
@rtype: L{bool}
"""
log.debug("DPS Client containsUID")
return self.service._call(
ContainsUIDsCommand,
lambda x: x['result'],
uid=self.uid.encode("utf-8"),
testUid=uid.encode("utf-8")
)

def _convertAccess(self, results):
access = results["access"].decode("utf-8")
return txdav.who.wiki.WikiAccessLevel.lookupByName(access)
Expand Down
10 changes: 10 additions & 0 deletions txdav/dps/commands.py
Expand Up @@ -198,6 +198,16 @@ class ExpandedMemberUIDsCommand(amp.Command):
]


class ContainsUIDsCommand(amp.Command):
arguments = [
('uid', amp.String()),
('testUid', amp.String()),
]
response = [
('result', amp.Boolean()),
]


class VerifyPlaintextPasswordCommand(amp.Command):
arguments = [
('uid', amp.String()),
Expand Down
18 changes: 17 additions & 1 deletion txdav/dps/server.py
Expand Up @@ -44,7 +44,7 @@
VerifyPlaintextPasswordCommand, VerifyHTTPDigestCommand,
WikiAccessForUIDCommand, ContinuationCommand,
ExternalDelegatesCommand, StatsCommand, ExpandedMemberUIDsCommand,
AddMembersCommand, RemoveMembersCommand,
ContainsUIDsCommand, AddMembersCommand, RemoveMembersCommand,
UpdateRecordsCommand, FlushCommand, SetAutoScheduleModeCommand,
# RemoveRecordsCommand,
)
Expand Down Expand Up @@ -498,6 +498,22 @@ def setMembers(self, uid, memberUIDs):
# log.debug("Responding with: {response}", response=response)
returnValue(response)

@ContainsUIDsCommand.responder
@inlineCallbacks
def containsUID(self, uid, testUid):
uid = uid.decode("utf-8")
testUid = testUid.decode("utf-8")
log.debug("ContainsUID: {u} {t}", u=uid, t=testUid)
record = (yield self._directory.recordWithUID(uid))
result = False
if record is not None:
result = yield record.containsUID(testUid)
response = {
"result": result,
}
# log.debug("Responding with: {response}", response=response)
returnValue(response)

@UpdateRecordsCommand.responder
@inlineCallbacks
def updateRecords(self, uids, create):
Expand Down

0 comments on commit 600fdef

Please sign in to comment.