1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-12 18:49:39 +02:00

Refactor JET in order to match spec

This commit is contained in:
vanitasvitae 2017-08-16 16:42:11 +02:00
parent 5edd630fd0
commit eb413f30b1
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
9 changed files with 78 additions and 70 deletions

View file

@ -46,7 +46,7 @@ import org.jivesoftware.smackx.carbons.CarbonManager;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.eme.element.ExplicitMessageEncryptionElement;
import org.jivesoftware.smackx.hints.element.StoreHint;
import org.jivesoftware.smackx.jet.JingleEncryptionMethod;
import org.jivesoftware.smackx.jet.JingleEnvelopeManager;
import org.jivesoftware.smackx.mam.MamManager;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
@ -91,7 +91,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
* @author Paul Schaub
*/
public final class OmemoManager extends Manager implements JingleEncryptionMethod {
public final class OmemoManager extends Manager implements JingleEnvelopeManager {
private static final Logger LOGGER = Logger.getLogger(OmemoManager.class.getName());
private static final WeakHashMap<XMPPConnection, WeakHashMap<Integer,OmemoManager>> INSTANCES = new WeakHashMap<>();
@ -760,11 +760,15 @@ public final class OmemoManager extends Manager implements JingleEncryptionMetho
return connection();
}
@Override
public String getNamespace() {
public static String getNamespace() {
return OMEMO_NAMESPACE_V_AXOLOTL;
}
@Override
public String getJingleEnvelopeNamespace() {
return getNamespace();
}
/**
* Return the OMEMO service object.
*
@ -870,13 +874,13 @@ public final class OmemoManager extends Manager implements JingleEncryptionMetho
}
@Override
public byte[] decryptJingleTransfer(FullJid sender, ExtensionElement encryptionElement) throws JingleEncryptionException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
if (!encryptionElement.getNamespace().equals(OMEMO_NAMESPACE_V_AXOLOTL)
|| !encryptionElement.getElementName().equals(OmemoElement.ENCRYPTED)) {
public byte[] decryptJingleTransfer(FullJid sender, ExtensionElement envelope) throws JingleEncryptionException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException {
if (!envelope.getNamespace().equals(OMEMO_NAMESPACE_V_AXOLOTL)
|| !envelope.getElementName().equals(OmemoElement.ENCRYPTED)) {
throw new IllegalArgumentException("Passed ExtensionElement MUST be an OmemoElement!");
}
OmemoElement omemoElement = (OmemoElement) encryptionElement;
OmemoElement omemoElement = (OmemoElement) envelope;
Message pseudoMessage = new Message();
pseudoMessage.setFrom(sender.asBareJid());
pseudoMessage.addExtension(omemoElement);