aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-08-22 08:55:37 +0200
committersteckbrief <steckbrief@chefmail.de>2016-08-22 08:55:37 +0200
commit77d0c1110a8ae7a980f1c4420d719af803990da8 (patch)
tree20d3ce434f3c6d740141727d4c143ea5f027a646 /src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
parent97100834a5bcb08f2fdf2eb6c580d3ceeb8b6b2f (diff)
parentf45ad10b1baaf09fd4a40d6b63d1cd093623eedc (diff)
Merge remote-tracking branch 'remotes/origin/filetransfer'
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
index 59c54662..529d12c4 100644
--- a/src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
+++ b/src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
@@ -17,6 +17,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.services.AbstractConnectionManager;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
@@ -24,29 +25,23 @@ import de.thedevstack.conversationsplus.utils.CryptoHelper;
import de.thedevstack.conversationsplus.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;
}
@@ -58,26 +53,24 @@ public class HttpConnectionManager extends AbstractConnectionManager {
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(