diff options
author | Jonathan Bauer | 2015-09-15 13:54:48 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-09-15 13:54:48 +0200 |
commit | 3d6f54486306017221075a4aed225323ba9af694 (patch) | |
tree | 643a7f3072529d19eb3f60bb5642805f3d15e5a1 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java | |
parent | [client] Added selection of satellite when more than one available. Shift key... (diff) | |
download | tutor-module-3d6f54486306017221075a4aed225323ba9af694.tar.gz tutor-module-3d6f54486306017221075a4aed225323ba9af694.tar.xz tutor-module-3d6f54486306017221075a4aed225323ba9af694.zip |
[client] Login: check if the user enters its org as part of the username
if he did and its the same as the selected IDP, then just use the username (everything before '@') and that IDP to login
if he did and the entered org exists and is different than the IDP, ask which we should use
if he did and the entered org does not exists, do nothing, meaning the login will eventually fail
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java index 7aefa1ec..0dfae7cf 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java @@ -20,6 +20,7 @@ import javax.swing.SwingUtilities; import org.apache.log4j.Logger; import org.apache.thrift.TBaseHelper; import org.apache.thrift.TException; +import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.Organization; import org.openslx.bwlp.thrift.iface.Satellite; import org.openslx.dozmod.App; @@ -40,6 +41,7 @@ import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.Sorters; import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.ThriftError; +import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.thrift.cache.OrganizationCache; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; @@ -246,8 +248,6 @@ public class LoginWindow extends LoginWindowLayout { idpCombo.requestFocus(); return; } - // we are doing the login soon, first save the config - doSaveConfig(); // here we only check for the fields String username = usernameField.getText(); String password = String.copyValueOf(passwordField.getPassword()); @@ -264,6 +264,36 @@ public class LoginWindow extends LoginWindowLayout { // determine which organization was selected by the user. Organization selectedOrg = idpCombo.getItemAt(idpCombo.getSelectedIndex()); + // now lets check if the username contains an organization + // for this we just check if the given username contains a '@' + // if it does, we just strip everything after and including '@' + if (loginType == LoginType.ECP && username.contains("@")) { + // split only on first occurence of '@' + String[] usernameSplit = username.split("@", 2); + if (!usernameSplit[1].isEmpty()) { + Organization orgInUsername = OrganizationCache.find(usernameSplit[1]); + if (orgInUsername != null) { + // username contains a known organization + if (!selectedOrg.equals(orgInUsername)) { + // but it does not match the one selected in the combobox + boolean ret = Gui.showMessageBox(this, + "Der angegebene Benutzername enthält eine Organization, die nicht mit Ihrer IDP-Auswahl übereinstimmt." + + "\nWollen Sie die in Ihrem Benutzername gefundene Organization verwenden?", + MessageType.QUESTION_YESNO, null, null); + if (ret) { + idpCombo.setSelectedItem(orgInUsername); + selectedOrg = orgInUsername; + } + } + } + // always set the username to everything before '@' + usernameField.setText(usernameSplit[0]); + username = usernameSplit[0]; + } + } + // we are doing the login soon, first save the config + doSaveConfig(); + // Setup login callback final LoginWindow me = this; AuthenticatorCallback authenticatorCallback = new AuthenticatorCallback() { |