Ejemplo n.º 1
0
    def remove(self, common_name=None, fingerprint=None):
        if not common_name and not fingerprint:
            print colors.red("You should specify either common name or "
                             "fingerprint to be removed.")
            return False

        keys = []
        with open(self.store_fn, 'r') as f:
            for l in f:
                cn, _, fp = l.strip().rpartition(self.SEP)
                if common_name != cn and fingerprint != fp:
                    keys.append("%s%s%s" % (cn, self.SEP, fp))

        f = open(self.store_fn, 'w')
        f.write('\n'.join(keys))
        f.close()
        print colors.blue("Fingerprint/Common name %s/%s was removed" %
                          (common_name, fingerprint))
        self.reload()
        return True
Ejemplo n.º 2
0
    def remove(self, common_name=None, fingerprint=None):
        if not common_name and not fingerprint:
            print colors.red("You should specify either common name or "
                             "fingerprint to be removed.")
            return False

        keys = []
        with open(self.store_fn, 'r') as f:
            for l in f:
                cn, _, fp = l.strip().rpartition(self.SEP)
                if common_name != cn and fingerprint != fp:
                    keys.append("%s%s%s" % (cn, self.SEP, fp))

        f = open(self.store_fn, 'w')
        f.write('\n'.join(keys))
        f.close()
        print colors.blue("Fingerprint/Common name %s/%s was removed" %
                          (common_name, fingerprint))
        self.reload()
        return True
Ejemplo n.º 3
0
    def insert(self, common_name, fingerprint):
        access_key = "%s%s%s" % (common_name, self.SEP, fingerprint)

        with open(self.store_fn, 'r') as f:
            for l in f:
                cn, _, fp = l.partition(self.SEP)
                if fp == fingerprint:
                    print colors.red(
                        "The specified fingerprint already exists. "
                        "You should first unregister it.")
                    return False
                if cn == common_name and fp != fingerprint:
                    print colors.red(
                        "The specified common name already exists. "
                        "You should first unregister it.")
                    return False

        with open(self.store_fn, 'a') as f:
            f.write('\n%s' % access_key)
            f.close()
            print colors.blue("Fingerprint for %s was added" % common_name)
        self.reload()
        return True
Ejemplo n.º 4
0
    def insert(self, common_name, fingerprint):
        access_key = "%s%s%s" % (common_name, self.SEP, fingerprint)

        with open(self.store_fn, 'r') as f:
            for l in f:
                cn, _, fp = l.partition(self.SEP)
                if fp == fingerprint:
                    print colors.red(
                        "The specified fingerprint already exists. "
                        "You should first unregister it.")
                    return False
                if cn == common_name and fp != fingerprint:
                    print colors.red(
                        "The specified common name already exists. "
                        "You should first unregister it.")
                    return False

        with open(self.store_fn, 'a') as f:
            f.write('\n%s' % access_key)
            f.close()
            print colors.blue("Fingerprint for %s was added" %
                              common_name)
        self.reload()
        return True
Ejemplo n.º 5
0
 def list_cli(self):
     user_store = CONFIG.user_store
     store = CertStore(user_store)
     for cli in store._store:
         print colors.blue("%-40s %s" % cli)
Ejemplo n.º 6
0
    def details(self):
        if not hasattr(self, "backend"):
            self.backend = self.transport_class.from_config(CONFIG)

        meta = OrderedDict(sorted(self.backend.meta().items(),
                                  key=lambda x: x[0]))

        print colors.blue('%-30s' % 'ID', bold=1), colors.blue('%s' %
                                                               CONFIG.node_id)
        for k, v in meta.items():
            print colors.blue('%-30s' % k, bold=1), colors.blue(v)
        if self.backend.properties:
            print colors.blue('===== Backend properties =====')
            for item in self.backend.properties:
                print colors.blue('%-30s' % item[0], bold=1), \
                    colors.blue(item[1])
Ejemplo n.º 7
0
 def details(self):
     self._create_backend()
     if self.backend.properties:
         for item in self.backend.properties:
             print colors.blue('%-30s' % item[0], bold=1), \
                 colors.blue(item[1])
Ejemplo n.º 8
0
 def list_cli(self):
     user_store = CONFIG.user_store
     store = CertStore(user_store)
     for cli in store._store:
         print colors.blue("%-40s %s" % cli)
Ejemplo n.º 9
0
    def details(self):
        if not hasattr(self, "backend"):
            self.backend = self.transport_class.from_config(CONFIG)

        meta = OrderedDict(
            sorted(self.backend.meta().items(), key=lambda x: x[0]))

        print colors.blue('%-30s' % 'ID',
                          bold=1), colors.blue('%s' % CONFIG.node_id)
        for k, v in meta.items():
            print colors.blue('%-30s' % k, bold=1), colors.blue(v)
        if self.backend.properties:
            print colors.blue('===== Backend properties =====')
            for item in self.backend.properties:
                print colors.blue('%-30s' % item[0], bold=1), \
                    colors.blue(item[1])
Ejemplo n.º 10
0
 def details(self):
     self.matcher = Matcher(CONFIG.node_id)
     props = [(k, v) for (k, v) in self.matcher.props.items()]
     props = sorted(props, key=lambda x: x[0])
     print colors.blue('%-30s' % 'ID', bold=1), colors.blue('%s' %
                                                            CONFIG.node_id)
     for item in props:
         print colors.blue('%-30s' % item[0], bold=1), colors.blue(item[1])
     if not hasattr(self, "backend"):
         self.backend = self.transport_class.from_config(CONFIG)
     if self.backend.properties:
         print colors.blue('===== Backend properties =====')
         for item in self.backend.properties:
             print colors.blue('%-30s' % item[0], bold=1), \
                 colors.blue(item[1])