summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2015-07-08 16:58:02 +0200
committerJonathan Bauer2015-07-08 16:58:02 +0200
commit73989b5cd12313d5192601ab453552ee3d26da10 (patch)
tree505b4c2bad9855aeecbeef4ed8780a6d431bc574
parent[client] user feedback when login fails. (diff)
downloadtutor-module-73989b5cd12313d5192601ab453552ee3d26da10.tar.gz
tutor-module-73989b5cd12313d5192601ab453552ee3d26da10.tar.xz
tutor-module-73989b5cd12313d5192601ab453552ee3d26da10.zip
[client] implemented login -> disclaimer -> vmwarelicense logic
-rw-r--r--dozentenmodul/src/main/java/config/Config.java117
-rw-r--r--dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java52
-rw-r--r--dozentenmodul/src/main/java/gui/core/DisclaimerGUI.java44
-rw-r--r--dozentenmodul/src/main/java/gui/core/LoginComposite.java50
-rw-r--r--dozentenmodul/src/main/java/gui/core/LoginGUI.java168
-rw-r--r--dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java84
-rw-r--r--dozentenmodul/src/main/java/gui/core/VMWareInfoGUI.java56
7 files changed, 338 insertions, 233 deletions
diff --git a/dozentenmodul/src/main/java/config/Config.java b/dozentenmodul/src/main/java/config/Config.java
index 97ede10d..cda8dab2 100644
--- a/dozentenmodul/src/main/java/config/Config.java
+++ b/dozentenmodul/src/main/java/config/Config.java
@@ -56,7 +56,7 @@ public class Config {
configPath = appDataPath + "\\bwSuite\\config.ini";
} else {
// APPDATA was empty, let's build it ourselves...
- LOGGER.warn("APPDATA ist leer.");
+ LOGGER.warn("APPDATA is empty.");
configPath = System.getProperty("user.home") + "\\AppData\\Roaming\\bwSuite\\config.ini";
}
@@ -71,15 +71,15 @@ public class Config {
if (!(configPath.isEmpty()||configPath == null)) {
configFile = new File(configPath);
} else {
- throw new IOException("Konnte keinen Pfad für die Konfigurationsdatei ermitteln.");
+ throw new IOException("Could not determine the path to the config file.");
}
// Check if the directory exists.
if (!configFile.getParentFile().exists()) {
- LOGGER.info("Ordner " + configFile.getParentFile() + " exisitiert nicht - lege ihn jetzt an.");
+ LOGGER.info("Folder " + configFile.getParentFile() + " does not exist, creating it.");
// Does not, create it
if (!configFile.getParentFile().mkdirs()) {
- throw new IOException("Konnte '" + configFile.getParentFile() + "' nicht erstellen.");
+ throw new IOException("Could not create '" + configFile.getParentFile() + "'.");
}
}
@@ -91,153 +91,136 @@ public class Config {
// Check if file is writeable
if(configFile.canWrite()) {
ini = new Wini(configFile);
- LOGGER.info("Erzeuge '" + configFile + "'...");
+ LOGGER.info("Creating '" + configFile + "'...");
// write default configuration options and values
- ini.put("main", "BillOfRights", false);
- ini.put("main", "vmware", false);
- ini.put("main", "Benutzername speichern", false);
- ini.put("main", "Benutzername", "");
- ini.put("main", "Letzter Downloadpfad", "");
- ini.put("main", "Letzter Uploadpfad", "");
- ini.put("main", "IdP", "");
+ ini.put("main", "disclaimer_agreement", false);
+ ini.put("main", "vmware_license_agreement", false);
+ ini.put("main", "auth_method", "");
+ ini.put("main", "username", "");
+ ini.put("main", "download_path", "");
+ ini.put("main", "upload_path", "");
+ ini.put("main", "identity_provider", "");
ini.store();
} else {
- throw new IOException("Konnte nicht in '" + configFile + "' schreiben. Haben Sie Rechte dazu?");
+ throw new IOException("Can not write to '" + configFile + "'. Do you have permissions?");
}
} else {
- LOGGER.info("'" + configFile + "' existiert bereits - keine weitere Aktion.");
ini = new Wini(configFile);
+ LOGGER.info("Loaded '" + configFile + "'.");
}
} // end constructor.
/**
+ * Query the path of the configuration file
+ * @return path to the configuration file
+ */
+ public static String getPath() {
+ if (ini.getFile().getParentFile().isDirectory())
+ return ini.getFile().getParentFile().toString();
+ else
+ return null;
+ }
+ /**
* Query the value of 'BillOfRights' from the configuration file.
* @return true if the user already accepted bill of rights, false otherwise.
*/
- public static boolean getBillOfRights() {
- return getBoolean("main", "BillOfRights", false);
+ public static boolean getDisclaimerAgreement() {
+ return getBoolean("main", "disclaimer_agreement", false);
}
/**
* Query the value of 'vmware' from the configuration file.
* @return true if the user already accepted vmware license, false otherwise.
*/
- public static boolean getVmwareLicense() {
- return getBoolean("main", "vmware", false);
- }
- /**
- * Query the value of 'Benutzername speichern' from the configuration file.
- * @return true if the username should be saved, false otherwise.
- */
- public static boolean getSaveUsername() {
- return getBoolean("main", "Benutzername speichern", false);
+ public static boolean getVmwareLicenseAgreement() {
+ return getBoolean("main", "vmware_license_agreement", false);
}
/**
* Query the value of 'Benutzername' from the configuration file.
* @return username if saved, an empty string otherwise.
*/
public static String getUsername() {
- return getString("main", "Benutzername", "");
+ return getString("main", "username", "");
}
/**
* Query the value of 'Letzter Downloadpfad' from the configuration file.
* @return last download path if saved, the path to the user's home otherwise.
*/
- public static String getLastDownloadPath() {
- return getString("main", "Letzter Downloadpfad", System.getProperty("user.home"));
+ public static String getDownloadPath() {
+ return getString("main", "download_path", System.getProperty("user.home"));
}
/**
* Query the value of 'Letzter Uploadpfad' from the configuration file.
* @return last upload path if saved, the path to the user's home otherwise.
*/
- public static String getLastUploadPath() {
- return getString("main", "Letzter Uploadpfad", System.getProperty("user.home"));
- }
-
- /**
- * Query the path of the configuration file
- * @return path to the configuration file
- */
- public static String getPath() {
- if (ini.getFile().getParentFile().isDirectory())
- return ini.getFile().getParentFile().toString();
- else
- return null;
+ public static String getUploadPath() {
+ return getString("main", "upload_path", System.getProperty("user.home"));
}
/**
* Query the IdP of the configuration file
* @return stored IdP
*/
- public static int getIdP() {
- return Integer.parseInt(getString("main", "IdP", ""));
+ public static String getIdentityProvider() {
+ return getString("main", "identity_provider", "");
}
/**
* Query the authentication method of the configuration file
* @return stored IdP
*/
public static String getAuthenticationMethod() {
- return getString("main", "authMethod", "");
+ return getString("main", "auth_method", "bwlp");
}
-
-
-
+
/**
* Sets the value of 'BillOfRights' in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
- public static boolean setBillOfRights(boolean value) {
- return setBoolean("main", "BillOfRights", value);
+ public static boolean setDisclaimerAgreement(boolean value) {
+ return setBoolean("main", "disclaimer_agreement", value);
}
/**
* Sets the value of 'vmware' in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
- public static boolean setVmwareLicense(boolean value) {
- return setBoolean("main", "vmware", value);
- }
- /**
- * Sets the value of 'Benutzername speichern' in the configuration file to 'value'
- * @return true if it succeeded, false otherwise
- */
- public static boolean setSaveUsername(boolean value) {
- return setBoolean("main", "Benutzername speichern", value);
+ public static boolean setVmwareLicenseAgreement(boolean value) {
+ return setBoolean("main", "vmware_license_agreement", value);
}
/**
* Sets the value of 'Benutzername' in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
public static boolean setUsername(String value) {
- return setString("main", "Benutzername", value);
+ return setString("main", "username", value);
}
/**
* Sets the value of 'Letzter Downloadpfad' in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
- public static boolean setLastDownloadPath(String value) {
- return setString("main", "Letzter Downloadpfad", value);
+ public static boolean setDownloadPath(String value) {
+ return setString("main", "download_path", value);
}
/**
* Sets the value of "Letzter Uploadpfad" in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
- public static boolean setLastUploadPath(String value) {
- return setString("main", "Letzter Uploadpfad", value);
+ public static boolean setUploadPath(String value) {
+ return setString("main", "upload_path", value);
}
/**
* Sets the value of "IdP" in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
- public static boolean setIdP(String value) {
- return setString("main", "IdP", value);
+ public static boolean setIdentityProvider(String value) {
+ return setString("main", "identity_provider", value);
}
/**
* Sets the value of the selected authentication method in the configuration file to 'value'
* @return true if it succeeded, false otherwise
*/
public static boolean setAuthenticationMethod(String value) {
- return setString("main","authMethod", value);
+ return setString("main","auth_method", value);
}
-
+
/**
* Save the changes to the ini file to actual file on the disk.
*
diff --git a/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java b/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java
index 370b06d8..15f21754 100644
--- a/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java
+++ b/dozentenmodul/src/main/java/gui/core/DisclaimerComposite.java
@@ -2,6 +2,7 @@ package gui.core;
import gui.GuiManager;
+import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -16,8 +17,11 @@ import org.eclipse.swt.widgets.Text;
public class DisclaimerComposite extends Composite {
- String notice = "Bitte lesen und bestätigen Sie folgende rechtliche Hinweise";
- String _disclaimer = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. \n\n"
+
+ private final static Logger LOGGER = Logger.getLogger(DisclaimerComposite.class);
+
+ private final String notice = "Bitte lesen und bestätigen Sie folgende rechtliche Hinweise";
+ private final String disclaimer = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. \n\n"
+ "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. \n\n"
+ "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\n"
+ "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.\n\n"
@@ -29,10 +33,10 @@ public class DisclaimerComposite extends Composite {
+ "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\n"
+ "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo";
- String _checkboxText = "Ja, ich aktzeptiere die Vereinbarung. Benachrichtigung nicht mehr anzeigen.";
+ private final String checkboxText = "Ja, ich aktzeptiere die Vereinbarung. Benachrichtigung nicht mehr anzeigen.";
- String title = "bwLehrpool Suite";
- String noticeLabel = "Hinweis";
+ private final String title = "bwLehrpool Suite";
+ private final String noticeLabel = "Hinweis";
// Buttons
protected Button agreeBox;
@@ -65,7 +69,7 @@ public class DisclaimerComposite extends Composite {
gridData.widthHint = 900;
gridData.heightHint = 600;
disclaimerText.setLayoutData(gridData);
- disclaimerText.setText(_disclaimer);
+ disclaimerText.setText(disclaimer);
// checkbox for acknowledging the disclaimer
@@ -76,7 +80,7 @@ public class DisclaimerComposite extends Composite {
checkboxComposite.setLayoutData(gridData);
agreeBox = new Button(checkboxComposite, SWT.CHECK);
- agreeBox.setText(_checkboxText);
+ agreeBox.setText(checkboxText);
continueButton = new Button(this, SWT.PUSH);
@@ -86,39 +90,5 @@ public class DisclaimerComposite extends Composite {
gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
gridData.horizontalAlignment = SWT.RIGHT;
continueButton.setLayoutData(gridData);
-
-
- // function for agreement checkbox
- agreeBox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- continueButton.setEnabled(!continueButton.isEnabled());
- }
- });
-
- // function for continue button
- continueButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedContinueButton();
- }
- });
-
- }
-
- //
- // logical functions for GUI
- //
-
-
- /**
- * function for the continueButton
- */
- protected void clickedContinueButton() {
- GuiManager.addContent(new VMWareInfoComposite(getShell()));
}
-
-
-
-
}
diff --git a/dozentenmodul/src/main/java/gui/core/DisclaimerGUI.java b/dozentenmodul/src/main/java/gui/core/DisclaimerGUI.java
new file mode 100644
index 00000000..5a53150e
--- /dev/null
+++ b/dozentenmodul/src/main/java/gui/core/DisclaimerGUI.java
@@ -0,0 +1,44 @@
+package gui.core;
+
+import gui.GuiManager;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Shell;
+
+import config.Config;
+
+public class DisclaimerGUI extends DisclaimerComposite{
+
+ private final static Logger LOGGER = Logger.getLogger(DisclaimerGUI.class);
+
+ public DisclaimerGUI(final Shell mainShell) {
+ super(mainShell);
+
+ // function for agreement checkbox
+ agreeBox.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ continueButton.setEnabled(!continueButton.isEnabled());
+ }
+ });
+
+ // function for continue button
+ continueButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // save the agreement to config
+ if (!Config.setDisclaimerAgreement(true))
+ LOGGER.error("Could not set the agreement to the disclaimer in '" + Config.getPath() + "'!");
+ Config.store();
+ // now check the config to see if the user has agreed to vmware stuff
+ if (!Config.getVmwareLicenseAgreement())
+ GuiManager.addContent(new VMWareInfoGUI(getShell()));
+ else
+ GuiManager.addContent(new MainWindowComposite(getShell()));
+ }
+ });
+ }
+
+}
diff --git a/dozentenmodul/src/main/java/gui/core/LoginComposite.java b/dozentenmodul/src/main/java/gui/core/LoginComposite.java
index 7c4f92f4..ad95b9f8 100644
--- a/dozentenmodul/src/main/java/gui/core/LoginComposite.java
+++ b/dozentenmodul/src/main/java/gui/core/LoginComposite.java
@@ -17,15 +17,38 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
+import config.Config;
+
public class LoginComposite extends Composite {
private final static Logger LOGGER = Logger.getLogger(LoginComposite.class);
- protected enum LOGIN_TYPE {
- BWIDM, BWLP, SAT
+ // TODO add ids to use for the authButtons group!
+ protected static enum LOGIN_TYPE {
+ BWIDM(0, "bwidm"),
+ BWLP(1, "bwlp"),
+ SAT(2, "sat");
+
+ private final int id;
+ private final String tag;
+ private LOGIN_TYPE(final int id, final String tag) {
+ this.id = id;
+ this.tag = tag;
+ }
+ public int getId() { return this.id; }
+ public String getTag() { return this.tag; }
+
+ public static LOGIN_TYPE getEnum(String tag) {
+ switch(tag) {
+ case "bwidm": return LOGIN_TYPE.BWIDM;
+ case "bwlp": return LOGIN_TYPE.BWLP;
+ case "sat": return LOGIN_TYPE.SAT;
+ default: return null;
+ }
+ }
}
-
- protected LOGIN_TYPE loginType = LOGIN_TYPE.BWIDM;
+ // authentication method to use for login attempts
+ protected LOGIN_TYPE loginType = null;
private Image titleImage;
@@ -86,21 +109,20 @@ public class LoginComposite extends Composite {
// add the authentication method selection buttons
authButtons = new Button[3];
- authButtons[0] = new Button(authGroup, SWT.RADIO);
- authButtons[0].setSelection(true);
- authButtons[0].setText("Authentifizierung über bwIDM");
+ authButtons[LOGIN_TYPE.BWIDM.id] = new Button(authGroup, SWT.RADIO);
+ authButtons[LOGIN_TYPE.BWIDM.id].setText("Authentifizierung über bwIDM");
gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
- authButtons[0].setLayoutData(gridData);
+ authButtons[LOGIN_TYPE.BWIDM.id].setLayoutData(gridData);
- authButtons[1] = new Button(authGroup, SWT.RADIO);
- authButtons[1].setText("Test-Zugang mit festem Benutzernamen");
+ authButtons[LOGIN_TYPE.BWLP.id] = new Button(authGroup, SWT.RADIO);
+ authButtons[LOGIN_TYPE.BWLP.id].setText("Test-Zugang mit festem Benutzernamen");
gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
- authButtons[1].setLayoutData(gridData);
+ authButtons[LOGIN_TYPE.BWLP.id].setLayoutData(gridData);
- authButtons[2] = new Button(authGroup, SWT.RADIO);
- authButtons[2].setText("Direkte Verbindung zum Satelliten");
+ authButtons[LOGIN_TYPE.SAT.id] = new Button(authGroup, SWT.RADIO);
+ authButtons[LOGIN_TYPE.SAT.id].setText("Direkte Verbindung zum Satelliten");
gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
- authButtons[2].setLayoutData(gridData);
+ authButtons[LOGIN_TYPE.SAT.id].setLayoutData(gridData);
// group for the login mask
final Group loginGroup = new Group(this, SWT.NONE);
diff --git a/dozentenmodul/src/main/java/gui/core/LoginGUI.java b/dozentenmodul/src/main/java/gui/core/LoginGUI.java
index e85f83cc..321942d5 100644
--- a/dozentenmodul/src/main/java/gui/core/LoginGUI.java
+++ b/dozentenmodul/src/main/java/gui/core/LoginGUI.java
@@ -14,7 +14,6 @@ import org.eclipse.swt.widgets.Shell;
import org.openslx.bwlp.dozmod.thrift.OrganizationCache;
import org.openslx.bwlp.thrift.iface.Organization;
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;
@@ -22,21 +21,32 @@ import util.ShibbolethECP.ReturnCode;
import auth.BWIDMAuthenticator;
import auth.BWLPAuthenticator;
import auth.BaseAuthenticator.AuthenticatorCallback;
+import config.Config;
import edu.kit.scc.dei.ecplean.ECPAuthenticationException;
import gui.GuiManager;
+/**
+ * @author Jonathan Bauer
+ *
+ */
public class LoginGUI extends LoginComposite {
private final static Logger LOGGER = Logger.getLogger(LoginGUI.class);
+ // text constants
private final String NO_USERNAME = "Kein Benutzername angegeben!";
private final String NO_PASSWORD = "Kein Passwort angegeben!";
- private final String BAD_AUTH = "Authentifizierung fehlgeschlagen!";
+ // user input variables
private String username = null;
private String password = null;
+
/**
+ * Constructor doing the setup of the logical GUI functions
+ * Fetches the organization list for BWIDM logins and
+ * adds mouse/keyboard event listeners to various widgets.
+ *
* @param mainShell
*/
public LoginGUI(final Shell mainShell) {
@@ -56,18 +66,61 @@ public class LoginGUI extends LoginComposite {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
+
+ // now check if we had a saved identity provider
+ String savedOrganizationId = Config.getIdentityProvider();
+ // add only organizations which have an ECP URL to the combobox
for (Organization o : orgs) {
if (o.getEcpUrl() == null | o.getEcpUrl().isEmpty()) continue;
+ LOGGER.debug("Adding: " + o.toString());
idpCombo.add(o.displayName);
idpCombo.setData(o.displayName, o);
+ if (savedOrganizationId != null &&
+ !savedOrganizationId.isEmpty() &&
+ savedOrganizationId.equals(o.getOrganizationId()))
+ // select the organization we just added, this seems kinda bad - is there a better way?
+ idpCombo.select(idpCombo.getItemCount() - 1);
+ //idpCombo.select(idpCombo.indexOf(savedOrganizationId)); this is probably not optimal... but safer
+ }
+ // if no organization was saved, none is selected, so select the first one in the combobox
+ if (idpCombo.getSelectionIndex() == -1)
+ idpCombo.select(0);
+ // check if we had saved an authentication method
+ String savedAuthMethod = Config.getAuthenticationMethod();
+ if (savedAuthMethod != null && !savedAuthMethod.isEmpty()) {
+ LOGIN_TYPE savedLoginType = LOGIN_TYPE.getEnum(savedAuthMethod);
+ // if no valid LOGIN_TYPE was saved, just enable the BWIDM button
+ if (savedLoginType == null) {
+ authButtons[LOGIN_TYPE.BWIDM.getId()].setSelection(true);
+ loginType = LOGIN_TYPE.BWIDM;
+ } else {
+ authButtons[savedLoginType.getId()].setSelection(true);
+ loginType = savedLoginType;
+ idpText.setVisible(savedLoginType == LOGIN_TYPE.BWIDM);
+ idpCombo.setVisible(savedLoginType == LOGIN_TYPE.BWIDM);
+ }
+ } else {
+ // default value for LOGIN_TYPE is BWIDM
+ authButtons[LOGIN_TYPE.BWIDM.getId()].setSelection(true);
+ loginType = LOGIN_TYPE.BWIDM;
}
- idpCombo.select(0);
+
+
+ // finally check if we had a saved username
+ String savedUsername = Config.getUsername();
+ if (savedUsername != null && !savedUsername.isEmpty()) {
+ usernameText.setText(savedUsername);
+ saveUsernameCheck.setSelection(true);
+ passwordText.setFocus();
+ } else
+ usernameText.setFocus();
// actions of the login button
loginButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- doLogin(loginType);
+ doSaveConfig();
+ doLogin();
}
});
@@ -109,27 +162,63 @@ public class LoginGUI extends LoginComposite {
loginType = LOGIN_TYPE.SAT;
}
});
+
+ // add a key listener to the password field to trigger login
+ // when the user presses the ENTER key.
passwordText.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
- // TODO Auto-generated method stub
if (e.keyCode == SWT.CR) {
- doLogin(loginType);
+ doSaveConfig();
+ doLogin();
}
}
-
@Override
public void keyPressed(KeyEvent e) {}
});
}
/**
+ * Saves various user choices to the config file.
+ * This gets triggered when the login button is activated.
+ */
+ private void doSaveConfig() {
+ // first we need to check if the "Remember me" button is active
+ if (saveUsernameCheck.isEnabled()) {
+ // save username
+ String username = usernameText.getText();
+ if (username != null && !username.isEmpty()) {
+ // all good, save it
+ if (!Config.setUsername(username))
+ LOGGER.error("Could not save username '" + username + "' to '" + Config.getPath() + "'.");
+ }
+ }
+ // always save the authentication method and potentially the identity provider
+ if (!Config.setAuthenticationMethod(loginType.getTag()))
+ LOGGER.error("Could not save authentication method '" + loginType.getTag() + "' to '" + Config.getPath() + "'.");
+ // check if we are doing bwIDM authentication
+ if (loginType == LOGIN_TYPE.BWIDM) {
+ // save the selected identity provider
+ Organization selectedOrg = getSelectedOrganization();
+ if (!Config.setIdentityProvider(selectedOrg.organizationId))
+ LOGGER.error("Could not save the identity provider '" + selectedOrg.organizationId + "'!");
+ }
+ // finalize by actually storing the config file
+ if (!Config.store())
+ LOGGER.error("Could not save '" + Config.getPath() + "'!");
+ }
+ /**
* Actually do the login using the username/password in the field using the
* authentication mechanism corresponding to the selected authButton
* @throws ECPAuthenticationException
*/
- private void doLogin(LOGIN_TYPE loginType) {
+ private void doLogin() {
+ // sanity check on loginType.
+ if (loginType == null) {
+ LOGGER.error("No login type set, a default should be set! Ignoring...");
+ return;
+ }
// here we only check for the fields
username = usernameText.getText();
password = passwordText.getText();
@@ -146,15 +235,9 @@ public class LoginGUI extends LoginComposite {
GuiManager.showMessage(NO_PASSWORD);
return;
}
- // get the index of the selected item in the combobox
- int selectionIndex = idpCombo.getSelectionIndex();
- if (selectionIndex == -1) {
- LOGGER
- .error("No IdP is selected in the combobox. There should be a default value!");
- return;
- }
- Organization selectedOrg =
- (Organization) idpCombo.getData(idpCombo.getItem(selectionIndex));
+
+ // determine which organization was selected by the user.
+ Organization selectedOrg = getSelectedOrganization();
// now switch over the login types.
switch (loginType) {
@@ -165,21 +248,19 @@ public class LoginGUI extends LoginComposite {
bwidmAuth.login(username, password, new AuthenticatorCallback() {
@Override
public void postLogin(ReturnCode returnCode, UserInfo user) {
+ // TODO finish this
// handle errors first
if (returnCode != ReturnCode.NO_ERROR && user == null) {
switch(returnCode) {
case IDP_ERROR:
- GuiManager.showMessage("");
+ GuiManager.showMessage("IdP Error");
break;
default:
GuiManager.showMessage("Internal error!");
break;
}
- } else {
- // TODO: FOR DEBUGGING/DEV PURPOSES!
- ThriftManager.setSatelliteAddress( "132.230.8.113" );
- GuiManager.addContent(new DisclaimerComposite(getShell()));
- }
+ } else
+ postSuccessfulLogin();
}
});
} catch (TAuthenticationException e) {
@@ -200,12 +281,8 @@ public class LoginGUI extends LoginComposite {
LOGGER.error("BWLP login failed.");
GuiManager.showMessage("Login failed!");
}
- if (returnCode == ReturnCode.NO_ERROR && user != null) {
- LOGGER.error("BWLP login failed.");
- // TODO: FOR DEBUGGING/DEV PURPOSES!
- ThriftManager.setSatelliteAddress( "132.230.8.113" );
- GuiManager.addContent(new DisclaimerComposite(getShell()));
- }
+ if (returnCode == ReturnCode.NO_ERROR && user != null)
+ postSuccessfulLogin();
}
});
} catch (TAuthenticationException e) {
@@ -216,10 +293,39 @@ public class LoginGUI extends LoginComposite {
LOGGER.info("sat");
break;
default:
- LOGGER.error("derp");
+ LOGGER.error("Unknown login type! Ignoring...");
break;
}
return;
-
+ }
+
+ /**
+ * Functions called by doLogin is the login process succeeded.
+ */
+ private void postSuccessfulLogin() {
+ LOGGER.info(loginType.getTag() + " succeeded.");
+
+ ThriftManager.setSatelliteAddress( "132.230.8.113" );
+
+ // now read the config to see if the user already agreed to the disclaimer
+ if (!Config.getDisclaimerAgreement())
+ GuiManager.addContent(new DisclaimerGUI(getShell()));
+ else if (!Config.getVmwareLicenseAgreement())
+ GuiManager.addContent(new VMWareInfoGUI(getShell()));
+ else
+ GuiManager.addContent(new MainWindowComposite(getShell()));
+ }
+
+ /**
+ * @return the organization currently selected in the combobox for identity providers
+ */
+ private final Organization getSelectedOrganization() {
+ // get the index of the selected item in the combobox
+ int selectionIndex = idpCombo.getSelectionIndex();
+ if (selectionIndex == -1) {
+ LOGGER.error("No identity provider is selected in the combobox. There should be a default value!");
+ return null;
+ }
+ return (Organization) idpCombo.getData(idpCombo.getItem(selectionIndex));
}
}
diff --git a/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java b/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java
index 7ccd68c5..d385c60b 100644
--- a/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java
+++ b/dozentenmodul/src/main/java/gui/core/VMWareInfoComposite.java
@@ -3,8 +3,6 @@ package gui.core;
import gui.GuiManager;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
@@ -16,14 +14,14 @@ import org.eclipse.swt.widgets.Shell;
public class VMWareInfoComposite extends Composite {
- String title = "Hinweis VMWare Player";
- String infoText = "Für die Arbeit mit der bwLehrpool Suite wird zwingend ein VMWare Player benötigt. "
+ private final String title = "Hinweis VMWare Player";
+ private final String infoText = "Für die Arbeit mit der bwLehrpool Suite wird zwingend ein VMWare Player benötigt. "
+ "Diesen können Sie sich unter folgendem Link kostenfrei downloaden. "
+ "Wenn Sie bereits den VMWare Player oder die VMWare Workstation installiert haben, können Sie diesen Hinweis ignorieren.";
- String checkboxText = "Ja, ich aktzeptiere die Vereinbarung. Benachrichtigung nicht mehr anzeigen.";
+ private final String checkboxText = "Ja, ich aktzeptiere die Vereinbarung. Benachrichtigung nicht mehr anzeigen.";
- String infoTitle = "bwLehrpool Suite";
+ private final String infoTitle = "bwLehrpool Suite";
protected Button windowsDLButton;
protected Button linuxDLButton;
@@ -88,79 +86,5 @@ public class VMWareInfoComposite extends Composite {
gridData = new GridData(GridData.BEGINNING, GridData.END, false, false);
continueButton.setLayoutData(gridData);
- // TODO still looks very ugly
-
- // function for agreement checkbox
- continueButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedContinueButton();
- }
- });
-
- // actions of the login button
- linuxDLButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedLinuxDLButton();
-
- }
- });
-
- // actions of the login button
- windowsDLButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedWindowsDLButton();
-
- }
- });
-
- // actions of the login button
- readCheck.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedReadCheckButton();
-
- }
- });
}
-
-
- //
- // logical functions for GUI
- //
-
-
- /**
- * function for the readCheckbox
- */
- protected void clickedReadCheckButton() {
- // TODO Auto-generated method stub
- }
-
-
- /**
- * function for the windowsDLButton
- */
- protected void clickedWindowsDLButton() {
- // TODO Auto-generated method stub
- }
-
-
- /**
- * function for the linuxDLButton
- */
- protected void clickedLinuxDLButton() {
- // TODO Auto-generated method stub
- }
-
-
- /**
- * function for the continueButton
- */
- protected void clickedContinueButton() {
- GuiManager.addContent(new MainWindowComposite(this.getShell()));
- }
-
} \ No newline at end of file
diff --git a/dozentenmodul/src/main/java/gui/core/VMWareInfoGUI.java b/dozentenmodul/src/main/java/gui/core/VMWareInfoGUI.java
new file mode 100644
index 00000000..74f6ad63
--- /dev/null
+++ b/dozentenmodul/src/main/java/gui/core/VMWareInfoGUI.java
@@ -0,0 +1,56 @@
+package gui.core;
+
+import gui.GuiManager;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Shell;
+
+import config.Config;
+
+public class VMWareInfoGUI extends VMWareInfoComposite {
+
+ private final static Logger LOGGER = Logger.getLogger(VMWareInfoGUI.class);
+
+ public VMWareInfoGUI(final Shell mainShell) {
+ super(mainShell);
+
+ // function for agreement checkbox
+ continueButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (!Config.setVmwareLicenseAgreement(true))
+ LOGGER.error("Could not set the agreement to the vmware license in '" + Config.getPath() + "'!");
+ Config.store();
+ GuiManager.addContent(new MainWindowComposite(getShell()));
+ }
+ });
+
+ // actions of the login button
+ linuxDLButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ //clickedLinuxDLButton();
+ }
+ });
+
+ // actions of the login button
+ windowsDLButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ //clickedWindowsDLButton();
+ }
+ });
+
+ // actions of the login button
+ readCheck.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ //clickedReadCheckButton();
+ }
+ });
+
+ }
+
+}