summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/gui/intro/Login_GUI.java')
-rw-r--r--dozentenmodul/src/main/java/gui/intro/Login_GUI.java131
1 files changed, 63 insertions, 68 deletions
diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
index 16854c0f..02660011 100644
--- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
+++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
@@ -6,8 +6,6 @@ import java.awt.Image;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -22,6 +20,7 @@ import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
@@ -46,13 +45,13 @@ import org.openslx.imagemaster.thrift.iface.OrganizationData;
import org.openslx.imagemaster.thrift.iface.UserInfo;
import thrift.ThriftManager;
-import util.GuiOrganizer;
+import util.GuiManager;
import util.ResourceLoader;
import util.ShibbolethECP;
import config.Config;
@SuppressWarnings("serial")
-public class Login_GUI extends JFrame {
+public class Login_GUI extends JInternalFrame {
/**
* Logger instance for this class.
@@ -72,7 +71,6 @@ public class Login_GUI extends JFrame {
boolean isClientReturnedCorrectly = false;
JCheckBox chckbxBenutzernameSpeichern;
Component c = null;
- String[] args = null;
private JPanel panel;
private JPanel panel_1;
@@ -99,18 +97,7 @@ public class Login_GUI extends JFrame {
/**
* Create the frame.
*/
- public Login_GUI(String[] args) {
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
-
- System.exit(0);
- }
- });
-
- this.args = args;
- // Fenster darf nicht vergroessert werden
- setResizable(false);
+ public Login_GUI() {
try {
// Setzt das Look and Feel auf System
@@ -122,8 +109,6 @@ public class Login_GUI extends JFrame {
}
// Titel des Fensters setzen
setTitle("bwLehrpool Suite");
- // Aktion die beim Schliessen durchgefuehrt werden soll
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Größe setzen und mittig ausrichten
setBounds(0, 0, 785, 430);
@@ -282,9 +267,6 @@ public class Login_GUI extends JFrame {
panel.setVisible(true);
panel_1.setVisible(true);
contentPane.setVisible(true);
-
- GuiOrganizer.centerGUI(this);
- c = this;
}// end LoginGUI()
@@ -341,9 +323,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);
+ if (!ThriftManager.setSatellite(result.serverAddress)) {
+ LOGGER.error("Setting satellite IP to '" + result.serverAddress +
+ "' failed. Appears to be empty. Is the satellite IP returned from masterserver correct?");
+ setStatus(Color.green, "IP von Satelliten invalid.", null);
+ System.exit(1);
+ // TODO handle this correctly
+ }
// Satellite-Connection
setStatus(Color.black, "Hole Verbindungsdaten von Server...", null);
@@ -367,8 +354,7 @@ public class Login_GUI extends JFrame {
person.verantwortlicher.setRole("Dozent");
//person.verantwortlicher.setRole("Student");
}
-
- showMainMenu();
+ postLogin();
//}
} // end bwLehrpool-Login
@@ -389,10 +375,27 @@ public class Login_GUI extends JFrame {
switch(ecpReturn) {
case NO_ERROR:
setStatus(Color.green, "Info: bwIDM-Anmeldung erfolgreich.", null);
- JOptionPane.showMessageDialog(c, "Der Shibboleth-Login war erfolgreich und das Holen der Resource hat geklappt! Der Rest ist noch in Entwicklung :)",
- "Anmeldung erfolgreich", JOptionPane.PLAIN_MESSAGE);
- // all done, show main menu
- showMainMenu();
+ /*
+ * Login successful
+ */
+ person.verantwortlicher.setUsername(lblusername.getText().trim());
+ person.verantwortlicher.setUserID(lblusername.getText().trim());
+ person.verantwortlicher.setName(ShibbolethECP.getResponse().lastName);
+ person.verantwortlicher.setVorname(ShibbolethECP.getResponse().firstName);
+ person.verantwortlicher.setEMail(ShibbolethECP.getResponse().mail);
+ person.verantwortlicher.setHochschule(((OrganizationData)idpChoice.getSelectedItem()).getOrganizationId());
+ person.verantwortlicher.setRole("Dozent");
+ authToken = ShibbolethECP.getResponse().token;
+ ThriftManager.setSatellite(ShibbolethECP.getResponse().satellites.get("default"));
+ SessionData.session.setServerAdress(ShibbolethECP.getResponse().satellites.get("default"));
+ SessionData.session.setAuthToken(ShibbolethECP.getResponse().token);
+ SessionData.session.setSessionID(ShibbolethECP.getResponse().sessionId);
+
+ /*
+ * Now postprocess successful login
+ */
+ postLogin();
+ //showMainMenu();
break;
case ERROR_IDP:
setStatus(Color.red, "Fehler: bwIDM-Anmeldung fehlgeschlagen!", null);
@@ -430,18 +433,6 @@ public class Login_GUI extends JFrame {
}
};
worker.execute();
-
- // now we fake the user information for testing purposes.
- // TODO parse the response from the SP and set the correct user info
- person.verantwortlicher.setUsername(lblusername.getText().trim());
- person.verantwortlicher.setUserID(lblusername.getText().trim());
- person.verantwortlicher.setName("Joe");
- person.verantwortlicher.setVorname("B");
- person.verantwortlicher.setEMail("spam@aol.com");
- person.verantwortlicher.setHochschule("fr-test.de");
- person.verantwortlicher.setRole("Dozent");
- SessionData.session.setServerAdress("132.230.8.199");
-
}
// always save to user's config file.
@@ -459,16 +450,15 @@ public class Login_GUI extends JFrame {
}// end performLogin
/**
- * Shows the next GUI's til the main menu.
- * It checks if the user has already seen the bill of rights
- * and/or the vmware license windows and shows them before
- * continuing to the main menu.
- *
- * This function should be called on a successful login.
+ * Common function for either authentication method
*/
- private void showMainMenu() {
+ private void postLogin() {
+ LOGGER.debug("Post-processing login ...");
+ // TODO here do all the session data stuff
+ // TODO and the telling the sat Server who we are
+ LOGGER.debug("Checking token: " + SessionData.session.getAuthToken());
try {
- boolean authenticated = ThriftManager.getSatClient().authenticated(authToken);
+ boolean authenticated = ThriftManager.getSatClient().authenticated(SessionData.session.getAuthToken());
if(!authenticated) {
//TODO message for user and deactivation of menu points, actually just system exit
System.exit(0);
@@ -484,28 +474,33 @@ public class Login_GUI extends JFrame {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- // Pruefe ob Bills Of Rights schon akzeptiert wurden,
- // wenn nicht zeige diese an
+ // at the end
+ showMainMenu();
+ }
+ /**
+ * Shows the next GUI's til the main menu.
+ * It checks if the user has already seen the bill of rights
+ * and/or the vmware license windows and shows them before
+ * continuing to the main menu.
+ *
+ * This function should be called on a successful login.
+ */
+ private void showMainMenu() {
+ /**
+ *
+ * DISPLAY LICENSES / MAIN MENU
+ *
+ */
if (!Config.getBillOfRights()) {
- // Erstellen einer Instanz der Aktionsauswahl
- BillOfRights_GUI re = new BillOfRights_GUI();
- re.setVisible(true);
- // Schliessen des Fensters nach erfolgreichen Login
- setVisible(false);
+ // display bill of rights?
+ GuiManager.show(new BillOfRights_GUI(), true);
} else {
- // Pruefe ob die Links zu vmware angezeigt werden
- // sollen
+ // display vmware license?
if (!Config.getVmwareLicense()) {
- VmWareLink_GUI vm = new VmWareLink_GUI();
- vm.setVisible(true);
- setVisible(false);
+ GuiManager.show(new VmWareLink_GUI(), true);
} else {
-
- // oeffne das Hauptmenue
- MainMenue_GUI main = new MainMenue_GUI(c);
- main.setVisible(true);
- setVisible(false);
+ // main menu
+ GuiManager.show(new MainMenue_GUI(), true);
}
}
}