summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/thrift/ThriftManager.java
diff options
context:
space:
mode:
authorJonathan Bauer2015-03-03 19:02:48 +0100
committerJonathan Bauer2015-03-03 19:02:48 +0100
commit0447841f3a08890bf746625d0f17976adada6ac8 (patch)
treef63bd9f2ac8d77f4732b70cac8e5c0497f4d3a45 /dozentenmodul/src/main/java/thrift/ThriftManager.java
parentwarnings fix (diff)
downloadtutor-module-0447841f3a08890bf746625d0f17976adada6ac8.tar.gz
tutor-module-0447841f3a08890bf746625d0f17976adada6ac8.tar.xz
tutor-module-0447841f3a08890bf746625d0f17976adada6ac8.zip
bwIDM - Shibboleth login working for Freiburg's SP - more to come
rework GUI classes to work with GuiManager: use GuiManager.show(<GUI to show>) and GuiManager.openPopup(<popup like About_GUI or ListAllOtherUsers_GUI>) only! static openlinks class (models/links.java deleted). There are keywords to open links, e.g. OpenLinks.openWebpage("faq"). Please see the class.
Diffstat (limited to 'dozentenmodul/src/main/java/thrift/ThriftManager.java')
-rw-r--r--dozentenmodul/src/main/java/thrift/ThriftManager.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/thrift/ThriftManager.java b/dozentenmodul/src/main/java/thrift/ThriftManager.java
index 716c4439..cc085ecd 100644
--- a/dozentenmodul/src/main/java/thrift/ThriftManager.java
+++ b/dozentenmodul/src/main/java/thrift/ThriftManager.java
@@ -1,5 +1,8 @@
package thrift;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.apache.log4j.Logger;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
@@ -44,6 +47,15 @@ public class ThriftManager {
private static final int SATELLITE_TIMEOUT = 10000;
/**
+ * IP Validation Regex
+ */
+ private static final String IP_VALID_PATTERN =
+ "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
+ "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
+ "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
+ "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
+
+ /**
* Protected constructor to avoid external instantiation
*/
protected ThriftManager() {
@@ -106,6 +118,7 @@ public class ThriftManager {
final TProtocol protocol = new TBinaryProtocol(transport);
// now we are ready to create the client, according to ClientType!
_satClient.set(new Server.Client(protocol));
+ LOGGER.info("Satellite '" + SATELLITE_IP + "' reachable. Client initialised.");
}
return true;
}
@@ -119,7 +132,22 @@ public class ThriftManager {
LOGGER.error("Given IP for satellite is empty.");
return false;
}
+ // validate
+ Matcher matcher = Pattern.compile(IP_VALID_PATTERN).matcher(ip);
+ if (!matcher.matches()) {
+ LOGGER.error("Given form of IP is invalid: " + ip);
+ return false;
+ }
+ // finally set it
SATELLITE_IP = ip;
+
+ // last check: try to connect
+ if (!init(ClientType.SATELLITE, SATELLITE_IP, SATELLITE_PORT, SATELLITE_TIMEOUT)) {
+ // init failed
+ LOGGER.error("Could not initialise new client to satellite: " + SATELLITE_IP);
+ return false;
+ }
+ // TODO final last: get version from server
return true;
}
/**