diff options
| author | Jonathan Bauer | 2015-03-02 13:22:44 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2015-03-02 13:22:44 +0100 |
| commit | ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a (patch) | |
| tree | 1e252164aa23b6b74d30c6185fda06ceddcd6041 /dozentenmodul/src/main/java/gui/intro/Login_GUI.java | |
| parent | pom.xml (diff) | |
| download | tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.tar.gz tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.tar.xz tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.zip | |
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!!!
Diffstat (limited to 'dozentenmodul/src/main/java/gui/intro/Login_GUI.java')
| -rw-r--r-- | dozentenmodul/src/main/java/gui/intro/Login_GUI.java | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java index 0af27fee..974a62aa 100644 --- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java +++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java @@ -41,13 +41,12 @@ import models.person; import org.apache.log4j.Logger; import org.apache.thrift.TException; -import org.openslx.imagemaster.thrift.iface.ImageServer.Client; +import org.openslx.imagemaster.thrift.iface.ImageServer; import org.openslx.imagemaster.thrift.iface.OrganizationData; import org.openslx.imagemaster.thrift.iface.UserInfo; import org.openslx.sat.thrift.iface.Server; -import thrift.MasterThriftConnection; -import thrift.ThriftConnection; +import thrift.ThriftManager; import util.GuiOrganizer; import util.ResourceLoader; import util.ShibbolethECP; @@ -295,24 +294,12 @@ public class Login_GUI extends JFrame { public void performLogin(final String loginType) { LOGGER.info("Trying login of type: " + loginType); - - - if (loginType == LOGIN_TYPE_BWLEHRPOOL) - { + if (loginType == LOGIN_TYPE_BWLEHRPOOL) { // start the authentication process against the masterserver org.openslx.imagemaster.thrift.iface.SessionData result = null; // Connect to Master - MasterThriftConnection thrift = new MasterThriftConnection(); - Client client = thrift.getMasterThriftConnection(); - - if (client == null) { - // Thrift connection to master could not be established - setStatus(Color.red, "Fehler: Masterserver nicht erreichbar.", null); - LOGGER.info("Thrift client could not be initialized, is the masterserver up and running?"); - return; - } - + ImageServer.Client client = ThriftManager.getMasterClient(); String passText = new String(lblpass.getPassword()); UserInfo user = null; // Log user in @@ -355,18 +342,14 @@ public class Login_GUI extends JFrame { // set Information SessionData.session.setAuthToken(result.authToken); SessionData.session.setSessionID(result.sessionId); + // TODO: support list of adresses SessionData.session.setServerAdress(result.serverAddress); + ThriftManager.setSatellite(result.serverAddress); // Satellite-Connection setStatus(Color.black, "Hole Verbindungsdaten von Server...", null); - // set connection to bwLehrpoolSuiteServer - ThriftConnection bwthrift = new ThriftConnection(); - Server.Client bwClient = bwthrift.getThriftConnection(); - models.Client.clientcon.setClient(bwClient); // User-Info - //LOGGER.debug("Session-ID: " + result.sessionId); - //LOGGER.debug("Token: " + result.authToken); setStatus(Color.green, "Daten erhalten.", null); String hochschule = user.eMail.substring(user.eMail.indexOf("@") + 1); @@ -417,6 +400,11 @@ public class Login_GUI extends JFrame { JOptionPane.showMessageDialog(c, "Anmeldung fehlgeschlagen. Überprüfen Sie den Benutzername und Passwort.", "Fehler", JOptionPane.ERROR_MESSAGE); break; + case ERROR_UNREG: + setStatus(Color.red, "Fehler: Nicht bei bwLehrpool registriert!", null); + JOptionPane.showMessageDialog(c, "Sie sind nicht bei bwLehrpool registriert.\nGehen Sie dazu auf folgende Seite:\n" + + ShibbolethECP.getRegistrationUrl(), "Fehler", JOptionPane.ERROR_MESSAGE); + break; case ERROR_SP: setStatus(Color.red, "Fehler: bwIDM-Anmeldung fehlgeschlagen!", null); JOptionPane.showMessageDialog(c, "Anmeldung erfolgreich aber die Antwort des Service Providers ist ungültig.", @@ -480,33 +468,19 @@ public class Login_GUI extends JFrame { * This function should be called on a successful login. */ private void showMainMenu() { - - /* - * TODO check if user has already been regisistered. if not, do so - * - * - */ - //import server.generated.Server.Client; - Server.Client client_2 = models.Client.clientcon.getClient(); - try - { - boolean authenticated = client_2.authenticated(authToken); - - if(!authenticated) - { + try { + boolean authenticated = ThriftManager.getSatClient().authenticated(authToken); + if(!authenticated) { //TODO message for user and deactivation of menu points, actually just system exit System.exit(0); } - } catch (TException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { - String pk_institution = client_2.setInstitution(person.verantwortlicher.getHochschule(),SessionData.session.getAuthToken()); - //LOGGER.info("Institution of user is: "+pk_institution); - client_2.setPerson(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken(),pk_institution); - //LOGGER.info("user data, ID="+person.verantwortlicher.getUserID()+" , Name="+person.verantwortlicher.getName()+" , Vorname="+ person.verantwortlicher.getVorname()+" , E-Mail="+ person.verantwortlicher.getEMail()+" , Institution="+ pk_institution); + String pk_institution = ThriftManager.getSatClient().setInstitution(person.verantwortlicher.getHochschule(),SessionData.session.getAuthToken()); + ThriftManager.getSatClient().setPerson(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken(),pk_institution); } catch (TException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -636,11 +610,11 @@ public class Login_GUI extends JFrame { protected Boolean doInBackground() throws Exception { publish("Info: Hole Liste von IdPs"); // if not then request it from the masterserver - MasterThriftConnection thrift = new MasterThriftConnection(); - Client client = thrift.getMasterThriftConnection(); List<OrganizationData> tempOrgs = null; try { - tempOrgs = client.getOrganizations(); + if (ThriftManager.getMasterClient() == null) LOGGER.error("DERP"); + + tempOrgs = ThriftManager.getMasterClient().getOrganizations(); } catch (TException e) { LOGGER.error("Could not fetch list of identity providers from the masterserver, see trace: ", e); return false; |
