Ejemplo n.º 1
0
    def _run_command_execution(self):
        ####################################################################
        """Run function for class."""
        ####################################################################
        yield from self._confirm_pdb()
        self.recipient_list.append(str(self.args["identity"]))
        self.recipient_list = list(set(self.recipient_list))
        yield from self._confirm_recipients()
        for dist_pass, _ in tqdm(self.filtered_pdb.items()):
            password = PasswordEntry()
            password.read_password_data(dist_pass)
            if self.args["identity"] in password.recipients.keys():
                # we shouldn't modify escrow on distribute
                self.args["min_escrow"] = None
                self.args["escrow_users"] = None
                plaintext_pw = password.decrypt_entry(
                    self.identity,
                    passphrase=self.passphrase,
                    card_slot=self.args["card_slot"],
                )
                password.add_recipients(
                    secret=plaintext_pw,
                    distributor=self.args["identity"],
                    recipients=self.recipient_list,
                    session=self.session,
                    passphrase=self.passphrase,
                    card_slot=self.args["card_slot"],
                    pwstore=self.args["pwstore"],
                )

                password.write_password_data(dist_pass)
Ejemplo n.º 2
0
    def create_pass(self, password1, description, authorizer, recipient_list=None):
        """ This writes password data to a file."""
        ##################################################################
        password_metadata = {}
        password_metadata['description'] = description
        password_metadata['authorizer'] = authorizer
        password_metadata['creator'] = self.args['identity']
        password_metadata['name'] = self.args['pwname']
        if self.args['noescrow']:
            self.args['min_escrow'] = None
            self.args['escrow_users'] = None
        if recipient_list is None:
            recipient_list = [self.args['identity']]

        password = PasswordEntry(**password_metadata)

        password.add_recipients(secret=password1,
                                distributor=self.args['identity'],
                                recipients=recipient_list,
                                identitydb=self.identities,
                                passphrase=self.passphrase,
                                card_slot=self.args['card_slot'],
                                escrow_users=self.args['escrow_users'],
                                minimum=self.args['min_escrow'],
                                pwstore=self.args['pwstore']
                               )

        password.write_password_data(path.join(self.args['pwstore'], self.args['pwname']),
                                     overwrite=self.args['overwrite'])
Ejemplo n.º 3
0
    def create_pass(self, password1, description, authorizer, recipient_list=None):
        ##################################################################
        """This writes password data to a file."""
        ##################################################################
        password_metadata = {}
        password_metadata["description"] = description
        password_metadata["authorizer"] = authorizer
        password_metadata["creator"] = self.args["identity"]
        password_metadata["name"] = self.args["pwname"]
        if self.args["noescrow"]:
            self.args["min_escrow"] = None
            self.args["escrow_users"] = None
        if recipient_list is None:
            recipient_list = [self.args["identity"]]

        password = PasswordEntry(**password_metadata)

        password.add_recipients(
            secret=password1,
            distributor=self.args["identity"],
            recipients=recipient_list,
            session=self.session,
            passphrase=self.passphrase,
            card_slot=self.args["card_slot"],
            escrow_users=self.args["escrow_users"],
            minimum=self.args["min_escrow"],
            pwstore=self.args["pwstore"],
        )

        password.write_password_data(
            path.join(self.args["pwstore"], self.args["pwname"]),
            overwrite=self.args["overwrite"],
        )
Ejemplo n.º 4
0
 def update_pass(self, pass_value):
     ##################################################################
     """Fully updated a password record"""
     ##################################################################
     pass_entry = PasswordEntry()
     pass_entry.read_password_data(
         path.join(self.args["pwstore"], self.args["pwname"])
     )
     swap_pass = PasswordEntry()
     swap_pass.add_recipients(
         secret=pass_value,
         distributor=self.args["identity"],
         recipients=[self.args["identity"]],
         session=self.session,
         passphrase=self.passphrase,
         card_slot=self.args["card_slot"],
         escrow_users=self.args["escrow_users"],
         minimum=self.args["min_escrow"],
         pwstore=self.args["pwstore"],
     )
     pass_entry["recipients"][self.args["identity"]] = swap_pass["recipients"][
         self.args["identity"]
     ]
     pass_entry.write_password_data(
         path.join(self.args["pwstore"], self.args["pwname"]),
         overwrite=self.args["overwrite"],
     )
Ejemplo n.º 5
0
    def test_create_encrypt_decrypt(self):
        """create a password entry"""
        passwordentry = PasswordEntry(name='testcreate',
                                      description=self.textblob,
                                      creator='r1',
                                      authorizer='r1')

        passwordentry.add_recipients(secret=self.secret,
                                     distributor='r1',
                                     recipients=self.idobj.recipient_list,
                                     identitydb=self.idobj)
Ejemplo n.º 6
0
    def test_create_encrypt_decrypt(self):
        """create a password entry"""
        passwordentry = PasswordEntry(name="testcreate",
                                      description=self.textblob,
                                      creator="r1",
                                      authorizer="r1")

        passwordentry.add_recipients(
            secret=self.secret,
            distributor="r1",
            recipients=self.idobj.recipient_list,
            session=self.session,
        )
Ejemplo n.º 7
0
    def _run_command_execution(self):
        """ Run function for class.                                      """
        ####################################################################
        passworddb = PasswordDB()
        passworddb.load_from_directory(self.args['pwstore'])
        filtered_pdb = util.dictionary_filter(
            path.join(self.args['pwstore'], self.args['pwname']),
            passworddb.pwdb,
            [self.args['identity'], 'recipients']
        )
        self.recipient_list.append(str(self.args['identity']))
        self.recipient_list = list(set(self.recipient_list))
        print("The following users will receive the password:"******", ".join(self.recipient_list))
        print("The following password files have matched:")
        print(*filtered_pdb.keys(), sep="\n")
        correct_distribution = input("Are these lists correct? (y/N) ")
        if correct_distribution and correct_distribution.lower()[0] == 'y':
            passworddb.pwdb = filtered_pdb
            db_len = len(passworddb.pwdb.keys())
            i = 0
            self.progress_bar(i, db_len)
            for dist_pass, _ in passworddb.pwdb.items():
                password = PasswordEntry()
                password.read_password_data(dist_pass)
                if self.args['identity'] in password.recipients.keys():
                    # we shouldn't modify escrow on distribute
                    self.args['min_escrow'] = None
                    self.args['escrow_users'] = None
                    plaintext_pw = password.decrypt_entry(
                        self.identities.iddb[self.args['identity']],
                        passphrase=self.passphrase,
                        card_slot=self.args['card_slot'])

                    password.read_password_data(dist_pass)
                    password.add_recipients(secret=plaintext_pw,
                                            distributor=self.args['identity'],
                                            recipients=self.recipient_list,
                                            identitydb=self.identities,
                                            passphrase=self.passphrase,
                                            card_slot=self.args['card_slot'],
                                            pwstore=self.args['pwstore']
                                           )

                    password.write_password_data(dist_pass)
                    i += 1
                    self.progress_bar(i, db_len)
            # format the progress bar appropriately after the loop
            print("")
        else:
            print("Exiting due to wrong password list")
Ejemplo n.º 8
0
 def update_pass(self, pass_value):
     pass_entry = PasswordEntry()
     pass_entry.read_password_data(os.path.join(self.args['pwstore'], self.args['pwname']))
     swap_pass = PasswordEntry()
     swap_pass.add_recipients(secret=pass_value,
                              distributor=self.args['identity'],
                              recipients=[self.args['identity']],
                              identitydb=self.identities,
                              passphrase=self.passphrase,
                              card_slot=self.args['card_slot'],
                              pwstore=self.args['pwstore']
                             )
     pass_entry['recipients'][self.args['identity']] = swap_pass['recipients'][self.args['identity']]
     pass_entry.write_password_data(os.path.join(self.args['pwstore'], self.args['pwname']),
                                    overwrite=self.args['overwrite'])