diff options
| author | Jonathan Bauer | 2015-07-06 17:20:22 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-07-06 17:20:22 +0200 |
| commit | 23da82d6eef17e2bd4ec2de497495b32fd338659 (patch) | |
| tree | 3d48cb028951586989786db4e8a0f020e39f6576 /dozentenmodul/src/main/java/gui | |
| parent | [client] reworked exceptions handling of BWIDM auth (diff) | |
| download | tutor-module-23da82d6eef17e2bd4ec2de497495b32fd338659.tar.gz tutor-module-23da82d6eef17e2bd4ec2de497495b32fd338659.tar.xz tutor-module-23da82d6eef17e2bd4ec2de497495b32fd338659.zip | |
[client] more error handling changes for BWIDM Auth
Diffstat (limited to 'dozentenmodul/src/main/java/gui')
| -rw-r--r-- | dozentenmodul/src/main/java/gui/core/LoginGUI.java | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/dozentenmodul/src/main/java/gui/core/LoginGUI.java b/dozentenmodul/src/main/java/gui/core/LoginGUI.java index 6ca06518..00fb5310 100644 --- a/dozentenmodul/src/main/java/gui/core/LoginGUI.java +++ b/dozentenmodul/src/main/java/gui/core/LoginGUI.java @@ -5,15 +5,18 @@ import java.util.Comparator; import java.util.List; import org.apache.log4j.Logger; -import org.apache.thrift.TException; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Shell; +import org.openslx.bwlp.dozmod.thrift.OrganizationList; import org.openslx.bwlp.thrift.iface.Organization; import org.openslx.bwlp.thrift.iface.TAuthenticationException; import org.openslx.bwlp.thrift.iface.UserInfo; -import org.openslx.thrifthelper.ThriftManager; +import util.ShibbolethECP.ReturnCode; import auth.BWIDMAuthenticator; import auth.BaseAuthenticator.AuthenticatorCallback; import edu.kit.scc.dei.ecplean.ECPAuthenticationException; @@ -38,16 +41,12 @@ public class LoginGUI extends LoginComposite { super(mainShell); // entries in the combo - List<Organization> orgs = null; - try { - orgs = ThriftManager.getMasterClient().getOrganizations(); - } catch (TException e) { - LOGGER.error( - "Could not fetch the IdP list from the masterserver! See trace:", e); - // in this case, we can just call the default fillIdPCombo method of the - // superclass + List<Organization> orgs = OrganizationList.getAll(); + if (orgs == null) { + LOGGER.error("No organizations received from the cache."); idpCombo.add("No entries"); } + // all fine, lets sort it Collections.sort(orgs, new Comparator<Organization>() { public int compare(Organization o1, Organization o2) { @@ -55,6 +54,7 @@ public class LoginGUI extends LoginComposite { } }); for (Organization o : orgs) { + if (o.getEcpUrl() == null | o.getEcpUrl().isEmpty()) continue; idpCombo.add(o.displayName); idpCombo.setData(o.displayName, o); } @@ -64,12 +64,7 @@ public class LoginGUI extends LoginComposite { loginButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - try { doLogin(loginType); - } catch (ECPAuthenticationException ae) { - LOGGER.error("Authentication error, see trace: ", ae); - GuiManager.showMessage(ae.getMessage()); - } } }); @@ -111,6 +106,19 @@ public class LoginGUI extends LoginComposite { loginType = LOGIN_TYPE.SAT; } }); + passwordText.addKeyListener(new KeyListener() { + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + if (e.keyCode == SWT.CR) { + doLogin(loginType); + } + } + + @Override + public void keyPressed(KeyEvent e) {} + }); } /** @@ -118,7 +126,7 @@ public class LoginGUI extends LoginComposite { * authentication mechanism corresponding to the selected authButton * @throws ECPAuthenticationException */ - private void doLogin(LOGIN_TYPE loginType) throws ECPAuthenticationException { + private void doLogin(LOGIN_TYPE loginType) { // here we only check for the fields username = usernameText.getText(); password = passwordText.getText(); @@ -153,15 +161,24 @@ public class LoginGUI extends LoginComposite { try { bwidmAuth.login(username, password, new AuthenticatorCallback() { @Override - public void postLogin(UserInfo user) { - LOGGER.info(user.firstName + " " + user.lastName); - if (user != null) + public void postLogin(ReturnCode returnCode, UserInfo user) { + // handle errors first + if (returnCode != ReturnCode.NO_ERROR && user == null) { + switch(returnCode) { + case IDP_ERROR: + GuiManager.showMessage(""); + break; + default: + GuiManager.showMessage("Internal error!"); + break; + } + } else GuiManager.addContent(new DisclaimerComposite(getShell())); } }); } catch (TAuthenticationException e) { - LOGGER.error("Authentication error, see trace: ", e); - GuiManager.showMessage(BAD_AUTH); + //LOGGER.error("Authentication error, see trace: ", e); + GuiManager.showMessage(e.getMessage()); return; } break; |
