'PLAIN ZAP authentication'

def _authenticate_plain(self, domain, username, password):

    allowed = False
    reason = ''
    if self.passwords:
        if (not domain):
            domain = '*'
        if (domain in self.passwords):
            if (username in self.passwords[domain]):
                if (password == self.passwords[domain][username]):
                    allowed = True
                else:
                    reason = 'Invalid    password'
            else:
                reason = 'Invalid    username'
        else:
            reason = 'Invalid    domain'
        if allowed:
            self.log.debug('ALLOWED    (PLAIN)    domain=%s    username=%s    password=%s', domain, username, password)
        else:
            self.log.debug('DENIED    %s', reason)
    else:
        reason = 'No    passwords    defined'
        self.log.debug('DENIED    (PLAIN)    %s', reason)
    return (allowed, reason)
