當前位置: 首頁>>代碼示例>>Python>>正文


Python credentials.checkPassword方法代碼示例

本文整理匯總了Python中twisted.cred.credentials.checkPassword方法的典型用法代碼示例。如果您正苦於以下問題:Python credentials.checkPassword方法的具體用法?Python credentials.checkPassword怎麽用?Python credentials.checkPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.cred.credentials的用法示例。


在下文中一共展示了credentials.checkPassword方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: requestAvatarId

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def requestAvatarId(self, c):
        try:
            u, p = self.getUser(c.username)
        except KeyError:
            return defer.fail(error.UnauthorizedLogin())
        else:
            up = credentials.IUsernamePassword(c, None)
            if self.hash:
                if up is not None:
                    h = self.hash(up.username, up.password, p)
                    if h == p:
                        return defer.succeed(u)
                return defer.fail(error.UnauthorizedLogin())
            else:
                return defer.maybeDeferred(c.checkPassword, p
                    ).addCallback(self._cbPasswordMatch, u)



# For backwards compatibility
# Allow access as the old name. 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:23,代碼來源:checkers.py

示例2: assertServerAuthenticated

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def assertServerAuthenticated(self, loginArgs, username="username", password="password"):
        """
        Assert that a login attempt has been made, that the credentials and
        interfaces passed to it are correct, and that when the login request
        is satisfied, a successful response is sent by the ESMTP server
        instance.

        @param loginArgs: A C{list} previously passed to L{portalFactory}.
        """
        d, credentials, mind, interfaces = loginArgs.pop()
        self.assertEqual(loginArgs, [])
        self.assertTrue(twisted.cred.credentials.IUsernamePassword.providedBy(credentials))
        self.assertEqual(credentials.username, username)
        self.assertTrue(credentials.checkPassword(password))
        self.assertIn(smtp.IMessageDeliveryFactory, interfaces)
        self.assertIn(smtp.IMessageDelivery, interfaces)
        d.callback((smtp.IMessageDeliveryFactory, None, lambda: None))

        self.assertEqual(
            ["235 Authentication successful."],
            self.transport.value().splitlines()) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:23,代碼來源:test_smtp.py

示例3: assertServerAuthenticated

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def assertServerAuthenticated(self, loginArgs, username=b"username",
                                  password=b"password"):
        """
        Assert that a login attempt has been made, that the credentials and
        interfaces passed to it are correct, and that when the login request
        is satisfied, a successful response is sent by the ESMTP server
        instance.

        @param loginArgs: A C{list} previously passed to L{portalFactory}.
        @param username: The login user.
        @param password: The login password.
        """
        d, credentials, mind, interfaces = loginArgs.pop()
        self.assertEqual(loginArgs, [])
        self.assertTrue(twisted.cred.credentials.IUsernamePassword.providedBy(credentials))
        self.assertEqual(credentials.username, username)
        self.assertTrue(credentials.checkPassword(password))
        self.assertIn(smtp.IMessageDeliveryFactory, interfaces)
        self.assertIn(smtp.IMessageDelivery, interfaces)
        d.callback((smtp.IMessageDeliveryFactory, None, lambda: None))

        self.assertEqual(
            [b"235 Authentication successful."],
            self.transport.value().splitlines()) 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:26,代碼來源:test_smtp.py

示例4: requestAvatarId

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def requestAvatarId(self, c):
        try:
            u, p = self.getUser(c.username)
        except KeyError:
            return defer.fail(error.UnauthorizedLogin())
        else:
            up = credentials.IUsernamePassword(c, None)
            if self.hash:
                if up is not None:
                    h = self.hash(up.username, up.password, p)
                    if h == p:
                        return defer.succeed(u)
                return defer.fail(error.UnauthorizedLogin())
            else:
                return defer.maybeDeferred(c.checkPassword, p
                    ).addCallback(self._cbPasswordMatch, u) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:18,代碼來源:checkers.py

示例5: assertServerAuthenticated

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def assertServerAuthenticated(self, loginArgs, username="username", password="password"):
        """
        Assert that a login attempt has been made, that the credentials and
        interfaces passed to it are correct, and that when the login request
        is satisfied, a successful response is sent by the ESMTP server
        instance.

        @param loginArgs: A C{list} previously passed to L{portalFactory}.
        """
        d, credentials, mind, interfaces = loginArgs.pop()
        self.assertEqual(loginArgs, [])
        self.failUnless(twisted.cred.credentials.IUsernamePassword.providedBy(credentials))
        self.assertEqual(credentials.username, username)
        self.failUnless(credentials.checkPassword(password))
        self.assertIn(smtp.IMessageDeliveryFactory, interfaces)
        self.assertIn(smtp.IMessageDelivery, interfaces)
        d.callback((smtp.IMessageDeliveryFactory, None, lambda: None))

        self.assertEqual(
            ["235 Authentication successful."],
            self.transport.value().splitlines()) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:23,代碼來源:test_smtp.py

示例6: requestAvatarId

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def requestAvatarId(self, credentials):
        username = credentials.username
        if username in self.tokens:
            if credentials.checkPassword(self.tokens[username]):
                return defer.succeed(username)
            else:
                return defer.fail(
                    credError.UnauthorizedLogin("Bad session token"))
        else:
            return defer.fail(
                credError.UnauthorizedLogin("No such user")) 
開發者ID:leapcode,項目名稱:bitmask-dev,代碼行數:13,代碼來源:_auth.py

示例7: requestAvatarId

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def requestAvatarId(self, credentials):
        return defer.maybeDeferred(
            credentials.checkPassword, self.users[credentials.username]
        ).addCallback(self._cbCheck, credentials.username) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:6,代碼來源:test_smtp.py

示例8: requestAvatarId

# 需要導入模塊: from twisted.cred import credentials [as 別名]
# 或者: from twisted.cred.credentials import checkPassword [as 別名]
def requestAvatarId(self, credentials):
        if credentials.username in self.users:
            return defer.maybeDeferred(
                credentials.checkPassword, self.users[credentials.username]
        ).addCallback(self._cbCheck, credentials.username) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:7,代碼來源:test_imap.py


注:本文中的twisted.cred.credentials.checkPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。