def _checkPassword(self, user, salt, password, challenge, remoteIp = None):
        if challenge is ValidPasswordToken:
            # Short-circuit for shim-using code that does its own
            # authentication, e.g. through one-time tokens or session
            # data.
            return True

        if self.cacheTimeout:
            cacheEntry = sha1helper.sha1String("%s%s" % (user, challenge))
            timeout = self.pwCache.get(cacheEntry, None)
            if timeout is not None and time.time() < timeout:
                return True

        if self.pwCheckUrl:
            try:
                url = "%s?user=%s;password=%s" \
                        % (self.pwCheckUrl, urllib.quote(user),
                           urllib.quote(challenge))

                if remoteIp is not None:
                    url += ';remote_ip=%s' % urllib.quote(remoteIp)

                f = urllib2.urlopen(url)
                xmlResponse = f.read()
            except:
                return False

            p = PasswordCheckParser()
            p.parse(xmlResponse)

            isValid = p.validPassword()
        else:
            m = digestlib.md5()
            m.update(salt)
            m.update(challenge)
            isValid = m.hexdigest() == password

        if isValid and self.cacheTimeout:
            # cacheEntry is still around from above
            self.pwCache[cacheEntry] = time.time() + self.cacheTimeout

        return isValid
dataset/ETHPy150Open sassoftware/conary/conary/repository/netrepos/netauth.py/UserAuthorization._checkPassword/original