示例#1
0
    def getSessionToken(self, payload):
        """Validate XML document and extract authentication token from
        the payload."""
        (error, xmlData) = validateDocXML(payload)
        if error is True: return None

        token = xmlData.find('token')
        if token is None: return None
        return decode(token.text)
示例#2
0
    def getSessionToken(self, payload):
        """Validate XML document and extract authentication token from
        the payload."""
        (error, xmlData) = validateDocXML(payload)
        if error is True: return None

        token = xmlData.find('token')
        if token is None: return None
        return decode(token.text)
示例#3
0
    def getNewMailParams(self, payload):
        """Retrieve newmail parameters."""
        (error, xmlData) = validateDocXML(payload)
        if error is True: return (error, xmlData)

        # Retrieve MAPIStore management object
        mgmt = config['mapistore']

        # Initialize dictionary
        params = {}

        # Retrieve notification and ensure it's newmail
        notification = xmlData.find('notification')
        if notification is None: return (True, 'Missing Notification')
        if not 'category' in notification.attrib: return (True, 'Missing notification type')
        if notification.attrib['category'] != 'newmail': return (True, 'Invalid notification type')

        # backend parameter
        param = notification.find('backend')
        if param is None or param.text is None: return (True, 'Invalid/Missing backend parameter')
        if mgmt.registered_backend(param.text) is False: return (True, 'Specified backend is invalid')
        params['backend'] = param.text

        # folder parameter
        param = notification.find('folder')
        if param is None or param.text is None: return (True, 'Invalid/Missing folder parameter')
        params['folder'] = param.text

        # messageID parameter
        param = notification.find('messageID')
        if param is None or param.text is None: retrun (True, 'Invalid/Missing messageID parameter')
        params['messageID'] = param.text

        # username parameter
        param = notification.find('username')
        if param is None or param.text is None: return (True, 'Invalid/Missing username parameter')
        params['vuser'] = param.text

        # Search for openchange user matching above attributes
        ed = mgmt.existing_users(params['backend'], params['vuser'], params['folder'])
        if ed['count'] == 0: return (True, 'Invalid user')
        print ed
        count = 0
        for info in ed['infos']:
            ret = mgmt.registered_message(params['backend'], info['username'], params['vuser'],
                                          params['folder'], info['mapistoreURI'], params['messageID'])
            if ret is True:
                print 'Message already registered for user %s' % info['username']
                count = count + 1
            else:
                # Register the message in all users indexing databases
                message = mgmt.register_message(params['backend'], info['username'], 
                                                info['mapistoreURI'], params['messageID'])
                if not message: print "Unable to register URI for user %s" % (info['username'])
                else:
                    print "[REGISTERED] user %s: (%s, %s)" % (info['username'], hex(message[0]), message[1])
示例#4
0
    def verifyPassword(self, login, token_salt, salt, payload):
        """Check if the supplied login hash is correct.
        """
        (error, xmlData) = validateDocXML(payload)
        if error is True: return (error, xmlData)

        token = xmlData.find('token')
        if token is None: return (True, 'No token parameter found')

        return self.model.verifyPassword(login, token_salt, salt, token.text)
示例#5
0
    def verifyPassword(self, login, token_salt, salt, payload):
        """Check if the supplied login hash is correct.
        """
        (error, xmlData) = validateDocXML(payload)
        if error is True: return (error, xmlData)

        token = xmlData.find('token')
        if token is None: return (True, 'No token parameter found')
 
        return self.model.verifyPassword(login, token_salt, salt, token.text)
示例#6
0
    def getTokenLogin(self, payload):
        """Validate XML document and retrieve the login from XML payload."""
        (error, xmlData) = validateDocXML(payload)
        if error is True: return None

        login = xmlData.find('login')
        if login is None: return None

        # Ensure login is made of allowed characters (prevent from injections)
        if re.match(r'^[A-Za-z0-9_.@-]+$', login.text) is None: return None

        return login.text
示例#7
0
    def getTokenLogin(self, payload):
        """Validate XML document and retrieve the login from XML payload."""
        (error, xmlData) = validateDocXML(payload)
        if error is True: return None

        login = xmlData.find('login')
        if login is None: return None

        # Ensure login is made of allowed characters (prevent from injections)
        if re.match(r'^[A-Za-z0-9_.@-]+$', login.text) is None: return None

        return login.text