summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-17 18:14:08 +0200
committerSimon Rettberg2015-08-17 18:14:08 +0200
commit76f13bf7a26b79b0f4a45ec7992c4bcd8eeb9ee6 (patch)
tree172aa0259d6172f9881e3c02b84b0bdf58bb890c /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
parent[server] Switch to libthrift 0.9.2 (diff)
downloadtutor-module-76f13bf7a26b79b0f4a45ec7992c4bcd8eeb9ee6.tar.gz
tutor-module-76f13bf7a26b79b0f4a45ec7992c4bcd8eeb9ee6.tar.xz
tutor-module-76f13bf7a26b79b0f4a45ec7992c4bcd8eeb9ee6.zip
[server] Add TLS/SSL related classes and functionality (wip)
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
index f1746697..3232374e 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
@@ -13,11 +13,14 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+
import org.apache.log4j.Logger;
import org.openslx.bwlp.sat.database.models.LocalImageVersion;
import org.openslx.bwlp.sat.util.Configuration;
import org.openslx.bwlp.sat.util.Constants;
import org.openslx.bwlp.sat.util.Formatter;
+import org.openslx.bwlp.sat.util.Identity;
import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
import org.openslx.bwlp.thrift.iface.TTransferRejectedException;
import org.openslx.bwlp.thrift.iface.UserInfo;
@@ -35,6 +38,8 @@ public class FileServer implements IncomingEvent {
*/
private final Listener plainListener = new Listener(this, null, 9092, Constants.TRANSFER_TIMEOUT); // TODO: Config
+ private final Listener sslListener;
+
private final ThreadPoolExecutor transferPool = new ThreadPoolExecutor(2, Constants.MAX_UPLOADS
+ Constants.MAX_DOWNLOADS, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(1));
@@ -51,6 +56,8 @@ public class FileServer implements IncomingEvent {
private static final FileServer globalInstance = new FileServer();
private FileServer() {
+ SSLContext ctx = Identity.getSSLContext();
+ sslListener = ctx == null ? null : new Listener(this, ctx, 9093, Constants.TRANSFER_TIMEOUT);
}
public static FileServer instance() {
@@ -59,7 +66,9 @@ public class FileServer implements IncomingEvent {
public boolean start() {
boolean ret = plainListener.start();
- // TODO: Start SSL listener too
+ if (sslListener != null) {
+ ret |= sslListener.start();
+ }
return ret;
}
@@ -146,7 +155,9 @@ public class FileServer implements IncomingEvent {
}
public int getSslPort() {
- return 0; // TODO
+ if (sslListener == null)
+ return 0;
+ return sslListener.getPort();
}
public ActiveDownload createNewUserDownload(LocalImageVersion localImageData)