From ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 2 Mar 2015 13:22:44 +0100 Subject: ThriftManager class: use getSatClient() and getMasterClient() to get the singleton instances of the thrift clients to satellite and master servers DO NOT CREATE NEW THRIFT OBJECTS!!! --- .../src/main/java/util/ShibbolethECP.java | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'dozentenmodul/src/main/java/util/ShibbolethECP.java') 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; @@ -30,14 +32,20 @@ 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; } } -- cgit v1.2.3-55-g7522