summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/util/ShibbolethECP.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/util/ShibbolethECP.java')
-rw-r--r--dozentenmodul/src/main/java/util/ShibbolethECP.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/dozentenmodul/src/main/java/util/ShibbolethECP.java b/dozentenmodul/src/main/java/util/ShibbolethECP.java
index 3dea9e3e..b834b1a2 100644
--- a/dozentenmodul/src/main/java/util/ShibbolethECP.java
+++ b/dozentenmodul/src/main/java/util/ShibbolethECP.java
@@ -1,8 +1,10 @@
package util;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
@@ -31,13 +33,19 @@ public class ShibbolethECP {
private static final Gson GSON = new GsonBuilder().create();
/**
+ * URL for bwLehrpool registration
+ */
+ private static URL _registrationUrl = null;
+ /**
* Return codes
*/
public static enum ReturnCode {
NO_ERROR(0, "Authentication against the identity provider and request of the service provider resource worked."),
ERROR_IDP(1, "Authentication against the identity provider failed."),
- ERROR_SP(2, "Invalid resource of the service provider."),
- ERROR_OTHER(3, "Internal class error.");
+ ERROR_UNREG(2, "User not registered to use bwLehrpool"),
+ ERROR_SP(3, "Invalid resource of the service provider."),
+ ERROR_URL(4, "Invalid URL received from master server."),
+ ERROR_OTHER(5, "Internal class error.");
private final int id;
private final String msg;
@@ -63,7 +71,7 @@ public class ShibbolethECP {
static {
URI tmp;
try {
- tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/secure-all/test.php");
+ tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/secure-all/api.php");
} catch (URISyntaxException e) {
// should never happen!
LOGGER.error("Bad URI syntax of the service provider, see trace: ", e);
@@ -148,9 +156,23 @@ public class ShibbolethECP {
LOGGER.error("Bad JSON syntax, see trace: ", e);
return ReturnCode.ERROR_SP;
}
- LOGGER.debug("SP JSON STATUS: " + spr.getStatus());
// TODO: here we will need to parse the answer accordingly.
// no errors, meaning everything worked fine.
- return spr.getStatus().equals("funzt") ? ReturnCode.NO_ERROR : ReturnCode.ERROR_SP;
+ if (spr.status.equals("unregistered")) {
+ try {
+ _registrationUrl = new URL(spr.url);
+ } catch (MalformedURLException e) {
+ LOGGER.error("URL returned by masterserver is malformed, see trace: " + e);
+ return ReturnCode.ERROR_URL;
+ }
+ return ReturnCode.ERROR_UNREG;
+ }
+ // TODO the rest of the cases...
+
+ // still here? then something else went wrong
+ return ReturnCode.ERROR_OTHER;
+ }
+ public static URL getRegistrationUrl() {
+ return _registrationUrl;
}
}