diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java b/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java index f105646f..a1ad3c01 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java @@ -17,6 +17,8 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; +import de.thedevstack.conversationsplus.ConversationsPlusApplication; + import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.services.XmppConnectionService; @@ -24,29 +26,22 @@ import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.SSLSocketHelper; public class HttpConnectionManager extends AbstractConnectionManager { + private static HttpConnectionManager INSTANCE; - public HttpConnectionManager(XmppConnectionService service) { - super(service); - } + public static void init() { + INSTANCE = new HttpConnectionManager(); + } private List<HttpDownloadConnection> downloadConnections = new CopyOnWriteArrayList<>(); - private List<HttpUploadConnection> uploadConnections = new CopyOnWriteArrayList<>(); - public HttpDownloadConnection createNewDownloadConnection(Message message) { - return this.createNewDownloadConnection(message, false); + public static HttpDownloadConnection createNewDownloadConnection(Message message) { + return createNewDownloadConnection(message, false); } - public HttpDownloadConnection createNewDownloadConnection(Message message, boolean interactive) { - HttpDownloadConnection connection = new HttpDownloadConnection(this); + public static HttpDownloadConnection createNewDownloadConnection(Message message, boolean interactive) { + HttpDownloadConnection connection = new HttpDownloadConnection(INSTANCE); connection.init(message,interactive); - this.downloadConnections.add(connection); - return connection; - } - - public HttpUploadConnection createNewUploadConnection(Message message, boolean delay) { - HttpUploadConnection connection = new HttpUploadConnection(this); - connection.init(message,delay); - this.uploadConnections.add(connection); + INSTANCE.downloadConnections.add(connection); return connection; } @@ -54,30 +49,24 @@ public class HttpConnectionManager extends AbstractConnectionManager { this.downloadConnections.remove(connection); } - public void finishUploadConnection(HttpUploadConnection httpUploadConnection) { - this.uploadConnections.remove(httpUploadConnection); - } - - public void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) { + public static void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) { final X509TrustManager trustManager; final HostnameVerifier hostnameVerifier; if (interactive) { - trustManager = mXmppConnectionService.getMemorizingTrustManager(); - hostnameVerifier = mXmppConnectionService - .getMemorizingTrustManager().wrapHostnameVerifier( + trustManager = ConversationsPlusApplication.getMemorizingTrustManager(); + hostnameVerifier = ConversationsPlusApplication.getMemorizingTrustManager().wrapHostnameVerifier( new StrictHostnameVerifier()); } else { - trustManager = mXmppConnectionService.getMemorizingTrustManager() + trustManager = ConversationsPlusApplication.getMemorizingTrustManager() .getNonInteractive(); - hostnameVerifier = mXmppConnectionService - .getMemorizingTrustManager() + hostnameVerifier = ConversationsPlusApplication.getMemorizingTrustManager() .wrapHostnameVerifierNonInteractive( new StrictHostnameVerifier()); } try { final SSLContext sc = SSLSocketHelper.getSSLContext(); sc.init(null, new X509TrustManager[]{trustManager}, - mXmppConnectionService.getRNG()); + ConversationsPlusApplication.getSecureRandom()); final SSLSocketFactory sf = sc.getSocketFactory(); final String[] cipherSuites = CryptoHelper.getOrderedCipherSuites( |