mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-24 04:52:05 +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);
|
throw new SmackOpenPgpException("Could not create SecretKeyRingCollection from SecretKeyRing.", e);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
getStore().storeSecretKeyRing(owner, secretKeyRings);
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ public final class OpenPgpManager extends Manager {
|
||||||
SecretKeyRestoreSelectionCallback selectionCallback)
|
SecretKeyRestoreSelectionCallback selectionCallback)
|
||||||
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
|
||||||
SmackException.NotConnectedException, SmackException.NoResponseException, SmackOpenPgpException,
|
SmackException.NotConnectedException, SmackException.NoResponseException, SmackOpenPgpException,
|
||||||
InvalidBackupCodeException, SmackException.NotLoggedInException {
|
InvalidBackupCodeException, SmackException.NotLoggedInException, IOException, MissingUserIdOnKeyException {
|
||||||
throwIfNoProviderSet();
|
throwIfNoProviderSet();
|
||||||
throwIfNotAuthenticated();
|
throwIfNotAuthenticated();
|
||||||
SecretkeyElement backup = PubSubDelegate.fetchSecretKey(connection());
|
SecretkeyElement backup = PubSubDelegate.fetchSecretKey(connection());
|
||||||
|
@ -348,7 +348,8 @@ public final class OpenPgpManager extends Manager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
byte[] encrypted = Base64.decode(backup.getB64Data());
|
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.
|
// TODO: catch InvalidBackupCodeException in order to prevent re-fetching the backup on next try.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue