summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-15 17:33:19 +0200
committerSimon Rettberg2015-07-15 17:33:19 +0200
commit2987d0992a0609a3c9eb23048d87df630225b978 (patch)
tree4f9a778563b2da0316bc3e637d2dd31ee5280b70 /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
parent[cilent] check if vmdk parsed from vmx is relative or absolute and do proper ... (diff)
downloadtutor-module-2987d0992a0609a3c9eb23048d87df630225b978.tar.gz
tutor-module-2987d0992a0609a3c9eb23048d87df630225b978.tar.xz
tutor-module-2987d0992a0609a3c9eb23048d87df630225b978.zip
Adapt to changed thrift api for improved session validation
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java23
1 files changed, 20 insertions, 3 deletions
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 c4e6bb6b..1f4cf0b0 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
@@ -1,7 +1,12 @@
package org.openslx.dozmod.thrift;
+import org.apache.thrift.TException;
import org.openslx.bwlp.thrift.iface.ClientSessionData;
+import org.openslx.bwlp.thrift.iface.SessionData;
+import org.openslx.bwlp.thrift.iface.TInvalidTokenException;
+import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.dozmod.authentication.ServiceProviderResponse;
+import org.openslx.thrifthelper.ThriftManager;
public class Session {
@@ -29,11 +34,23 @@ public class Session {
masterToken = session.sessionId;
satelliteToken = session.authToken;
}
+
+ public static void fromSessionData(SessionData session) throws TInvalidTokenException, TException {
+ // TODO: This is legacy API, switch to ClientSessionData asap
+ UserInfo ui = ThriftManager.getMasterClient().getUserFromToken(session.authToken);
+ if (userId != null && !userId.equals(ui.userId))
+ throw new IllegalArgumentException("Cannot set new session data with different user id!");
+ firstName = ui.firstName;
+ lastName = ui.lastName;
+ eMail = ui.eMail;
+ userId = ui.userId;
+ masterToken = session.sessionId;
+ satelliteToken = session.authToken;
+ }
public static void fromEcpLogin(ServiceProviderResponse response) {
- // TODO
- //if (userId != null && !userId.equals(response.userId))
- // throw new IllegalArgumentException("Cannot set new session data with different user id!");
+ if (userId != null && !userId.equals(response.userId))
+ throw new IllegalArgumentException("Cannot set new session data with different user id!");
firstName = response.firstName;
lastName = response.lastName;
eMail = response.mail;