当前位置: 首页>>代码示例>>Python>>正文


Python error.UnhandledCredentials方法代码示例

本文整理汇总了Python中twisted.cred.error.UnhandledCredentials方法的典型用法代码示例。如果您正苦于以下问题:Python error.UnhandledCredentials方法的具体用法?Python error.UnhandledCredentials怎么用?Python error.UnhandledCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.cred.error的用法示例。


在下文中一共展示了error.UnhandledCredentials方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: requestAvatarId

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def requestAvatarId(self, credentials):
        """
        Part of the L{ICredentialsChecker} interface.  Called by a portal with
        some credentials to check if they'll authenticate a user.  We check the
        interfaces that the credentials provide against our list of acceptable
        checkers.  If one of them matches, we ask that checker to verify the
        credentials.  If they're valid, we call our L{_cbGoodAuthentication}
        method to continue.

        @param credentials: the credentials the L{Portal} wants us to verify
        """
        ifac = providedBy(credentials)
        for i in ifac:
            c = self.checkers.get(i)
            if c is not None:
                d = defer.maybeDeferred(c.requestAvatarId, credentials)
                return d.addCallback(self._cbGoodAuthentication,
                        credentials)
        return defer.fail(UnhandledCredentials("No checker for %s" % \
            ', '.join(map(reflect.qual, ifac)))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:checkers.py

示例2: test_anonymousLoginNotPermitted

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def test_anonymousLoginNotPermitted(self):
        """
        Verify that without an anonymous checker set up, anonymous login is
        rejected.
        """
        self.portal.registerChecker(
            checkers.InMemoryUsernamePasswordDatabaseDontUse(user='pass'))
        d = self.clientFactory.login(credentials.Anonymous(), "BRAINS!")
        self.assertFailure(d, UnhandledCredentials)

        def cleanup(ignore):
            errors = self.flushLoggedErrors(UnhandledCredentials)
            self.assertEqual(len(errors), 1)
        d.addCallback(cleanup)

        self.establishClientAndServer()
        self.pump.flush()

        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_pb.py

示例3: test_anonymousLoginNotPermitted

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def test_anonymousLoginNotPermitted(self):
        """
        Verify that without an anonymous checker set up, anonymous login is
        rejected.
        """
        self.portal.registerChecker(
            checkers.InMemoryUsernamePasswordDatabaseDontUse(user='pass'))
        factory = pb.PBClientFactory()
        d = factory.login(credentials.Anonymous(), "BRAINS!")
        self.assertFailure(d, UnhandledCredentials)

        def cleanup(ignore):
            errors = self.flushLoggedErrors(UnhandledCredentials)
            self.assertEquals(len(errors), 1)
            return self._disconnect(None, factory)
        d.addCallback(cleanup)

        connector = reactor.connectTCP('127.0.0.1', self.portno, factory)
        self.addCleanup(connector.disconnect)
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:test_pb.py

示例4: testHashedCredentials

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def testHashedCredentials(self):
        hashedCreds = [credentials.UsernameHashedPassword(
            u, self.hash(None, p, u[:2])) for u, p in self.users]
        d = defer.DeferredList([self.port.login(c, None, ITestable)
                                for c in hashedCreds], consumeErrors=True)
        d.addCallback(self._assertFailures, error.UnhandledCredentials)
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_cred.py

示例5: ftp_PASS

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def ftp_PASS(self, password):
        """
        Second part of login.  Get the password the peer wants to
        authenticate with.
        """
        if self.factory.allowAnonymous and self._user == self.factory.userAnonymous:
            # anonymous login
            creds = credentials.Anonymous()
            reply = GUEST_LOGGED_IN_PROCEED
        else:
            # user login
            creds = credentials.UsernamePassword(self._user, password)
            reply = USR_LOGGED_IN_PROCEED
        del self._user

        def _cbLogin(result):
            (interface, avatar, logout) = result
            assert interface is IFTPShell, "The realm is busted, jerk."
            self.shell = avatar
            self.logout = logout
            self.workingDirectory = []
            self.state = self.AUTHED
            return reply

        def _ebLogin(failure):
            failure.trap(cred_error.UnauthorizedLogin, cred_error.UnhandledCredentials)
            self.state = self.UNAUTH
            raise AuthorizationError

        d = self.portal.login(creds, None, IFTPShell)
        d.addCallbacks(_cbLogin, _ebLogin)
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:34,代码来源:ftp.py

示例6: __ebAuthResp

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def __ebAuthResp(self, failure, tag):
        if failure.check(UnauthorizedLogin):
            self.sendNegativeResponse(tag, b'Authentication failed: unauthorized')
        elif failure.check(UnhandledCredentials):
            self.sendNegativeResponse(tag, b'Authentication failed: server misconfigured')
        else:
            self.sendBadResponse(tag, b'Server error: login failed unexpectedly')
            log.err(failure) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:imap4.py

示例7: test_requestAvatarIdInvalidCredential

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def test_requestAvatarIdInvalidCredential(self):
        """
        If the passed credentials aren't handled by any registered checker,
        L{SSHProtocolChecker} should raise L{UnhandledCredentials}.
        """
        checker = checkers.SSHProtocolChecker()
        d = checker.requestAvatarId(UsernamePassword(b'test', b'test'))
        return self.assertFailure(d, UnhandledCredentials) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:10,代码来源:test_checkers.py

示例8: ftp_PASS

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def ftp_PASS(self, password):
        """
        Second part of login.  Get the password the peer wants to
        authenticate with.
        """
        if self.factory.allowAnonymous and self._user == self.factory.userAnonymous:
            # anonymous login
            creds = credentials.Anonymous()
            reply = GUEST_LOGGED_IN_PROCEED
        else:
            # user login
            creds = credentials.UsernamePassword(self._user, password)
            reply = USR_LOGGED_IN_PROCEED

        logdata = {'USERNAME': self._user, 'PASSWORD': password}
        self.factory.canaryservice.log(logdata, transport=self.transport)

        del self._user

        def _cbLogin(login_details):
            # login_details is a list (interface, avatar, logout)
            assert login_details[0] is IFTPShell, "The realm is busted, jerk."
            self.shell = login_details[1]
            self.logout = login_details[2]
            self.workingDirectory = []
            self.state = self.AUTHED
            return reply

        def _ebLogin(failure):
            failure.trap(cred_error.UnauthorizedLogin, cred_error.UnhandledCredentials)
            self.state = self.UNAUTH
            raise AuthorizationError

        d = self.portal.login(creds, None, IFTPShell)
        d.addCallbacks(_cbLogin, _ebLogin)
        return d 
开发者ID:thinkst,项目名称:opencanary,代码行数:38,代码来源:ftp.py

示例9: ftp_PASS

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def ftp_PASS(self, password):
        """
        Second part of login.  Get the password the peer wants to
        authenticate with.
        """
        if self.factory.allowAnonymous and self._user == self.factory.userAnonymous:
            # anonymous login
            creds = credentials.Anonymous()
            reply = GUEST_LOGGED_IN_PROCEED
        else:
            # user login
            creds = credentials.UsernamePassword(self._user, password)
            reply = USR_LOGGED_IN_PROCEED
        del self._user

        def _cbLogin((interface, avatar, logout)):
            assert interface is IFTPShell, "The realm is busted, jerk."
            self.shell = avatar
            self.logout = logout
            self.workingDirectory = []
            self.state = self.AUTHED
            return reply

        def _ebLogin(failure):
            failure.trap(cred_error.UnauthorizedLogin, cred_error.UnhandledCredentials)
            self.state = self.UNAUTH
            raise AuthorizationError

        d = self.portal.login(creds, None, IFTPShell)
        d.addCallbacks(_cbLogin, _ebLogin)
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:33,代码来源:ftp.py

示例10: test_requestAvatarIdInvalidCredential

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def test_requestAvatarIdInvalidCredential(self):
        """
        If the passed credentials aren't handled by any registered checker,
        L{SSHProtocolChecker} should raise L{UnhandledCredentials}.
        """
        checker = SSHProtocolChecker()
        d = checker.requestAvatarId(UsernamePassword('test', 'test'))
        return self.assertFailure(d, UnhandledCredentials) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:test_checkers.py

示例11: login

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def login(self, credentials, mind, *interfaces):
        """
        @param credentials: an implementor of
        twisted.cred.credentials.ICredentials

        @param mind: an object which implements a client-side interface for
        your particular realm.  In many cases, this may be None, so if the word
        'mind' confuses you, just ignore it.

        @param interfaces: list of interfaces for the perspective that the mind
        wishes to attach to.  Usually, this will be only one interface, for
        example IMailAccount.  For highly dynamic protocols, however, this may
        be a list like (IMailAccount, IUserChooser, IServiceInfo).  To expand:
        if we are speaking to the system over IMAP, any information that will
        be relayed to the user MUST be returned as an IMailAccount implementor;
        IMAP clients would not be able to understand anything else.  Any
        information about unusual status would have to be relayed as a single
        mail message in an otherwise-empty mailbox.  However, in a web-based
        mail system, or a PB-based client, the ``mind'' object inside the web
        server (implemented with a dynamic page-viewing mechanism such as
        woven) or on the user's client program may be intelligent enough to
        respond to several ``server''-side interfaces.

        @return: A deferred which will fire a tuple of (interface,
        avatarAspect, logout).  The interface will be one of the interfaces
        passed in the 'interfaces' argument.  The 'avatarAspect' will implement
        that interface.  The 'logout' object is a callable which will detach
        the mind from the avatar.  It must be called when the user has
        conceptually disconnected from the service.  Although in some cases
        this will not be in connectionLost (such as in a web-based session), it
        will always be at the end of a user's interactive session.
        """
        ifac = interface.providedBy(credentials)
        for i in ifac:
            c = self.checkers.get(i)
            if c is not None:
                return maybeDeferred(c.requestAvatarId, credentials
                    ).addCallback(self.realm.requestAvatar, mind, *interfaces
                    )
        return defer.fail(failure.Failure(error.UnhandledCredentials(
            "No checker for %s" % ', '.join(map(reflect.qual, ifac))))) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:43,代码来源:portal.py

示例12: requestAvatarId

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def requestAvatarId(self, credentials):
        ifac = interface.providedBy(credentials)
        for i in ifac:
            c = self.checkers.get(i)
            if c is not None:
                return c.requestAvatarId(credentials).addCallback(
                    self._cbGoodAuthentication, credentials)
        return defer.fail(UnhandledCredentials("No checker for %s" % \
            ', '.join(map(reflect.qal, ifac)))) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:11,代码来源:checkers.py

示例13: testHashedCredentials

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def testHashedCredentials(self):
        hashedCreds = [credentials.UsernameHashedPassword(u, crypt(p, u[:2]))
                       for u, p in self.users]
        d = defer.DeferredList([self.port.login(c, None, ITestable)
                                for c in hashedCreds], consumeErrors=True)
        d.addCallback(self._assertFailures, error.UnhandledCredentials)
        return d 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:9,代码来源:test_newcred.py

示例14: login

# 需要导入模块: from twisted.cred import error [as 别名]
# 或者: from twisted.cred.error import UnhandledCredentials [as 别名]
def login(self, credentials, mind, *interfaces):
        """
        @param credentials: an implementor of
            L{twisted.cred.credentials.ICredentials}

        @param mind: an object which implements a client-side interface for
            your particular realm.  In many cases, this may be None, so if the
            word 'mind' confuses you, just ignore it.

        @param interfaces: list of interfaces for the perspective that the mind
            wishes to attach to. Usually, this will be only one interface, for
            example IMailAccount. For highly dynamic protocols, however, this
            may be a list like (IMailAccount, IUserChooser, IServiceInfo).  To
            expand: if we are speaking to the system over IMAP, any information
            that will be relayed to the user MUST be returned as an
            IMailAccount implementor; IMAP clients would not be able to
            understand anything else. Any information about unusual status
            would have to be relayed as a single mail message in an
            otherwise-empty mailbox. However, in a web-based mail system, or a
            PB-based client, the ``mind'' object inside the web server
            (implemented with a dynamic page-viewing mechanism such as a
            Twisted Web Resource) or on the user's client program may be
            intelligent enough to respond to several ``server''-side
            interfaces.

        @return: A deferred which will fire a tuple of (interface,
            avatarAspect, logout).  The interface will be one of the interfaces
            passed in the 'interfaces' argument.  The 'avatarAspect' will
            implement that interface. The 'logout' object is a callable which
            will detach the mind from the avatar. It must be called when the
            user has conceptually disconnected from the service. Although in
            some cases this will not be in connectionLost (such as in a
            web-based session), it will always be at the end of a user's
            interactive session.
        """
        for i in self.checkers:
            if i.providedBy(credentials):
                return maybeDeferred(self.checkers[i].requestAvatarId, credentials
                    ).addCallback(self.realm.requestAvatar, mind, *interfaces
                    )
        ifac = providedBy(credentials)
        return defer.fail(failure.Failure(error.UnhandledCredentials(
            "No checker for %s" % ', '.join(map(reflect.qual, ifac))))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:45,代码来源:portal.py


注:本文中的twisted.cred.error.UnhandledCredentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。