本文整理匯總了Python中twisted.cred方法的典型用法代碼示例。如果您正苦於以下問題:Python twisted.cred方法的具體用法?Python twisted.cred怎麽用?Python twisted.cred使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted
的用法示例。
在下文中一共展示了twisted.cred方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _cbAnonymousAuthentication
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def _cbAnonymousAuthentication(self, result):
"""
Save the state resulting from a successful anonymous cred login.
"""
(iface, avatar, logout) = result
if issubclass(iface, IMessageDeliveryFactory):
self.deliveryFactory = avatar
self.delivery = None
elif issubclass(iface, IMessageDelivery):
self.deliveryFactory = None
self.delivery = avatar
else:
raise RuntimeError("%s is not a supported interface" % (iface.__name__,))
self._onLogout = logout
self.challenger = None
# overridable methods:
示例2: _ebAuthenticated
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def _ebAuthenticated(self, reason):
"""
Handle cred login errors by translating them to the SMTP authenticate
failed. Translate all other errors into a generic SMTP error code and
log the failure for inspection. Stop all errors from propagating.
@param reason: Reason for failure.
"""
self.challenge = None
if reason.check(cred.error.UnauthorizedLogin):
self.sendCode(535, b'Authentication failed')
else:
log.err(reason, "SMTP authentication failure")
self.sendCode(
451,
b'Requested action aborted: local error in processing')
示例3: _cbAuthenticated
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def _cbAuthenticated(self, loginInfo):
"""
Save the state resulting from a successful cred login and mark this
connection as authenticated.
"""
result = SMTP._cbAnonymousAuthentication(self, loginInfo)
self.authenticated = True
return result
示例4: _ebAuthenticated
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def _ebAuthenticated(self, reason):
"""
Handle cred login errors by translating them to the SMTP authenticate
failed. Translate all other errors into a generic SMTP error code and
log the failure for inspection. Stop all errors from propagating.
"""
self.challenge = None
if reason.check(cred.error.UnauthorizedLogin):
self.sendCode(535, 'Authentication failed')
else:
log.err(reason, "SMTP authentication failure")
self.sendCode(
451,
'Requested action aborted: local error in processing')
示例5: brokerAttached
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def brokerAttached(self, reference, identity, broker):
"""An intermediary method to override.
Normally you will want to use 'attached', as described in
L{twisted.cred.perspective.Perspective}.attached; however, this method
serves the same purpose, and in some circumstances, you are sure that
the protocol that objects will be attaching to your Perspective with is
Perspective Broker, and in that case you may wish to get the Broker
object they are connecting with, for example, to determine what host
they are connecting from. Bear in mind that when overriding this
method, other, non-PB protocols will not notify you of being attached
or detached.
"""
warnings.warn("pb.Perspective is deprecated, please use pb.Avatar.", DeprecationWarning, 2)
return self.attached(reference, identity)
示例6: _cbLogInResponded
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def _cbLogInResponded(identity, d, client, serviceName, perspectiveName):
warnings.warn("This is deprecated. Use PBClientFactory.", DeprecationWarning, 2)
if identity:
identity.callRemote("attach", serviceName, perspectiveName, client).chainDeferred(d)
else:
from twisted import cred
d.errback(cred.error.Unauthorized("invalid username or password"))
示例7: _cbGotIdentity
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def _cbGotIdentity(self, i):
self._identityWrapper = i
if i:
for d in self._connectDeferreds:
d.callback(i)
self._connectDeferreds[:] = []
else:
from twisted import cred
e = cred.error.Unauthorized("invalid username or password")
self._ebGotIdentity(e)
示例8: login
# 需要導入模塊: import twisted [as 別名]
# 或者: from twisted import cred [as 別名]
def login(self, credentials, client=None):
"""Login and get perspective from remote PB server.
Currently only credentials implementing
L{twisted.cred.credentials.IUsernamePassword} are supported.
@return: Deferred of RemoteReference to the perspective.
"""
d = self.getRootObject()
d.addCallback(self._cbSendUsername, credentials.username, credentials.password, client)
return d