本文整理匯總了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.
示例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())
示例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())
示例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)
示例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())
示例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"))
示例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)
示例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)