aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-05-29 20:33:36 +0200
committersteckbrief <steckbrief@chefmail.de>2016-05-29 20:33:36 +0200
commitb1ab7347b92329512bebe57f6624cae33c27036f (patch)
tree9234c39535e6320d0ca217b9e28e3dfcd0eb56ea /src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
parentd3a2fe5796e18493a8ff641308d2c6d21bfd06a4 (diff)
FileTransfer reworked (first steps - functionality as is), HttpUpload
separated, some bugfixes - HttpUpload moved into own package - FileTransfer managed by a central manager class, several FileTransferService implementation can be used - Security initializations moved to ConversationsPlusApplication - Access to PowerManager moved to ConversationsPlusApplication - Removed unused code fragments - Access to HttpConnectionManager is now static
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(