summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/gui/intro
diff options
context:
space:
mode:
authorJonathan Bauer2015-03-02 13:22:44 +0100
committerJonathan Bauer2015-03-02 13:22:44 +0100
commitea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a (patch)
tree1e252164aa23b6b74d30c6185fda06ceddcd6041 /dozentenmodul/src/main/java/gui/intro
parentpom.xml (diff)
downloadtutor-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')
-rw-r--r--dozentenmodul/src/main/java/gui/intro/Login_GUI.java64
-rw-r--r--dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java6
2 files changed, 21 insertions, 49 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;
diff --git a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java
index 504203fe..c811b585 100644
--- a/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java
+++ b/dozentenmodul/src/main/java/gui/intro/MainMenue_GUI.java
@@ -56,6 +56,7 @@ import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.sat.thrift.iface.Server.Client;
+import thrift.ThriftManager;
import util.News;
import util.OpenLinks;
import util.ResourceLoader;
@@ -82,9 +83,6 @@ public class MainMenue_GUI extends JFrame {
private JMenuItem mntmAbout;
Component c = null;
- Client client = models.Client.clientcon.getClient();
-
-
// for testing
ImageRights imageRights = new ImageRights();
@@ -97,7 +95,7 @@ public class MainMenue_GUI extends JFrame {
@Override
public void windowClosing(WindowEvent arg0) {
try {
- tokenDeleted = client.setSessionInvalid(SessionData.session.getAuthToken());
+ tokenDeleted = ThriftManager.getSatClient().setSessionInvalid(SessionData.session.getAuthToken());
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();