summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java
diff options
context:
space:
mode:
authorJonathan Bauer2015-09-17 18:41:06 +0200
committerJonathan Bauer2015-09-17 18:41:06 +0200
commit1ab2153e4922a4dd303b9084eaae22693989896b (patch)
tree4b746b5367dfaab78a8141741561ebe5c5ad922f /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java
parentMerge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1 (diff)
downloadtutor-module-1ab2153e4922a4dd303b9084eaae22693989896b.tar.gz
tutor-module-1ab2153e4922a4dd303b9084eaae22693989896b.tar.xz
tutor-module-1ab2153e4922a4dd303b9084eaae22693989896b.zip
[client] async login
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.java54
1 files changed, 31 insertions, 23 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 323c0d58..8b16bd2b 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
@@ -11,7 +11,6 @@ import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -39,7 +38,6 @@ import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.window.layout.LoginWindowLayout;
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.OrganizationCache;
@@ -74,7 +72,7 @@ public class LoginWindow extends LoginWindowLayout {
// text constants
private final String NO_USERNAME = "Kein Benutzername angegeben!";
private final String NO_PASSWORD = "Kein Passwort angegeben!";
-
+
public static boolean forceCustomSatellite;
private final KeyEventDispatcher satelliteShiftDispatcher = new KeyEventDispatcher() {
@Override
@@ -84,7 +82,7 @@ public class LoginWindow extends LoginWindowLayout {
if (code == KeyEvent.VK_SHIFT) { // shift key is pressed
if (type == KeyEvent.KEY_PRESSED) {
forceCustomSatellite = true;
- } else if ( type == KeyEvent.KEY_RELEASED)
+ } else if (type == KeyEvent.KEY_RELEASED)
forceCustomSatellite = false;
event.consume();
}
@@ -170,7 +168,7 @@ public class LoginWindow extends LoginWindowLayout {
});
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(satelliteShiftDispatcher);
-
+
loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -215,7 +213,8 @@ public class LoginWindow extends LoginWindowLayout {
return;
}
- idpCombo.setModel(new DefaultComboBoxModel<Organization>(orgs.toArray(new Organization[orgs.size()])));
+ idpCombo.setModel(
+ new DefaultComboBoxModel<Organization>(orgs.toArray(new Organization[orgs.size()])));
// now check if we had a saved identity provider
String savedOrganizationId = Config.getIdentityProvider();
idpCombo.setSelectedItem(OrganizationCache.find(savedOrganizationId));
@@ -267,7 +266,7 @@ public class LoginWindow extends LoginWindowLayout {
}
// here we only check for the fields
String username = usernameField.getText();
- String password = String.copyValueOf(passwordField.getPassword());
+ final String password = String.copyValueOf(passwordField.getPassword());
// login clicked, lets first read the fields
if (username.isEmpty()) {
Gui.showMessageBox(this, NO_USERNAME, MessageType.ERROR, LOGGER, null);
@@ -295,7 +294,7 @@ public class LoginWindow extends LoginWindowLayout {
// but it does not match the one selected in the combobox
boolean ret = Gui.showMessageBox(this,
"Der angegebene Benutzername enthält eine Organisation, die nicht mit Ihrer IDP-Auswahl übereinstimmt."
- + "\nWollen Sie die in Ihrem Benutzername gefundene Organisation verwenden?",
+ + "\nWollen Sie die in Ihrem Benutzername gefundene Organisation verwenden?",
MessageType.QUESTION_YESNO, null, null);
if (ret) {
idpCombo.setSelectedItem(orgInUsername);
@@ -313,7 +312,7 @@ public class LoginWindow extends LoginWindowLayout {
// Setup login callback
final LoginWindow me = this;
- AuthenticatorCallback authenticatorCallback = new AuthenticatorCallback() {
+ final AuthenticatorCallback authenticatorCallback = new AuthenticatorCallback() {
@Override
public void postLogin(ReturnCode returnCode, AuthenticationData data, Throwable t) {
switch (returnCode) {
@@ -330,9 +329,10 @@ public class LoginWindow extends LoginWindowLayout {
LOGGER, t);
break;
case UNREGISTERED_ERROR:
- Gui.showMessageBox(me, "You are not registered to bwLehrpool. Please visit "
- + ShibbolethEcp.getRegistrationUrl() + " and register first.", MessageType.ERROR,
- LOGGER, t);
+ Gui.showMessageBox(me,
+ "You are not registered to bwLehrpool. Please visit "
+ + ShibbolethEcp.getRegistrationUrl() + " and register first.",
+ MessageType.ERROR, LOGGER, t);
break;
case INVALID_URL_ERROR:
Gui.showMessageBox(me, "ECP Authenticator says: Invalid URL.", MessageType.ERROR, LOGGER,
@@ -347,7 +347,7 @@ public class LoginWindow extends LoginWindowLayout {
};
// now switch over the login types.
- Authenticator authenticator;
+ final Authenticator authenticator;
switch (loginType) {
case ECP:
authenticator = new EcpAuthenticator(selectedOrg.getEcpUrl());
@@ -363,15 +363,22 @@ public class LoginWindow extends LoginWindowLayout {
return;
}
- // Excute login
+ // Execute login
App.waitForInit();
- try {
- authenticator.login(username, password, authenticatorCallback);
- } catch (TException e) {
- ThriftError.showMessage(this, LOGGER, e, "Anmeldung fehlgeschlagen");
- } catch (Exception e) {
- Gui.showMessageBox(this, "Anmeldung fehlgeschlagen", MessageType.ERROR, LOGGER, e);
- }
+ final String finalUsername = username;
+ QuickTimer.scheduleOnce(new Task() {
+ @Override
+ public void fire() {
+ try {
+ authenticator.login(finalUsername, password, authenticatorCallback);
+ } catch (TException e) {
+ ThriftError.showMessage(LoginWindow.this, LOGGER, e, "Anmeldung fehlgeschlagen");
+ } catch (Exception e) {
+ Gui.showMessageBox(LoginWindow.this, "Anmeldung fehlgeschlagen", MessageType.ERROR,
+ LOGGER, e);
+ }
+ }
+ });
}
/**
@@ -390,8 +397,9 @@ public class LoginWindow extends LoginWindowLayout {
Session.getMasterToken());
}
// Remove the listener for the shift key. (For forcing the satellite selection)
- KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(satelliteShiftDispatcher);
-
+ KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .removeKeyEventDispatcher(satelliteShiftDispatcher);
+
dispose();
return;
}