mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Enable importing keys again
This commit is contained in:
parent
ef00f50d79
commit
9566f5ae65
2 changed files with 9 additions and 3 deletions
|
@ -409,7 +409,12 @@ public class PainlessOpenPgpProvider implements OpenPgpProvider {
|
|||
throw new SmackOpenPgpException("Could not create SecretKeyRingCollection from SecretKeyRing.", e);
|
||||
}
|
||||
} else {
|
||||
secretKeyRings = PGPSecretKeyRingCollection.addSecretKeyRing(secretKeyRings, secretKeys);
|
||||
try {
|
||||
secretKeyRings = PGPSecretKeyRingCollection.addSecretKeyRing(secretKeyRings, secretKeys);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOGGER.log(Level.INFO, "Skip key " + Long.toHexString(secretKeys.getPublicKey().getKeyID()) +
|
||||
" as it is already part of the key ring.");
|
||||
}
|
||||
}
|
||||
getStore().storeSecretKeyRing(owner, secretKeyRings);
|
||||
|
||||
|
|
|
@ -339,7 +339,7 @@ public final class OpenPgpManager extends Manager {
|
|||
SecretKeyRestoreSelectionCallback selectionCallback)
|
||||
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, SmackException.NoResponseException, SmackOpenPgpException,
|
||||
InvalidBackupCodeException, SmackException.NotLoggedInException {
|
||||
InvalidBackupCodeException, SmackException.NotLoggedInException, IOException, MissingUserIdOnKeyException {
|
||||
throwIfNoProviderSet();
|
||||
throwIfNotAuthenticated();
|
||||
SecretkeyElement backup = PubSubDelegate.fetchSecretKey(connection());
|
||||
|
@ -348,7 +348,8 @@ public final class OpenPgpManager extends Manager {
|
|||
return;
|
||||
}
|
||||
byte[] encrypted = Base64.decode(backup.getB64Data());
|
||||
// provider.restoreSecretKeyBackup(backup, codeCallback.askForBackupCode(), selectionCallback);
|
||||
byte[] decrypted = provider.symmetricallyDecryptWithPassword(encrypted, codeCallback.askForBackupCode());
|
||||
provider.importSecretKey(connection().getUser().asBareJid(), decrypted);
|
||||
// TODO: catch InvalidBackupCodeException in order to prevent re-fetching the backup on next try.
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue