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


Python Certificate.peerFromTransport方法代码示例

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


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

示例1: remote_login

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
    def remote_login(self, client):
        # print 'Remote login!'
        peerCertificate = Certificate.peerFromTransport(self.broker.transport)
        pdid = peerCertificate.getSubject().commonName.decode('utf-8')

        avatar, logout = yield self.portal.login(pdid, client)
        avatar = pb.AsReferenceable(avatar, "perspective")

        # Formerly in _cbLogin, moved here to make the deferred chain cleaner
        puid = avatar.processUniqueID()

        # only call logout once, whether the connection is dropped (disconnect)
        # or a logout occurs (cleanup), and be careful to drop the reference to
        # it in either case
        logout = [logout]

        def maybeLogout():
            if not logout:
                return
            fn = logout[0]
            del logout[0]
            fn()

        self.broker._localCleanup[puid] = maybeLogout
        self.broker.notifyOnDisconnect(maybeLogout)

        defer.returnValue(avatar)
开发者ID:SejalChauhan,项目名称:Paradrop,代码行数:29,代码来源:riffle.py

示例2: startTLS

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
 def startTLS(self, certificate, *verifyAuthorities):
     if self.hostCertificate is None:
         self.hostCertificate = certificate
         self._justStartedTLS = True
         self.transport.startTLS(certificate.options(*verifyAuthorities))
         stlsb = self._startingTLSBuffer
         if stlsb is not None:
             self._startingTLSBuffer = None
             for box in stlsb:
                 self.sendPacket(box)
     else:
         raise RuntimeError(
             "Previously authenticated connection between %s and %s "
             "is trying to re-establish as %s" % (
                 self.hostCertificate,
                 Certificate.peerFromTransport(self.transport),
                 (certificate, verifyAuthorities)))
开发者ID:perkinslr,项目名称:epsilon-py3,代码行数:19,代码来源:juice.py

示例3: login2

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
    def login2(self, portal):
        self.portal = portal

        # Returns a _RifflePortalWrapper remote reference. Set a timeout
        # in case the connection is down
        self.setTimeout(TIMEOUT)
        root = yield self.getRootObject()

        # Reset the timeout, indicating we've made the connection and are done waiting
        self.setTimeout(None)

        # Extract the name from credentials
        peerCertificate = Certificate.peerFromTransport(self._broker.transport)
        pdid = peerCertificate.getSubject().commonName.decode('utf-8')

        # Returns the server's avatar based on the client's interpretation
        # 'other' is the other end of the connection.
        other = self.portal.partialLogin(pdid)

        # Convert to remote referentiable for transmission
        referencibleOther = pb.AsReferenceable(other, "perspective")

        # Here is the problem. The login call triggers the init call, and that
        # starts the chain of riffle callbacks, but this object won't be back in time by then!

        # Avatar is the remotely described API object
        avatar = yield root.callRemote('login', referencibleOther)
        other.remote = Levy(avatar)

        # This is absolutely not needed. The point of this method is to registers
        # the new connections with the portal, but we already have all the pieces.
        # a, b = yield self.portal.login(pdid, avatar)

        # tttteeeemmmpppppoooorrraaaarrryyy
        realm = self.portal.findRealm(pdid)
        realm.attach(other, avatar)

        avatar.callRemote('handshake')
        other.perspective_handshake()

        defer.returnValue(avatar)
开发者ID:SejalChauhan,项目名称:Paradrop,代码行数:43,代码来源:riffle.py

示例4: dataReceived

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
 def dataReceived(self, data):
     peerCertificate = Certificate.peerFromTransport(self.transport)
     print(peerCertificate.getSubject().commonName.decode('utf-8'))
     self.transport.loseConnection()
开发者ID:damouse,项目名称:pdservertemp,代码行数:6,代码来源:whichclient.py


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