示例#1
0
 def on_mi_parse_password_activate(self, widget):
     dlg = dialogs.ParsePasswordDialog()
     response = dlg.run()
     if response == gtk.RESPONSE_OK:
         pswd = FigaroPassword()
         pswd.update(dlg.parseddict)
         self.addPasswordInteractively(pswd)
示例#2
0
    def do_new(self, arg):
        '''Add new password to current category. You will be prompted to enter
fields.

Syntax:
    new [-p]

    -p - Get properties by parsing provided text. Will open default text editor
         for you to paste text in.
'''
        new_pass = FigaroPassword(
        )  # FIXME: Password type shouldn't be hardcoded.
        argv = arg.split()

        if "-p" in argv:
            text = self.getEditorInput()
            choosendict = parser.parseMessage(text, self.conf.patterns)
            new_pass.update(choosendict)

        try:
            self.editPassword(new_pass)
        except (KeyboardInterrupt, EOFError):
            print "Cancelled"
        else:
            tree = self.getCwd()
            tree.addNode(new_pass)
            self.tryToSave()
示例#3
0
文件: wnd_main.py 项目: sbjud/kedpm
 def on_mi_parse_password_activate(self, widget):
     dlg = dialogs.ParsePasswordDialog()
     response = dlg.run()
     if response == gtk.RESPONSE_OK:
         pswd = FigaroPassword()
         pswd.update(dlg.parseddict)
         self.addPasswordInteractively(pswd)
示例#4
0
 def test_tooLongPassword(self):
     pwd = FigaroPassword()
     longpswd = "1234567890" * 3
     self.assertRaises(FigaroPasswordTooLongError, pwd.__setitem__,
                       'password', longpswd)
     self.assertRaises(FigaroPasswordTooLongError, pwd.update,
                       {'password': longpswd})
     pwd.store_long_password = 1
     pwd['title'] = "Long password"
     pwd['password'] = longpswd
     self.pdb.getTree()['Test'].addNode(pwd)
     self.pdb.save(fname="fpm.saved")
     self.pdb = PDBFigaro()
     self.pdb.open(self.password, fname='fpm.saved')
     saved_pwd = self.pdb.getTree()['Test'].locate('Long password')[0]
     self.assertEqual(saved_pwd['password'], longpswd)
示例#5
0
 def test_tooLongPassword(self):
     pwd = FigaroPassword()
     longpswd = "1234567890"*3;
     self.assertRaises(FigaroPasswordTooLongError, pwd.__setitem__,
         'password', longpswd)
     self.assertRaises(FigaroPasswordTooLongError, pwd.update,
         {'password': longpswd})
     pwd.store_long_password = 1
     pwd['title'] = "Long password"
     pwd['password'] = longpswd
     self.pdb.getTree()['Test'].addNode(pwd)
     self.pdb.save(fname="fpm.saved")
     self.pdb = PDBFigaro()
     self.pdb.open(self.password, fname='fpm.saved')
     saved_pwd = self.pdb.getTree()['Test'].locate('Long password')[0]
     self.assertEqual(saved_pwd['password'], longpswd)
示例#6
0
文件: cli.py 项目: chutzimir/kedpm
    def do_new(self, arg):
        '''Add new password to current category. You will be prompted to enter
fields.

Syntax:
    new [-p | -t]

    -p - Get properties by parsing provided text. Will open default text editor
         for you to paste text in. Mutually exclusive with -t option. 
    -t - Display editor template in default text editor. Mutually exclusive with -p option.
'''
        new_pass = FigaroPassword() # FIXME: Password type shouldn't be hardcoded.
        argv = arg.split()

        if   "-p" in argv and "-t" in argv:
            print _("new: -p and -t arguments are mutually exclusive.")          
            print _("try 'help new' for more information")
        elif "-p" in argv:
            text = self.getEditorInput()
            choosendict = parser.parseMessage(text, self.conf.patterns)
            new_pass.update(choosendict)
        elif "-t" in argv:
            text = self.getEditorInput(new_pass.asEditText())
            choosendict = parser.parseMessage(text, [new_pass.getEditPattern()])
            new_pass.update(choosendict)

        try:
            self.editPassword(new_pass)
        except (KeyboardInterrupt, EOFError):
            self.printMessage(_("Cancelled"))
        else:
            tree = self.getCwd()
            tree.addNode(new_pass)
            self.tryToSave()
示例#7
0
文件: cli.py 项目: chutzimir/kedpm
    def do_import(self, arg):
        '''Imports new password records into current category.
Syntax:
    import
    
    Get properties by parsing provided text. Will open default text editor
    for you to paste text in.
'''
        argv = arg.split()
        tree = self.getCwd()

        text = self.getEditorInput()
        for line in text.split("\n"):
            new_pass = FigaroPassword() # FIXME: Password type shouldn't be hardcoded.
            choosendict = parser.parseMessage(line, self.conf.patterns)
            new_pass.update(choosendict)
            tree.addNode(new_pass)

        self.tryToSave()
示例#8
0
    def do_import(self, arg):
        '''Imports new password records into current category.
Syntax:
    import
    
    Get properties by parsing provided text. Will open default text editor
    for you to paste text in.
'''
        argv = arg.split()
        tree = self.getCwd()

        text = self.getEditorInput()
        for line in [x for x in text.splitlines() if x]:
            new_pass = FigaroPassword(
            )  # FIXME: Password type shouldn't be hardcoded.
            choosendict = parser.parseMessage(line, self.conf.patterns)
            new_pass.update(choosendict)
            tree.addNode(new_pass)

        self.tryToSave()
示例#9
0
    def test_catlessPassword(self):
        'Saving and loading password without category'

        tree = self.pdb.getTree()
        pwd = FigaroPassword(title='CLHost', password='******')
        tree.addNode(pwd)
        self.pdb.save(fname='fpm.saved')
        self.pdb = PDBFigaro()
        self.pdb.open(self.password, fname='fpm.saved')
        tlnodes = self.pdb.getTree().getNodes()
        self.assertEqual(len(tlnodes), 1)
        self.assertEqual(tlnodes[0].title, 'CLHost')
        self.assertEqual(tlnodes[0]['password'], 'CLPass')
        self.assertEqual(tlnodes[0]['url'], '')
示例#10
0
    def addPasswordInteractively(self, pswd=None):
        """Add the given password to the current category interactively. 
        
        Let user deside add the password or not and let him correct information
        before adding."""

        if pswd is None:
            pswd = FigaroPassword()
        dlg = dialogs.PasswordEditDialog(pswd)
        response = dlg.run()
        if response == gtk.RESPONSE_OK:
            self.getCWTree().addNode(pswd)
            self.setupPasswords()
            self.tryToSave()
示例#11
0
    def do_new(self, arg):
        '''Add new password to current category. You will be prompted to enter
fields.

Syntax:
    new [-p | -t]

    -p - Get properties by parsing provided text. Will open default text editor
         for you to paste text in. Mutually exclusive with -t option. 
    -t - Display editor template in default text editor. Mutually exclusive with -p option.

    If the config option 'force-editor is set, this command defaults to the -t option when no options are provided.
'''
        new_pass = FigaroPassword(
        )  # FIXME: Password type shouldn't be hardcoded.

        argv = arg.split()

        use_visual_editor = len(
            argv) == 0 and self.conf.options["force-editor"]

        if "-p" in argv and "-t" in argv:
            print _("new: -p and -t arguments are mutually exclusive.")
            print _("try 'help new' for more information")
        elif "-p" in argv:
            text = self.getEditorInput()
            choosendict = parser.parseMessage(text, self.conf.patterns)
            new_pass.update(choosendict)
        elif "-t" in argv or use_visual_editor:
            text = self.getEditorInput(new_pass.asEditText())
            choosendict = parser.parseMessage(text,
                                              [new_pass.getEditPattern()])
            new_pass.update(choosendict)

        try:
            if not use_visual_editor:
                self.editPassword(new_pass)
        except (KeyboardInterrupt, EOFError):
            self.printMessage(_("Cancelled"))
        else:
            tree = self.getCwd()
            tree.addNode(new_pass)
            self.tryToSave()