diff options
| author | Simon Rettberg | 2015-07-10 14:58:23 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-07-10 14:58:23 +0200 |
| commit | 21bcc133d1e668f4ab30e735621ccdb9847592b5 (patch) | |
| tree | a1450400a5eadd64907782235a62c1beb1a50fb8 /dozentenmodul/src/main/java | |
| parent | [client] More refactoring, introduce a Gui helper class (again) (diff) | |
| parent | [client] fix virt notice not coming back even if the checkbox wasn't clicked (diff) | |
| download | tutor-module-21bcc133d1e668f4ab30e735621ccdb9847592b5.tar.gz tutor-module-21bcc133d1e668f4ab30e735621ccdb9847592b5.tar.xz tutor-module-21bcc133d1e668f4ab30e735621ccdb9847592b5.zip | |
Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1
Diffstat (limited to 'dozentenmodul/src/main/java')
6 files changed, 78 insertions, 28 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java index fbc26c5d..9bbc4175 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java @@ -1,12 +1,10 @@ package org.openslx.dozmod.authentication; import org.apache.log4j.Logger; -import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.TAuthenticationException; -import org.openslx.bwlp.thrift.iface.TInvalidTokenException; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.authentication.ShibbolethEcp.ReturnCode; -import org.openslx.thrifthelper.ThriftManager; +import org.openslx.dozmod.thrift.Session; /** * @author Jonathan Bauer @@ -58,18 +56,18 @@ public class EcpAuthenticator implements Authenticator { LOGGER.error("No token received from the service provider!"); callback.postLogin(ReturnCode.SERVICE_PROVIDER_ERROR, null, null); } - try { - // valid token? - userInfo = ThriftManager.getMasterClient().getUserFromToken(token); - } catch (TInvalidTokenException e) { - LOGGER.error("Masterserver does not accepts the token received from the Service Provider. See trace: ", e); - callback.postLogin(ReturnCode.SERVICE_PROVIDER_ERROR, null, e); - return; - } catch (TException e) { - LOGGER.error("Thrift transport error, see trace: ", e); - callback.postLogin(ReturnCode.GENERIC_ERROR, null, e); - return; - } + + // create the session for the user from the response of the ECP + Session.fromEcpLogin(ShibbolethEcp.getResponse()); + + // build userInfo from the information received + userInfo = new UserInfo(Session.getUserId(), + Session.getFirstName(), + Session.getLastName(), + Session.getEMail(), + Session.getOrganizationId()); + + // send it back to the GUI callback.postLogin(ReturnCode.NO_ERROR, userInfo, null); } else { // else just return the ReturnCode to the GUI diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java index f222efb7..c8ff5a2c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java @@ -10,6 +10,8 @@ public class ServiceProviderResponse { public HashMap<String, String> satellites; public String token; public String sessionId; + public String userId; + public String organizationId; public String url; public String error; } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/TestAccountAuthenticator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/TestAccountAuthenticator.java index bdb92023..0c83ad0b 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/TestAccountAuthenticator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/TestAccountAuthenticator.java @@ -36,6 +36,7 @@ public class TestAccountAuthenticator implements Authenticator { // handle answer from server if (authResult != null && authResult.authToken != null) { + // TODO: Session.fromClientSessionData(authResult); UserInfo userInfo = null; try { userInfo = ThriftManager.getMasterClient().getUserFromToken(authResult.authToken); 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 b9a021e6..0ae01702 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 @@ -85,14 +85,14 @@ public class LoginWindow extends LoginWindowLayout { if (savedLoginType == null) { authButtons[LOGIN_TYPE.BWIDM.getId()].setSelection(true); loginType = LOGIN_TYPE.BWIDM; + idpText.setVisible(true); + idpCombo.setVisible(true); } else { authButtons[savedLoginType.getId()].setSelection(true); loginType = savedLoginType; // enable the IDP combo only if we actually have items in it - if (idpCombo.getItemCount() > 1) { - idpText.setVisible(savedLoginType == LOGIN_TYPE.BWIDM); - idpCombo.setVisible(savedLoginType == LOGIN_TYPE.BWIDM); - } + idpText.setVisible(savedLoginType == LOGIN_TYPE.BWIDM); + idpCombo.setVisible(savedLoginType == LOGIN_TYPE.BWIDM); } } else { // default value for LOGIN_TYPE is BWIDM @@ -176,6 +176,10 @@ public class LoginWindow extends LoginWindowLayout { } public void populateIdpCombo(List<Organization> orgs) { + + // safety check to see if the login window still exists + // when this function gets called by the other thread + if (this.isDisposed()) return; // always clearup the list first idpCombo.removeAll(); @@ -211,8 +215,8 @@ public class LoginWindow extends LoginWindowLayout { // if no organization was saved, none is selected, so select the first one in the combobox if (idpCombo.getSelectionIndex() == -1) idpCombo.select(0); - // finally reenable it - idpCombo.setEnabled(true); + // finally re-enable it + if (idpCombo.isVisible()) idpCombo.setEnabled(true); } /** @@ -346,20 +350,17 @@ public class LoginWindow extends LoginWindowLayout { */ private void postSuccessfulLogin() { LOGGER.info(loginType.getTag() + " succeeded."); - + // TODO HACK HACK ThriftManager.setSatelliteAddress("132.230.8.113"); - // TODO set session stuff - // now read the config to see if the user already agreed to the disclaimer if (!Config.getDisclaimerAgreement()) MainWindow.openPopup(DisclaimerWindow.class, true); if (!Config.getVmwareLicenseAgreement()) MainWindow.openPopup(VirtualizerNoticeWindow.class, true); - this.getParent().dispose(); - + getShell().dispose(); } /** diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java index 014e1ee9..d94ed01a 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java @@ -20,7 +20,7 @@ public class VirtualizerNoticeWindow extends VirtualizerNoticeWindowLayout { continueButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (!Config.setVmwareLicenseAgreement(true)) + if (!Config.setVmwareLicenseAgreement(readCheck.getSelection())) LOGGER.error("Could not set the agreement to the vmware license in '" + Config.getPath() + "'!"); Config.store(); me.getShell().dispose(); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java index 33612746..6950a743 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java @@ -13,6 +13,8 @@ public class Session { private static String userId = null; + private static String organizationId = null; + private static String satelliteToken = null; private static String masterToken = null; @@ -35,13 +37,59 @@ public class Session { firstName = response.firstName; lastName = response.lastName; eMail = response.mail; - //userId = response.userId; TODO + userId = response.userId; + organizationId = response.organizationId; masterToken = response.token; satelliteToken = response.sessionId; } + /** + * @return the first name + */ + public static String getFirstName() { + return firstName; + } + + /** + * @return the last name + */ + public static String getLastName() { + return lastName; + } + + /** + * @return the eMail + */ + public static String getEMail() { + return eMail; + } + + /** + * @return the user id + */ + public static String getUserId() { + return userId; + } + + /** + * @return the organization id + */ + public static String getOrganizationId() { + return organizationId; + } + + /** + * @return the satellite token + */ public static String getSatelliteToken() { return satelliteToken; } + /** + * @return the master token + */ + public static String getMasterToken() { + return masterToken; + } + } |
