summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/auth
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-08 19:39:35 +0200
committerSimon Rettberg2015-07-08 19:39:35 +0200
commit8d6cd17c330388aa13fd7c39802c7400d85f972c (patch)
tree5f2c5856f58b1454e24dc16fad10751dfe9d087b /dozentenmodul/src/main/java/auth
parentoops (diff)
downloadtutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.tar.gz
tutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.tar.xz
tutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.zip
[client] Redo package structure, add comments/TODOs, rename GUI classes
Diffstat (limited to 'dozentenmodul/src/main/java/auth')
-rw-r--r--dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java89
-rw-r--r--dozentenmodul/src/main/java/auth/BWLPAuthenticator.java56
-rw-r--r--dozentenmodul/src/main/java/auth/BaseAuthenticator.java33
3 files changed, 0 insertions, 178 deletions
diff --git a/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java b/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java
deleted file mode 100644
index 40c1d2eb..00000000
--- a/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java
+++ /dev/null
@@ -1,89 +0,0 @@
-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;
-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;
-
-/**
- * @author Jonathan Bauer
- *
- */
-public class BWIDMAuthenticator implements BaseAuthenticator {
-
- /**
- * Logger instance for this class
- */
- private final static Logger LOGGER = Logger.getLogger(BWIDMAuthenticator.class);
-
- private final String ecpUrl;
-
- public BWIDMAuthenticator(String ecpUrl) {
- // first lets check the given ecpUrl
- if (!ecpUrl.isEmpty())
- this.ecpUrl = ecpUrl;
- else
- this.ecpUrl = null;
- // NOTE: the actual check for a correct URI will be done by
- // the ECP client.
- }
-
- @Override
- public void login(String username, String password,
- AuthenticatorCallback callback) throws TAuthenticationException {
- // 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 {
- userInfo = ThriftManager.getMasterClient().getUserFromToken(ShibbolethECP.getResponse().token);
- } catch (TInvalidTokenException e) {
- LOGGER.error("Masterserver does not accepts the token received from the Service Provider. See trace: ", e);
- return;
- } catch (TException e) {
- LOGGER.error("Thrift transport error, see trace: ", e);
- return;
- }
- 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/BWLPAuthenticator.java b/dozentenmodul/src/main/java/auth/BWLPAuthenticator.java
deleted file mode 100644
index 66c31d73..00000000
--- a/dozentenmodul/src/main/java/auth/BWLPAuthenticator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package auth;
-
-import org.apache.log4j.Logger;
-import org.apache.thrift.TException;
-import org.openslx.bwlp.thrift.iface.SessionData;
-import org.openslx.bwlp.thrift.iface.TAuthenticationException;
-import org.openslx.bwlp.thrift.iface.TAuthorizationException;
-import org.openslx.bwlp.thrift.iface.UserInfo;
-import org.openslx.thrifthelper.ThriftManager;
-
-import util.ShibbolethECP.ReturnCode;
-
-/**
- * @author Jonathan Bauer
- *
- */
-public class BWLPAuthenticator implements BaseAuthenticator {
-
- /**
- * Logger instance for this class
- */
- private final static Logger LOGGER = Logger.getLogger(BWLPAuthenticator.class);
-
- @Override
- public void login(String username, String password,
- AuthenticatorCallback callback) throws TAuthenticationException {
-
- SessionData authResult = null;
- // try to login user
- try {
- authResult = ThriftManager.getMasterClient().authenticate(username, password);
- } catch (TException e) {
- LOGGER.error("Thrift communication error: ", e);
- // TODO authenticate has to return a TAuthenticationException!
- callback.postLogin(ReturnCode.ERROR_OTHER, null);
- return;
- }
-
- // handle answer from server
- if (authResult != null && authResult.authToken != null) {
- UserInfo userInfo = null;
- try {
- userInfo = ThriftManager.getMasterClient().getUserFromToken(authResult.authToken);
- } catch (TException e) {
- LOGGER.error("Thrift communication error: ", e);
- // TODO authenticate has to return a TAuthenticationException!
- callback.postLogin(ReturnCode.ERROR_OTHER, null);
- return;
- }
- callback.postLogin(ReturnCode.NO_ERROR, userInfo);
- } else {
- // it should then show a corresponding error message!
- callback.postLogin(ReturnCode.ERROR_OTHER, null);
- }
- }
-}
diff --git a/dozentenmodul/src/main/java/auth/BaseAuthenticator.java b/dozentenmodul/src/main/java/auth/BaseAuthenticator.java
deleted file mode 100644
index f22577d8..00000000
--- a/dozentenmodul/src/main/java/auth/BaseAuthenticator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-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
- *
- */
-public interface BaseAuthenticator {
-
- /**
- * Callback interface to the login to be called after a login
- * Note that this will be called after every login, independent
- * of the success of the operation. This way the GUI can show a
- * corresponding message to the user.
- */
- interface AuthenticatorCallback {
- void postLogin(ReturnCode returnCode, UserInfo user);
- }
- /**
- * Definition of the generic login method.
- *
- * @param username The username as String.
- * @param password The password as String.
- * @param callback The callback function to be called after the login
- * @throws ECPAuthenticationException
- */
- void login(String username, String password, AuthenticatorCallback callback) throws TAuthenticationException;
-} \ No newline at end of file