diff options
Diffstat (limited to 'dozentenmodul/src/main/java/auth')
| -rw-r--r-- | dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java | 40 | ||||
| -rw-r--r-- | dozentenmodul/src/main/java/auth/BaseAuthenticator.java | 5 |
2 files changed, 40 insertions, 5 deletions
diff --git a/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java b/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java index e4da3cc3..40c1d2eb 100644 --- a/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java +++ b/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java @@ -1,5 +1,11 @@ package auth; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; + +import org.apache.http.ParseException; +import org.apache.http.client.ClientProtocolException; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.TAuthenticationException; @@ -7,6 +13,8 @@ import org.openslx.bwlp.thrift.iface.TInvalidTokenException; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.thrifthelper.ThriftManager; +import com.google.gson.JsonSyntaxException; + import util.ShibbolethECP; import util.ShibbolethECP.ReturnCode; @@ -36,10 +44,30 @@ public class BWIDMAuthenticator implements BaseAuthenticator { @Override public void login(String username, String password, AuthenticatorCallback callback) throws TAuthenticationException { - // sanity check on the ecpUrl, should have been set - - ReturnCode ret = ShibbolethECP.doLogin(this.ecpUrl, username, password); + // try to login + ReturnCode ret = null; + try { + ret = ShibbolethECP.doLogin(this.ecpUrl, username, password); + } catch (JsonSyntaxException e) { + LOGGER.error("Could not parse JSON response from the service provider: ", e); + } catch (ClientProtocolException e) { + LOGGER.error("HTTP client protocol error: ", e); + } catch (ParseException e) { + LOGGER.error("Error parsing the raw response body from the service provider: ", e); + } catch (MalformedURLException e) { + LOGGER.error("Bad syntax of the registration URL returned by the service provider: ", e); + } catch (URISyntaxException e) { + LOGGER.error("Bad syntax of the URL to the identity provider: ", e); + } catch (IOException e) { + LOGGER.error("IO Error while communicating with the service provider: ", e); + } + // if ret is still null, some exception happened, so abort. + if (ret == null) { + LOGGER.error("Error during the ECP authentication process."); + return; + } + // else, we do have a valid ReturnCode if (ret == ReturnCode.NO_ERROR) { UserInfo userInfo; try { @@ -51,7 +79,11 @@ public class BWIDMAuthenticator implements BaseAuthenticator { LOGGER.error("Thrift transport error, see trace: ", e); return; } - callback.postLogin(userInfo); + callback.postLogin(ReturnCode.NO_ERROR, userInfo); + } else { + // else just return the ReturnCode to the GUI + // it should then show a corresponding error message! + callback.postLogin(ret, null); } } } diff --git a/dozentenmodul/src/main/java/auth/BaseAuthenticator.java b/dozentenmodul/src/main/java/auth/BaseAuthenticator.java index d52c5343..f22577d8 100644 --- a/dozentenmodul/src/main/java/auth/BaseAuthenticator.java +++ b/dozentenmodul/src/main/java/auth/BaseAuthenticator.java @@ -3,6 +3,9 @@ package auth; import org.openslx.bwlp.thrift.iface.TAuthenticationException; import org.openslx.bwlp.thrift.iface.UserInfo; +import util.ShibbolethECP.ReturnCode; +import edu.kit.scc.dei.ecplean.ECPAuthenticationException; + /** * @author Jonathan Bauer * @@ -16,7 +19,7 @@ public interface BaseAuthenticator { * corresponding message to the user. */ interface AuthenticatorCallback { - void postLogin(UserInfo user); + void postLogin(ReturnCode returnCode, UserInfo user); } /** * Definition of the generic login method. |
