summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/gui
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/gui')
-rw-r--r--dozentenmodul/src/main/java/gui/intro/Login_GUI.java415
1 files changed, 212 insertions, 203 deletions
diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
index 8cb8b3ca..d6f53a4f 100644
--- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
+++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
@@ -42,6 +42,7 @@ import org.apache.thrift.TException;
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.version.Version;
import org.openslx.thrifthelper.ThriftManager;
import util.GuiManager;
@@ -57,12 +58,12 @@ public class Login_GUI extends JInternalFrame {
*/
private final static Logger LOGGER = Logger.getLogger(Login_GUI.class);
String authToken = null;
-
+
// String constants representing the different login methods
private final static String LOGIN_TYPE_BWIDM = "bwidm";
private final static String LOGIN_TYPE_BWLEHRPOOL = "bwlp";
private final static String LOGIN_TYPE_SATELLITE = "sat";
-
+
private JPanel contentPane;
private JTextField lblusername;
private JPasswordField lblpass;
@@ -75,7 +76,7 @@ public class Login_GUI extends JInternalFrame {
private JPanel panel_1;
private JLabel LabelUser;
private JLabel LabelPass;
-
+
// radio button and group for login types.
private ButtonGroup bgLoginType;
private JRadioButton rdbtnBwIDM;
@@ -83,12 +84,12 @@ public class Login_GUI extends JInternalFrame {
private JRadioButton rdbtnMasterserver;
// its action listener
private ActionListener loginTypeActionListener;
-
+
// bwIDM label and dropdown
private JComboBox<OrganizationData> idpChoice;
private JLabel lblIdp;
private List<OrganizationData> organizations;
-
+
// Satellite IP label and text field
private JLabel lblSatellitenIp;
private JTextField lblSatIP;
@@ -101,9 +102,8 @@ public class Login_GUI extends JInternalFrame {
try {
// Setzt das Look and Feel auf System
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (ClassNotFoundException | InstantiationException
- | IllegalAccessException | UnsupportedLookAndFeelException e) {
-
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
+
e.printStackTrace();
}
// Titel des Fensters setzen
@@ -127,8 +127,7 @@ public class Login_GUI extends JInternalFrame {
imgLabel.setBounds(231, 11, 350, 142);
// Pfadangabe des Logos
- ImageIcon icon = ResourceLoader.getIcon("/img/Logo_bwLehrpool.png",
- "Logo");
+ ImageIcon icon = ResourceLoader.getIcon("/img/Logo_bwLehrpool.png", "Logo");
// Skalierung des Logos
Image scaled = icon.getImage().getScaledInstance(270, 64, 0);
imgLabel.setIcon(new ImageIcon(scaled));
@@ -152,26 +151,25 @@ public class Login_GUI extends JInternalFrame {
BtnLogin.setBounds(488, 358, 239, 23);
contentPane.add(BtnLogin);
-
+
// Start of the actual content of the right panel
panel = new JPanel();
panel.setLayout(null);
- panel.setBorder(new TitledBorder(null, "Zugangsdaten",
- TitledBorder.LEADING, TitledBorder.TOP, null, null));
+ panel.setBorder(new TitledBorder(null, "Zugangsdaten", TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel.setBackground(SystemColor.menu);
panel.setBounds(354, 143, 400, 181);
contentPane.add(panel);
-
+
chckbxBenutzernameSpeichern = new JCheckBox("Benutzername speichern");
chckbxBenutzernameSpeichern.setBounds(135, 137, 237, 23);
chckbxBenutzernameSpeichern.setSelected(Config.getSaveUsername());
panel.add(chckbxBenutzernameSpeichern);
-
+
// Erzeugen und Hinzufuegen des Labels
LabelUser = new JLabel("Benutzername:");
LabelUser.setBounds(25, 60, 82, 20);
panel.add(LabelUser);
-
+
// Erzeugen und Hinzufuegen des Textfeldes
lblusername = new JTextField();
lblusername.setBounds(135, 60, 237, 20);
@@ -185,12 +183,12 @@ public class Login_GUI extends JInternalFrame {
}
});
panel.add(lblusername);
-
+
// Erzeugen und Hinzufuegen des Labels
LabelPass = new JLabel("Passwort:");
LabelPass.setBounds(25, 85, 82, 20);
panel.add(LabelPass);
-
+
// Erzeugen und Hinzufuegen des Passwortfeldes
lblpass = new JPasswordField();
lblpass.setBounds(135, 85, 237, 20);
@@ -201,24 +199,24 @@ public class Login_GUI extends JInternalFrame {
}
});
panel.add(lblpass);
-
+
lblSatellitenIp = new JLabel("Satelliten IP:");
lblSatellitenIp.setBounds(25, 105, 82, 20);
- //panel.add(lblSatellitenIp);
-
+ // panel.add(lblSatellitenIp);
+
lblSatIP = new JTextField();
lblSatIP.setBounds(135, 110, 237, 20);
lblSatIP.setToolTipText("Bitte geben Sie die IP-Adresse des Satelliten ein.");
- //panel.add(lblSatIP);
+ // panel.add(lblSatIP);
idpChoice = new JComboBox<OrganizationData>();
idpChoice.setBounds(135, 35, 237, 20);
- //panel.add(choice);
-
+ // panel.add(choice);
+
lblIdp = new JLabel("IdP:");
lblIdp.setBounds(25, 35, 82, 20);
- //panel.add(lblIdp);
-
+ // panel.add(lblIdp);
+
// action listener for the radio buttons to
// toggle the gui elements depending on the login type
loginTypeActionListener = new ActionListener() {
@@ -227,26 +225,25 @@ public class Login_GUI extends JInternalFrame {
toggleLoginType(e.getActionCommand());
}
};
-
+
panel_1 = new JPanel();
panel_1.setLayout(null);
- panel_1.setBorder(new TitledBorder(
- UIManager.getBorder("TitledBorder.border"), "Authentifizierungsart",
- TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
+ panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Authentifizierungsart", TitledBorder.LEADING, TitledBorder.TOP, null,
+ new Color(0, 0, 0)));
panel_1.setBackground(SystemColor.menu);
panel_1.setBounds(10, 143, 334, 181);
contentPane.add(panel_1);
-
+
// group radio button for the login type together
bgLoginType = new ButtonGroup();
-
+
rdbtnBwIDM = new JRadioButton("Authentifizierung über bwIDM");
rdbtnBwIDM.setBounds(32, 35, 244, 23);
rdbtnBwIDM.setActionCommand(LOGIN_TYPE_BWIDM);
rdbtnBwIDM.addActionListener(loginTypeActionListener);
bgLoginType.add(rdbtnBwIDM);
panel_1.add(rdbtnBwIDM);
-
+
rdbtnMasterserver = new JRadioButton("Test-Zugang mit festem Benutzer");
rdbtnMasterserver.setSelected(true);
rdbtnMasterserver.setActionCommand(LOGIN_TYPE_BWLEHRPOOL);
@@ -254,7 +251,7 @@ public class Login_GUI extends JInternalFrame {
rdbtnMasterserver.setBounds(32, 60, 244, 23);
bgLoginType.add(rdbtnMasterserver);
panel_1.add(rdbtnMasterserver);
-
+
rdbtnDirekteVerbindung = new JRadioButton("Direkte Verbindung zum Satelliten");
rdbtnDirekteVerbindung.setBounds(32, 85, 244, 23);
rdbtnDirekteVerbindung.setActionCommand(LOGIN_TYPE_SATELLITE);
@@ -262,19 +259,18 @@ public class Login_GUI extends JInternalFrame {
rdbtnDirekteVerbindung.setEnabled(false);
bgLoginType.add(rdbtnDirekteVerbindung);
panel_1.add(rdbtnDirekteVerbindung);
-
+
panel.setVisible(true);
panel_1.setVisible(true);
contentPane.setVisible(true);
-
}// end LoginGUI()
// Versuche den Benutzer einzuloggen
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;
@@ -284,8 +280,7 @@ public class Login_GUI extends JInternalFrame {
UserInfo user = null;
// Log user in
try {
- setStatus(Color.black,
- "Authentifiziere - warte auf Antwort von Server...", null);
+ setStatus(Color.black, "Authentifiziere - warte auf Antwort von Server...", null);
result = client.authenticate(lblusername.getText(), passText);
@@ -300,21 +295,15 @@ public class Login_GUI extends JInternalFrame {
LOGGER.info("Authentifizierung von '" + lblusername.getText() + "' erfolgreich.");
user = client.getUserFromToken(result.authToken);
authToken = result.authToken;
-
} catch (org.openslx.imagemaster.thrift.iface.AuthenticationException e) {
- setStatus(
- Color.red,
- "Fehler: Zugangsdaten nicht akzeptiert.",
- "Benutzeranmeldung fehlgeschlagen: Bitte Benutzername und Passwort überprüfen.\n"
- + e.message);
+ setStatus(Color.red, "Fehler: Zugangsdaten nicht akzeptiert.",
+ "Benutzeranmeldung fehlgeschlagen: Bitte Benutzername und Passwort überprüfen.\n" + e.message);
e.printStackTrace();
return;
} catch (TException e) {
e.printStackTrace();
- setStatus(Color.red,
- "Kommunikation mit Masterserver fehlgeschlagen.",
- null);
+ setStatus(Color.red, "Kommunikation mit Masterserver fehlgeschlagen.", null);
LOGGER.error("Thrift-communication to the masterserver failed, see trace: ", e);
return;
}
@@ -324,19 +313,15 @@ public class Login_GUI extends JInternalFrame {
SessionData.session.setSessionID(result.sessionId);
SessionData.session.setServerAdress(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);
+ 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 vom Satelliten ungültig.", null);
System.exit(1);
- // TODO handle this correctly
}
- // Satellite-Connection
- setStatus(Color.black, "Hole Verbindungsdaten von Server...", null);
-
// User-Info
setStatus(Color.green, "Daten erhalten.", null);
-
+
String hochschule = user.eMail.substring(user.eMail.indexOf("@") + 1);
person.verantwortlicher.setUsername(lblusername.getText().trim());
@@ -347,20 +332,20 @@ public class Login_GUI extends JInternalFrame {
person.verantwortlicher.setHochschule(hochschule);
// Spaeter ueber result.getRole zum Beispiel die Rolle holen
- if(lblusername.getText().trim().startsWith("admin@")){
+ if (lblusername.getText().trim().startsWith("admin@")) {
person.verantwortlicher.setRole("Admin");
- } else {
- person.verantwortlicher.setRole("Dozent");
- //person.verantwortlicher.setRole("Student");
+ } else {
+ person.verantwortlicher.setRole("Dozent");
+ // person.verantwortlicher.setRole("Student");
}
postLogin();
-
- //}
+
+ // }
} // end bwLehrpool-Login
-
+
if (loginType == LOGIN_TYPE_BWIDM) {
// try the shibbo login in its own SwingWorker to avoid GUI lockups
- SwingWorker<ShibbolethECP.ReturnCode, String> worker = new SwingWorker<ShibbolethECP.ReturnCode, String>(){
+ SwingWorker<ShibbolethECP.ReturnCode, String> worker = new SwingWorker<ShibbolethECP.ReturnCode, String>() {
@Override
protected ShibbolethECP.ReturnCode doInBackground() throws Exception {
publish("Info: Initialisiere Shibboleth-Client ...");
@@ -368,56 +353,58 @@ public class Login_GUI extends JInternalFrame {
publish("Info: Überprüfe Zugangdaten über bwIDM ...");
return ShibbolethECP.doLogin(selectedOrg.getEcpUrl(), lblusername.getText().trim(), String.valueOf(lblpass.getPassword()));
}
+
protected void done() {
try {
ShibbolethECP.ReturnCode ecpReturn = get();
- switch(ecpReturn) {
- case NO_ERROR:
- setStatus(Color.green, "Info: bwIDM-Anmeldung erfolgreich.", null);
- /*
- * 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);
- 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.",
- "Fehler", JOptionPane.ERROR_MESSAGE);
- break;
- case ERROR_OTHER:
- setStatus(Color.red, "Fehler: bwIDM-Anmeldung fehlgeschlagen!", null);
- JOptionPane.showMessageDialog(c, "Fataler Fehler. Schicken Sie die Log-Datei einem Administrator zu!",
- "Fehler", JOptionPane.ERROR_MESSAGE);
- break;
- default:
- setStatus(Color.red, "Fehler: bwIDM-Login fehlgeschlagen!", null);
+ switch (ecpReturn) {
+ case NO_ERROR:
+ setStatus(Color.green, "Info: bwIDM-Anmeldung erfolgreich.", null);
+ /*
+ * 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);
+ 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.", "Fehler",
+ JOptionPane.ERROR_MESSAGE);
+ break;
+ case ERROR_OTHER:
+ setStatus(Color.red, "Fehler: bwIDM-Anmeldung fehlgeschlagen!", null);
+ JOptionPane.showMessageDialog(c, "Fataler Fehler. Schicken Sie die Log-Datei einem Administrator zu!", "Fehler",
+ JOptionPane.ERROR_MESSAGE);
+ break;
+ default:
+ setStatus(Color.red, "Fehler: bwIDM-Login fehlgeschlagen!", null);
}
} catch (InterruptedException e) {
LOGGER.error("SwingWorker for ShibbolethECP got interrupted, see trace: ", e);
@@ -425,9 +412,10 @@ public class Login_GUI extends JInternalFrame {
LOGGER.error("Execution of SwingWorker for ShibbolethECP failed, see trace: ", e);
}
}
+
@Override
protected void process(List<String> msgs) {
- String currentMessage = msgs.get(msgs.size()-1);
+ String currentMessage = msgs.get(msgs.size() - 1);
setStatus(Color.black, currentMessage, null);
}
};
@@ -445,43 +433,63 @@ public class Login_GUI extends JInternalFrame {
// save it to local disk
Config.store();
-
}// end performLogin
/**
* Common function for either authentication method
*/
private void postLogin() {
+ // Version check
+ long remoteVersion;
+ try {
+ remoteVersion = ThriftManager.getSatClient().getVersion();
+ LOGGER.info("Satellite RPC version: " + remoteVersion);
+ } catch (Exception e) {
+ LOGGER.error("Could not query sat server version after successful connect! Assuming untagged version 1", e);
+ remoteVersion = 1;
+ }
+ String text = null;
+ if (remoteVersion > Version.VERSION) {
+ text = "Das von Ihnen verwendete Dozentenmodul ist zu alt, um mit dem Satelliten-Server zu verbinden.\n"
+ + "Sie verwenden Version " + Version.VERSION
+ + ", der Satellit " + remoteVersion + "\n"
+ + "Aktuelle Version unter http://bwlehrpool.hs-offenburg.de/";
+ } else if (remoteVersion < Version.VERSION) {
+ text = "Das von Ihnen verwendete Dozentenmodul ist zu neu, um mit dem Satelliten-Server zu verbinden.\n"
+ + "Sie verwenden Version " + Version.VERSION
+ + ", der Satellit " + remoteVersion;
+ }
+ if (text != null) {
+ JOptionPane.showMessageDialog(null, text, "Fehler", JOptionPane.ERROR_MESSAGE);
+ }
+
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(SessionData.session.getAuthToken());
- if(!authenticated) {
- //TODO message for user and deactivation of menu points, actually just system exit
- System.exit(0);
+ if (!authenticated) {
+ JOptionPane.showMessageDialog(null, "Sessionübergabe an den Satelliten fehlgeschlagen.", "Fehler", JOptionPane.ERROR_MESSAGE);
+ return;
}
- } catch (TException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- try {
- String pk_institution = ThriftManager.getSatClient().setInstitution(person.verantwortlicher.getHochschule(),SessionData.session.getAuthToken());
- ThriftManager.getSatClient().setPerson(person.verantwortlicher.getUserID(),SessionData.session.getAuthToken(),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();
+ JOptionPane.showMessageDialog(null, "Unerwarteter Fehler.\n\n" + e.toString(), "Fehler", JOptionPane.ERROR_MESSAGE);
+ LOGGER.error("Unexpected exception", e);
+ return;
}
+
// 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.
- *
+ * 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() {
@@ -520,75 +528,72 @@ public class Login_GUI extends JInternalFrame {
lblConnectionInfo.setForeground(color);
lblConnectionInfo.setText(shortMessage);
if (longMessage != null)
- JOptionPane.showMessageDialog(c, longMessage,
- "Anmeldung fehlgeschlagen", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(c, longMessage, "Anmeldung fehlgeschlagen", JOptionPane.ERROR_MESSAGE);
}
-
+
/**
* Toggle the elements needed for the different login types.
*
* @param type
- * Type of the login to toggle. Valid are:
- * - LOGIN_TYPE_BWIDM
- * - LOGIN_TYPE_BWLEHRPOOL
- * - LOGIN_TYPE_SATELLITE
+ * Type of the login to toggle. Valid are: - LOGIN_TYPE_BWIDM -
+ * LOGIN_TYPE_BWLEHRPOOL - LOGIN_TYPE_SATELLITE
*/
private void toggleLoginType(String type) {
LOGGER.info("Toggling to login method to: " + type);
panel.setVisible(false);
- switch(type) {
- case LOGIN_TYPE_BWIDM:
- initIdpList();
- panel.remove(lblSatIP);
- panel.remove(lblSatellitenIp);
- panel.add(idpChoice);
- panel.add(lblIdp);
- panel.add(LabelPass);
- lblpass.setText("");
- lblpass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
- panel.add(lblpass);
- lblusername.setToolTipText("Bitte geben Sie Ihr bwIDM-Benutzername ein.");
- panel.revalidate();
- panel.repaint();
- panel.setVisible(true);
- break;
- case LOGIN_TYPE_BWLEHRPOOL:
- panel.remove(idpChoice);
- panel.remove(lblIdp);
- panel.remove(lblSatIP);
- panel.remove(lblSatellitenIp);
- panel.add(LabelPass);
- lblpass.setToolTipText("Bitte geben Sie Ihr bwLehrpool-Passwort ein.");
- panel.add(lblpass);
- lblusername.setToolTipText("Bitte geben Sie Ihr bwLehrpool-Benutzername ein.");
- panel.revalidate();
- panel.repaint();
- panel.setVisible(true);
- break;
- case LOGIN_TYPE_SATELLITE:
- panel.remove(idpChoice);
- panel.remove(lblIdp);
- panel.remove(LabelPass);
- panel.remove(lblpass);
- lblSatIP.setBounds(135, 85, 237, 20);
- lblSatIP.setText("");
- panel.add(lblSatIP);
- lblSatellitenIp.setBounds(25, 85, 82, 20);
- panel.add(lblSatellitenIp);
- panel.revalidate();
- panel.repaint();
- panel.setVisible(true);
- setStatus(Color.black, "Info: Bereit für bwIDM-Login", null);
- break;
- default:
- panel.setVisible(true);
- return;
+ switch (type) {
+ case LOGIN_TYPE_BWIDM:
+ initIdpList();
+ panel.remove(lblSatIP);
+ panel.remove(lblSatellitenIp);
+ panel.add(idpChoice);
+ panel.add(lblIdp);
+ panel.add(LabelPass);
+ lblpass.setText("");
+ lblpass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
+ panel.add(lblpass);
+ lblusername.setToolTipText("Bitte geben Sie Ihr bwIDM-Benutzername ein.");
+ panel.revalidate();
+ panel.repaint();
+ panel.setVisible(true);
+ break;
+ case LOGIN_TYPE_BWLEHRPOOL:
+ panel.remove(idpChoice);
+ panel.remove(lblIdp);
+ panel.remove(lblSatIP);
+ panel.remove(lblSatellitenIp);
+ panel.add(LabelPass);
+ lblpass.setToolTipText("Bitte geben Sie Ihr bwLehrpool-Passwort ein.");
+ panel.add(lblpass);
+ lblusername.setToolTipText("Bitte geben Sie Ihr bwLehrpool-Benutzername ein.");
+ panel.revalidate();
+ panel.repaint();
+ panel.setVisible(true);
+ break;
+ case LOGIN_TYPE_SATELLITE:
+ panel.remove(idpChoice);
+ panel.remove(lblIdp);
+ panel.remove(LabelPass);
+ panel.remove(lblpass);
+ lblSatIP.setBounds(135, 85, 237, 20);
+ lblSatIP.setText("");
+ panel.add(lblSatIP);
+ lblSatellitenIp.setBounds(25, 85, 82, 20);
+ panel.add(lblSatellitenIp);
+ panel.revalidate();
+ panel.repaint();
+ panel.setVisible(true);
+ setStatus(Color.black, "Info: Bereit für bwIDM-Login", null);
+ break;
+ default:
+ panel.setVisible(true);
+ return;
}
}
/**
- * Request the list of identity providers from the masterserver and
- * display them in a combobox.
+ * Request the list of identity providers from the masterserver and display
+ * them in a combobox.
*/
private void initIdpList() {
// abort if we fetched the list already.
@@ -598,7 +603,7 @@ public class Login_GUI extends JInternalFrame {
organizations = new ArrayList<OrganizationData>();
}
LOGGER.info("Fetching list of identity providers from masterserver...");
- SwingWorker<Boolean, String> worker = new SwingWorker<Boolean, String>(){
+ SwingWorker<Boolean, String> worker = new SwingWorker<Boolean, String>() {
@Override
protected Boolean doInBackground() throws Exception {
publish("Info: Hole Liste von IdPs");
@@ -624,9 +629,9 @@ public class Login_GUI extends JInternalFrame {
// now we build the list, lets sort it
Collections.sort(organizations, new Comparator<OrganizationData>() {
@Override
- public int compare(OrganizationData o1, OrganizationData o2) {
- return o1.displayName.compareTo(o2.displayName);
- }
+ public int compare(OrganizationData o1, OrganizationData o2) {
+ return o1.displayName.compareTo(o2.displayName);
+ }
});
} else {
LOGGER.error("Thrift call of 'getOrganizations()' seems to have worked, but 'organizations' is still null.");
@@ -636,23 +641,26 @@ public class Login_GUI extends JInternalFrame {
publish("Info: Liste von IdPs empfangen.");
return true;
}
+
protected void done() {
try {
if (get()) {
- // fill the combobox with the IdPs returned from the masterserver
- OrganizationData[] orgs = organizations.toArray(new OrganizationData[]{});
+ // fill the combobox with the IdPs returned from the
+ // masterserver
+ OrganizationData[] orgs = organizations.toArray(new OrganizationData[] {});
idpChoice.setModel(new DefaultComboBoxModel<OrganizationData>(orgs));
- // now override the renderer, to show the display names of the organizations.
+ // now override the renderer, to show the display names
+ // of the organizations.
idpChoice.setRenderer(new DefaultListCellRenderer() {
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- if (value instanceof OrganizationData){
- OrganizationData org = (OrganizationData) value;
- setText(org.getDisplayName());
- }
- return this;
- }
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ if (value instanceof OrganizationData) {
+ OrganizationData org = (OrganizationData) value;
+ setText(org.getDisplayName());
+ }
+ return this;
+ }
});
setStatus(Color.black, "Info: Bereit für Login", null);
} else {
@@ -664,9 +672,10 @@ public class Login_GUI extends JInternalFrame {
LOGGER.error("Execution of SwingWorker for 'getOrganizationsList' failed, see trace: ", e);
}
}
+
@Override
protected void process(List<String> msgs) {
- String currentMessage = msgs.get(msgs.size()-1);
+ String currentMessage = msgs.get(msgs.size() - 1);
setStatus(Color.black, currentMessage, null);
}
};