diff options
| author | Jonathan Bauer | 2015-07-06 17:20:22 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-07-06 17:20:22 +0200 |
| commit | 23da82d6eef17e2bd4ec2de497495b32fd338659 (patch) | |
| tree | 3d48cb028951586989786db4e8a0f020e39f6576 /dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java | |
| parent | [client] reworked exceptions handling of BWIDM auth (diff) | |
| download | tutor-module-23da82d6eef17e2bd4ec2de497495b32fd338659.tar.gz tutor-module-23da82d6eef17e2bd4ec2de497495b32fd338659.tar.xz tutor-module-23da82d6eef17e2bd4ec2de497495b32fd338659.zip | |
[client] more error handling changes for BWIDM Auth
Diffstat (limited to 'dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java')
| -rw-r--r-- | dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java | 40 |
1 files changed, 36 insertions, 4 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); } } } |
