def _buildKey(self, key, comment): if isinstance(key, basestring): try: key = Key.fromString(key) except: raise ValueError("Invalid key data") if not isinstance(key, Key): raise ValueError("Invalid key") return PublicKey(key, self.id, comment, self._db)
def loadKeys(self): log.debug("Loading keys from auth {0} agents".format(len(self.agents))) keys = {} for agent in self.agents: log.debug("Requesting keys from {0}".format(agent)) rawKeys = yield agent.requestIdentities() log.debug("Loaded {0} keys from {1}".format(len(rawKeys), agent)) for blob, comment in rawKeys: k = Key.fromString(blob) k.comment = comment k.agent = agent keys[k.id] = k log.debug("Loaded {0} keys from {1} agents".format( len(keys), len(self.agents))) self._updateKeys(keys) returnValue(keys)
def parseArgs(self, id, keyFile): self["id"] = id try: self["key"] = Key.fromFile(keyFile) except: raise UsageError("Invalid key file: {0}".format(keyFile))