def getMemberNames(self): assert self.isCollection if self.path == "/": memberNames = CardDAV.groupList(self.userProfile) else: memberNames = CardDAV.friendList(self.userProfile, self.groupName) return memberNames
def generateVCard(self): if not self.isCollection: logging.info("generateVCard()") vCard = CardDAV.getVCard(self.contactID) self.vCard = vCard[0].encode("utf8") self.vCardMtime = vCard[1] self.vCardMD5 = vCard[2]
def __init__(self, path, environ): path = os.path.normpath(path) path = replace(path, "//", "/") assert path=="" or path.startswith("/") self.provider = environ["wsgidav.provider"] self.path = path self.environ = environ self.userProfile = CardDAV.getUserProfile(environ["wsgidav.username"]) if (path == "/") or (path == ""): # this is the main folder self.isCollection = True self.name = "Psinque" else: self.groupName = os.path.dirname(path) fileName = os.path.basename(path) if self.groupName == "/": self.groupName = fileName fileName = "" if fileName != "": fileName = os.path.splitext(fileName) self.isCollection = False if fileName[1] != u".vcf": raise ValueError("Unsupported extension: %r" % fileName[1]) self.contactID = fileName[0] self.name = "Forest Gump" self.vCard = None else: self.isCollection = True self.name = self.groupName
def getRealmUserPassword(self, realmname, username, environ): """ Return the password for the given username for the realm. Used for digest authentication. """ #if self.userPassword is None: # user has not generated password #return None # Ignore spaces username = username.replace(" ", "") carddav_password = CardDAV.getCardDAVLogin(username) if carddav_password is None: return [ u"", u"" ] else: return [ carddav_password.generatedPasswordHash, carddav_password.salt ]
def authDomainUser(self, realmname, username, password, environ): """ Returns True if this username/password pair is valid for the realm, False otherwise. Used for basic authentication. """ if realmname != "carddav": return False # Ignore spaces username = username.replace(" ", "") password = password.replace(" ", "") userPassword = CardDAV.getCardDAVLogin(username) if userPassword is None: return False passwordHash = md5.new(userPassword.salt + password).hexdigest() return (userPassword.generatedPasswordHash == passwordHash)