本文整理汇总了Python中pyndn.security.KeyChain.getPolicyManager方法的典型用法代码示例。如果您正苦于以下问题:Python KeyChain.getPolicyManager方法的具体用法?Python KeyChain.getPolicyManager怎么用?Python KeyChain.getPolicyManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.security.KeyChain
的用法示例。
在下文中一共展示了KeyChain.getPolicyManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Bootstrap
# 需要导入模块: from pyndn.security import KeyChain [as 别名]
# 或者: from pyndn.security.KeyChain import getPolicyManager [as 别名]
#.........这里部分代码省略.........
if "identity" in confObj:
if confObj["identity"] == "default":
# TODO: handling the case where no default identity is present
defaultIdentity = self._keyChain.getDefaultIdentity()
else:
defaultIdentity = Name(confObj["identity"])
else:
defaultIdentity = self._keyChain.getDefaultIdentity()
# TODO: handling signature with direct bits instead of keylocator keyname
if "signer" in confObj:
if confObj["signer"] == "default":
signerName = None
else:
signerName = Name(confObj["signer"])
else:
signerName = None
print "Deriving from " + signerName.toUri() + " for controller name"
helper(defaultIdentity, signerName)
else:
if isinstance(defaultIdentityOrFileName, Name):
helper(defaultIdentityOrFileName, signerName)
else:
raise RuntimeError("Please call setupDefaultIdentityAndRoot with identity name and root key name")
return
def onControllerCertData(self, interest, data, onSetupComplete, onSetupFailed):
# TODO: verification rule for received self-signed cert.
# So, if a controller comes masquerading in at this point with the right name, it is problematic. Similar with ndn-pi's implementation
self._controllerCertificate = IdentityCertificate(data)
# insert root certificate so that we could verify initial trust schemas
# TODO: this does not seem a good approach, implementation-wise and security implication
self._keyChain.getPolicyManager()._certificateCache.insertCertificate(self._controllerCertificate)
try:
self._identityManager.addCertificate(self._controllerCertificate)
except SecurityException as e:
print str(e)
for schema in self._trustSchemas:
# TODO: remove the concept of pending-schema
if "pending-schema" in self._trustSchemas[schema]:
self._keyChain.verifyData(self._trustSchemas[schema]["pending-schema"], self.onSchemaVerified, self.onSchemaVerificationFailed)
if onSetupComplete:
onSetupComplete(Name(self._defaultCertificateName), self._keyChain)
return
def onControllerCertTimeout(self, interest, onSetupComplete, onSetupFailed, controllerCertRetries):
print "Controller certificate interest times out"
newInterest = Interest(interest)
newInterest.refreshNonce()
if controllerCertRetries == 0:
if onSetupFailed:
onSetupFailed("Controller certificate interest times out")
else:
print "Set up failed: controller certificate interest times out"
else:
self._face.expressInterest(newInterest,
lambda interest, data: self.onControllerCertData(interest, data, onSetupComplete, onSetupFailed),
lambda interest: self.onControllerCertTimeout(interest, onSetupComplete, onSetupFailed, controllerCertRetries - 1))
return
#########################################################
# Handling application consumption (trust schema updates)
#########################################################
# TODO: if trust schema gets over packet size limit, segmentation
def startTrustSchemaUpdate(self, appPrefix, onUpdateSuccess = None, onUpdateFailed = None):