when wrong GPG passphrase is entered, we re-ask to user twice. Fixes [1410]

This commit is contained in:
Yann Leboulanger 2006-01-21 21:19:14 +00:00
parent 97378c63ed
commit 89bf45a2c6
2 changed files with 28 additions and 10 deletions

View File

@ -1916,6 +1916,13 @@ class Connection:
#Inform GUI we just signed in
self.dispatch('SIGNED_IN', ())
def test_gpg_passphrase(self, password):
self.gpg.passphrase = password
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
signed = self.gpg.sign('test', keyID)
self.gpg.password = None
return signed != 'BAD_PASSPHRASE'
def get_signed_msg(self, msg):
signed = ''
keyID = gajim.config.get_per('accounts', self.name, 'keyid')

View File

@ -1518,16 +1518,27 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
passphrase = self.gpg_passphrase[keyid]
save = False
else:
w = dialogs.PassphraseDialog(
_('Passphrase Required'),
_('Enter GPG key passphrase for account %s') % account,
_('Save passphrase'))
passphrase, save = w.run()
if passphrase == -1:
passphrase = None
else:
self.gpg_passphrase[keyid] = passphrase
gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid)
password_ok = False
count = 0
title = _('Passphrase Required')
second = _('Enter GPG key passphrase for account %s.') % \
account
while not password_ok and count < 3:
count += 1
w = dialogs.PassphraseDialog(title, second,
_('Save passphrase'))
passphrase, save = w.run()
if passphrase == -1:
passphrase = None
password_ok = True
else:
password_ok = gajim.connections[account].\
test_gpg_passphrase(passphrase)
title = _('Wrong Passphrase')
second = _('Please retype your GPG passphrase or press Cancel.')
if passphrase != None:
self.gpg_passphrase[keyid] = passphrase
gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid)
if save:
gajim.config.set_per('accounts', account, 'savegpgpass', True)
gajim.config.set_per('accounts', account, 'gpgpassword',