mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-07 19:41:11 +01:00
Remove constructor dependency on XMPPConnection from OpenPgpProvider
This commit is contained in:
parent
ccc785062e
commit
4a878ff175
8 changed files with 21 additions and 19 deletions
|
|
@ -520,7 +520,7 @@ public final class OpenPgpManager extends Manager {
|
|||
*/
|
||||
public OpenPgpMessage decryptOpenPgpElement(OpenPgpElement element, OpenPgpContact sender)
|
||||
throws SmackException.NotLoggedInException, IOException, PGPException {
|
||||
return provider.decryptAndOrVerify(element, getOpenPgpSelf(), sender);
|
||||
return provider.decryptAndOrVerify(getAuthenticatedConnectionOrThrow(), element, getOpenPgpSelf(), sender);
|
||||
}
|
||||
|
||||
private void incomingChatMessageListener(final EntityBareJid from, final Message message, Chat chat) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.ox.crypto;
|
|||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpContact;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpMessage;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpSelf;
|
||||
|
|
@ -96,12 +97,13 @@ public interface OpenPgpProvider {
|
|||
* @param element signed and or encrypted {@link OpenPgpElement}.
|
||||
* @param self our OpenPGP identity.
|
||||
* @param sender OpenPGP identity of the sender.
|
||||
* @param connection XMPP connection used to fetch any missing keys.
|
||||
*
|
||||
* @return decrypted message as {@link OpenPgpMessage}.
|
||||
*
|
||||
* @throws IOException IO is dangerous
|
||||
* @throws PGPException PGP is brittle
|
||||
*/
|
||||
OpenPgpMessage decryptAndOrVerify(OpenPgpElement element, OpenPgpSelf self, OpenPgpContact sender)
|
||||
OpenPgpMessage decryptAndOrVerify(XMPPConnection connection, OpenPgpElement element, OpenPgpSelf self, OpenPgpContact sender)
|
||||
throws IOException, PGPException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,11 +51,9 @@ public class PainlessOpenPgpProvider implements OpenPgpProvider {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(PainlessOpenPgpProvider.class.getName());
|
||||
|
||||
private final XMPPConnection connection;
|
||||
private final OpenPgpStore store;
|
||||
|
||||
public PainlessOpenPgpProvider(XMPPConnection connection, OpenPgpStore store) {
|
||||
this.connection = Objects.requireNonNull(connection);
|
||||
public PainlessOpenPgpProvider(OpenPgpStore store) {
|
||||
this.store = Objects.requireNonNull(store);
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +156,7 @@ public class PainlessOpenPgpProvider implements OpenPgpProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OpenPgpMessage decryptAndOrVerify(OpenPgpElement element, final OpenPgpSelf self, final OpenPgpContact sender) throws IOException, PGPException {
|
||||
public OpenPgpMessage decryptAndOrVerify(XMPPConnection connection, OpenPgpElement element, final OpenPgpSelf self, final OpenPgpContact sender) throws IOException, PGPException {
|
||||
ByteArrayOutputStream plainText = new ByteArrayOutputStream();
|
||||
InputStream cipherText = element.toInputStream();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue