mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-07 19:41:11 +01:00
Fix some runtime bugs
This commit is contained in:
parent
422baa6d2e
commit
800955d5a8
6 changed files with 105 additions and 18 deletions
|
|
@ -317,14 +317,18 @@ public final class OpenPgpManager extends Manager {
|
|||
if (pubkeyElement == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
processPublicKey(pubkeyElement, jid);
|
||||
available.add(f);
|
||||
|
||||
} catch (PubSubException.NotAPubSubNodeException | PubSubException.NotALeafNodeException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not fetch public key " + f.toString() + " of user " + jid.toString(), e);
|
||||
unfetched.put(f, e);
|
||||
} catch (MissingUserIdOnKeyException e) {
|
||||
LOGGER.log(Level.WARNING, "Key does not contain user-id of " + jid + ". Ignoring the key.", e);
|
||||
unfetched.put(f, e);
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not import key " + f.toString() + " of user " + jid.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -382,7 +386,7 @@ public final class OpenPgpManager extends Manager {
|
|||
*/
|
||||
|
||||
private void processPublicKey(PubkeyElement pubkeyElement, BareJid owner)
|
||||
throws MissingUserIdOnKeyException {
|
||||
throws MissingUserIdOnKeyException, IOException, SmackOpenPgpException {
|
||||
byte[] base64 = pubkeyElement.getDataElement().getB64Data();
|
||||
provider.importPublicKey(owner, Base64.decode(base64));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,9 +133,11 @@ public interface OpenPgpProvider {
|
|||
throws SmackOpenPgpException, InvalidAlgorithmParameterException, NoSuchAlgorithmException,
|
||||
NoSuchProviderException, IOException;
|
||||
|
||||
OpenPgpV4Fingerprint importPublicKey(BareJid owner, byte[] bytes) throws MissingUserIdOnKeyException;
|
||||
OpenPgpV4Fingerprint importPublicKey(BareJid owner, byte[] bytes)
|
||||
throws MissingUserIdOnKeyException, IOException, SmackOpenPgpException;
|
||||
|
||||
OpenPgpV4Fingerprint importSecretKey(BareJid owner, byte[] bytes) throws MissingUserIdOnKeyException;
|
||||
OpenPgpV4Fingerprint importSecretKey(BareJid owner, byte[] bytes)
|
||||
throws MissingUserIdOnKeyException, SmackOpenPgpException, IOException;
|
||||
|
||||
OpenPgpStore getStore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.logging.Logger;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpV4Fingerprint;
|
||||
import org.jivesoftware.smackx.ox.element.PubkeyElement;
|
||||
|
|
@ -205,7 +206,15 @@ public class PubSubDelegate {
|
|||
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
|
||||
SmackException.NoResponseException {
|
||||
PubSubManager pm = PubSubManager.getInstance(connection, connection.getUser().asBareJid());
|
||||
pm.deleteNode(PEP_NODE_PUBLIC_KEYS);
|
||||
try {
|
||||
pm.deleteNode(PEP_NODE_PUBLIC_KEYS);
|
||||
} catch (XMPPException.XMPPErrorException e) {
|
||||
if (e.getXMPPError().getCondition() == StanzaError.Condition.item_not_found) {
|
||||
LOGGER.log(Level.FINE, "Node does not exist. No need to delete it.");
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue