From 24fab162e207ed54051c2073f13b449a60ccea50 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 7 Feb 2017 20:07:57 +0100 Subject: [PATCH] renamed omemo:// to aesgcm:// --- src/main/java/eu/siacs/conversations/entities/Message.java | 4 ++-- ...moURLStreamHandler.java => AesGcmURLStreamHandler.java} | 7 +++++-- ...dlerFactory.java => AesGcmURLStreamHandlerFactory.java} | 6 +++--- .../conversations/services/XmppConnectionService.java | 5 ++--- 4 files changed, 12 insertions(+), 10 deletions(-) rename src/main/java/eu/siacs/conversations/http/{OmemoURLStreamHandler.java => AesGcmURLStreamHandler.java} (52%) rename src/main/java/eu/siacs/conversations/http/{OmemoURLStreamHandlerFactory.java => AesGcmURLStreamHandlerFactory.java} (56%) diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 6cc72ce51..a1fabec5b 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -9,7 +9,7 @@ import java.net.URL; import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; -import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession; +import eu.siacs.conversations.http.AesGcmURLStreamHandler; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.GeoHelper; import eu.siacs.conversations.utils.MimeUtils; @@ -660,7 +660,7 @@ public class Message extends AbstractEntity { String ref = url.getRef(); final String protocol = url.getProtocol(); final boolean encrypted = ref != null && ref.matches("([A-Fa-f0-9]{2}){48}"); - if ("omemo".equalsIgnoreCase(protocol) && encrypted) { + if (AesGcmURLStreamHandler.PROTOCOL_NAME.equalsIgnoreCase(protocol) && encrypted) { return Decision.MUST; } if (!url.getProtocol().equalsIgnoreCase("http") && !url.getProtocol().equalsIgnoreCase("https")) { diff --git a/src/main/java/eu/siacs/conversations/http/OmemoURLStreamHandler.java b/src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandler.java similarity index 52% rename from src/main/java/eu/siacs/conversations/http/OmemoURLStreamHandler.java rename to src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandler.java index 07f28b9e0..e74e50b77 100644 --- a/src/main/java/eu/siacs/conversations/http/OmemoURLStreamHandler.java +++ b/src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandler.java @@ -6,9 +6,12 @@ import java.net.URLConnection; import java.net.URLStreamHandler; -public class OmemoURLStreamHandler extends URLStreamHandler { +public class AesGcmURLStreamHandler extends URLStreamHandler { + + public static final String PROTOCOL_NAME = "aesgcm"; + @Override protected URLConnection openConnection(URL url) throws IOException { - return new URL("https"+url.toString().substring(5)).openConnection(); + return new URL("https"+url.toString().substring(url.getProtocol().length())).openConnection(); } } diff --git a/src/main/java/eu/siacs/conversations/http/OmemoURLStreamHandlerFactory.java b/src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandlerFactory.java similarity index 56% rename from src/main/java/eu/siacs/conversations/http/OmemoURLStreamHandlerFactory.java rename to src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandlerFactory.java index 86421b51b..53b423ad2 100644 --- a/src/main/java/eu/siacs/conversations/http/OmemoURLStreamHandlerFactory.java +++ b/src/main/java/eu/siacs/conversations/http/AesGcmURLStreamHandlerFactory.java @@ -3,11 +3,11 @@ package eu.siacs.conversations.http; import java.net.URLStreamHandler; import java.net.URLStreamHandlerFactory; -public class OmemoURLStreamHandlerFactory implements URLStreamHandlerFactory { +public class AesGcmURLStreamHandlerFactory implements URLStreamHandlerFactory { @Override public URLStreamHandler createURLStreamHandler(String protocol) { - if ("omemo".equals(protocol)) { - return new OmemoURLStreamHandler(); + if (AesGcmURLStreamHandler.PROTOCOL_NAME.equals(protocol)) { + return new AesGcmURLStreamHandler(); } else { return null; } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 05bf8cb46..0fce323da 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -65,7 +65,6 @@ import java.util.ListIterator; import java.util.Locale; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicLong; import de.duenndns.ssl.MemorizingTrustManager; @@ -96,7 +95,7 @@ import eu.siacs.conversations.generator.IqGenerator; import eu.siacs.conversations.generator.MessageGenerator; import eu.siacs.conversations.generator.PresenceGenerator; import eu.siacs.conversations.http.HttpConnectionManager; -import eu.siacs.conversations.http.OmemoURLStreamHandlerFactory; +import eu.siacs.conversations.http.AesGcmURLStreamHandlerFactory; import eu.siacs.conversations.parser.AbstractParser; import eu.siacs.conversations.parser.IqParser; import eu.siacs.conversations.parser.MessageParser; @@ -145,7 +144,7 @@ import me.leolin.shortcutbadger.ShortcutBadger; public class XmppConnectionService extends Service { static { - URL.setURLStreamHandlerFactory(new OmemoURLStreamHandlerFactory()); + URL.setURLStreamHandlerFactory(new AesGcmURLStreamHandlerFactory()); } public static final String ACTION_REPLY_TO_CONVERSATION = "reply_to_conversations";