From 0447841f3a08890bf746625d0f17976adada6ac8 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 3 Mar 2015 19:02:48 +0100 Subject: bwIDM - Shibboleth login working for Freiburg's SP - more to come rework GUI classes to work with GuiManager: use GuiManager.show() and GuiManager.openPopup() only! static openlinks class (models/links.java deleted). There are keywords to open links, e.g. OpenLinks.openWebpage("faq"). Please see the class. --- .../src/main/java/util/ShibbolethECP.java | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 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 b834b1a2..a3e13a38 100644 --- a/dozentenmodul/src/main/java/util/ShibbolethECP.java +++ b/dozentenmodul/src/main/java/util/ShibbolethECP.java @@ -32,6 +32,10 @@ public class ShibbolethECP { */ private static final Gson GSON = new GsonBuilder().create(); + /** + * + */ + private static ServiceProviderResponse _lastResponse = null; /** * URL for bwLehrpool registration */ @@ -71,7 +75,7 @@ public class ShibbolethECP { static { URI tmp; try { - tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/secure-all/api.php"); + tmp = new URI("https://bwlp-masterserver.ruf.uni-freiburg.de/webif/shib/api.php"); } catch (URISyntaxException e) { // should never happen! LOGGER.error("Bad URI syntax of the service provider, see trace: ", e); @@ -80,6 +84,9 @@ public class ShibbolethECP { BWLP_SP = tmp; } + public static ServiceProviderResponse getResponse() { + return _lastResponse; + } /** * Fetches the resource * @@ -149,18 +156,18 @@ public class ShibbolethECP { LOGGER.error("I/O error, see trace: ", e); return ReturnCode.ERROR_OTHER; } - ServiceProviderResponse spr = null; + _lastResponse = null; try { - spr = GSON.fromJson(responseBody, ServiceProviderResponse.class); + _lastResponse = GSON.fromJson(responseBody, ServiceProviderResponse.class); } catch (JsonSyntaxException e) { LOGGER.error("Bad JSON syntax, see trace: ", e); return ReturnCode.ERROR_SP; } // TODO: here we will need to parse the answer accordingly. // no errors, meaning everything worked fine. - if (spr.status.equals("unregistered")) { + if (_lastResponse.status.equals("unregistered")) { try { - _registrationUrl = new URL(spr.url); + _registrationUrl = new URL(_lastResponse.url); } catch (MalformedURLException e) { LOGGER.error("URL returned by masterserver is malformed, see trace: " + e); return ReturnCode.ERROR_URL; @@ -168,7 +175,17 @@ public class ShibbolethECP { return ReturnCode.ERROR_UNREG; } // TODO the rest of the cases... - + if (_lastResponse.status.equals("error")) { + LOGGER.error("Server side error: " + _lastResponse.error); + return ReturnCode.ERROR_OTHER; + } + if (_lastResponse.status.equals("anonymous")) { + LOGGER.error("IdP did not forward user account information to SP. Contact developper."); + return ReturnCode.ERROR_OTHER; + } + if (_lastResponse.status.equals("ok")) { + return ReturnCode.NO_ERROR; + } // still here? then something else went wrong return ReturnCode.ERROR_OTHER; } -- cgit v1.2.3-55-g7522