diff options
author | Jonathan Bauer | 2015-07-10 14:05:52 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-07-10 14:05:52 +0200 |
commit | f44b17421b4c891273471649e072df49f419f172 (patch) | |
tree | b88b1ed2db2e89f8360868cff34f6fa2bff2eb7a /dozentenmodul/src | |
parent | [client] close popups a bit safer (diff) | |
download | tutor-module-f44b17421b4c891273471649e072df49f419f172.tar.gz tutor-module-f44b17421b4c891273471649e072df49f419f172.tar.xz tutor-module-f44b17421b4c891273471649e072df49f419f172.zip |
[client] create session from the ServiceProviderResponse
added getters for Session class members
use getShell to dispose LoginWindow
Diffstat (limited to 'dozentenmodul/src')
4 files changed, 67 insertions, 17 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..288a4cbc 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java @@ -6,6 +6,7 @@ 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.dozmod.thrift.Session; import org.openslx.thrifthelper.ThriftManager; /** @@ -58,18 +59,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/gui/window/LoginWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java index d0742616..edf7b030 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 @@ -25,6 +25,7 @@ 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.OrganizationCache; +import org.openslx.dozmod.thrift.Session; import org.openslx.thrifthelper.ThriftManager; import edu.kit.scc.dei.ecplean.ECPAuthenticationException; @@ -345,19 +346,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/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; + } + } |