示例#1
0
 def buildProtocol(self, addr):
     p = protocol.ClientFactory.buildProtocol(self, addr)
     username = self.settings["Username"]
     p.registerAuthenticator(imap4.CramMD5ClientAuthenticator(username))
     p.registerAuthenticator(imap4.LOGINAuthenticator(username))
     p.registerAuthenticator(imap4.PLAINAuthenticator(username))
     return p
示例#2
0
 def buildProtocol(self, addr):
     debug("[SimpleIMAP4ClientFactory] building protocol: %s" % addr)
     pr = self.protocol(contextFactory=self.ctx)
     pr.factory = self
     pr.greetDeferred = self.e2session.onConnect
     auth = imap4.CramMD5ClientAuthenticator(self.username)
     pr.registerAuthenticator(auth)
     return pr
示例#3
0
        def callback(password):
            password = password.encode("utf-8")
            self.proto.registerAuthenticator(
                imap4.CramMD5ClientAuthenticator(username))
            self.proto.registerAuthenticator(
                imap4.LOGINAuthenticator(username))

            return self.proto.authenticate(password).addCallback(
                self.cb).addErrback(self.loginClientInsecure, username,
                                    password).addErrback(self.catchErrors)
示例#4
0
    def buildProtocol(self, addr):
        assert not self.usedUp
        self.usedUp = True

        p = self.protocol(self.ctx)
        p.factory = self
        p.greetDeferred = self.onConn

        auth = imap4.CramMD5ClientAuthenticator(self.username)
        p.registerAuthenticator(auth)

        return p
示例#5
0
    def buildProtocol(self, addr):
        p = self.protocol(self.context)
        p.factory = self
        p.greetdefer = self.onconn

        auth1 = imap4.CramMD5ClientAuthenticator(self.uid)
        auth2 = imap4.PLAINAuthenticator(self.uid)
        auth3 = imap4.LOGINAuthenticator(self.uid)
        p.registerAuthenticator(auth1)
        p.registerAuthenticator(auth3)
        p.registerAuthenticator(auth2)
        p.registerAuthenticator(auth1)

        return p
示例#6
0
    def buildProtocol(self, addr):
        assert not self.usedUp
        self.usedUp = True

        p = self.protocol()
        p.factory = self
        p.greetDeferred = self.onConn

        p.registerAuthenticator(imap4.PLAINAuthenticator(self.username))
        p.registerAuthenticator(imap4.LOGINAuthenticator(self.username))
        p.registerAuthenticator(imap4.CramMD5ClientAuthenticator(
            self.username))

        return p
示例#7
0
文件: run.py 项目: breakds/brokering
    def serverGreeting(self, unused_capabilities):
        """The entry point for the whole program.

        It merely starts the long-running pipeline.
        """
        # NOTE: Although twisted official example suggest using the capabilities
        # returned here to decide what kind of authentication methods to
        # register, I found it to be not true as real capabilities are only
        # returned after the authentication is successful.
        username = self.pipeline.username
        self.registerAuthenticator(imap4.PLAINAuthenticator(username))
        self.registerAuthenticator(imap4.LOGINAuthenticator(username))
        self.registerAuthenticator(imap4.CramMD5ClientAuthenticator(username))
        self.pipeline.start()
示例#8
0
    def testAuth(self):
        realm = DummyRealm()
        p = cred.portal.Portal(realm)
        p.registerChecker(DummyChecker())

        server = DummyESMTP({'CRAM-MD5': cred.credentials.CramMD5Credentials})
        server.portal = p
        client = MyESMTPClient('testpassword')

        cAuth = imap4.CramMD5ClientAuthenticator('testuser')
        client.registerAuthenticator(cAuth)

        d = self.loopback(server, client)
        d.addCallback(lambda x : self.assertEquals(server.authenticated, 1))
        return d
示例#9
0
文件: client.py 项目: phlax/txCyrus
 def buildProtocol(self, addr):
     """
     Initiate the protocol instance. Since we are building a simple IMAP
     client, we don't bother checking what capabilities the server has. We
     just add all the authenticators twisted.mail has.  Note: Gmail no
     longer uses any of the methods below, it's been using XOAUTH since
     2010.
     """
     assert not self.usedUp
     self.usedUp = True
     p = self.protocol(self.ctx)
     p.factory = self
     p.greetDeferred = self.onConn
     p.registerAuthenticator(imap4.PLAINAuthenticator(self.username))
     p.registerAuthenticator(imap4.LOGINAuthenticator(self.username))
     p.registerAuthenticator(
         imap4.CramMD5ClientAuthenticator(self.username))
     return p
示例#10
0
    def _loginClient(self):
        """Logs a client in to an IMAP servier using the CramMD6, Login, or
           Plain authentication"""

        if __debug__:
            self.printCurrentView("_loginClient")

        assert self.account is not None
        """Twisted expects ascii values so encode the utf-8 username and password"""
        username = self.account.username.encode(constants.DEFAULT_CHARSET)
        password = self.account.password.encode(constants.DEFAULT_CHARSET)

        self.proto.registerAuthenticator(
            imap4.CramMD5ClientAuthenticator(username))
        self.proto.registerAuthenticator(imap4.LOGINAuthenticator(username))

        return self.proto.authenticate(password).addCallback(
            self.__selectInbox).addErrback(self.loginClientInsecure, username,
                                           password)