summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-11 16:32:07 +0200
committerSimon Rettberg2015-08-11 16:32:07 +0200
commit3a91f090eab386ea37f8c4379f27a26378fbaa04 (patch)
treed3ae74dbd17e81a8183cb81518458142b5c0a77f /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
parent[server] Create proper path for file download (diff)
downloadtutor-module-3a91f090eab386ea37f8c4379f27a26378fbaa04.tar.gz
tutor-module-3a91f090eab386ea37f8c4379f27a26378fbaa04.tar.xz
tutor-module-3a91f090eab386ea37f8c4379f27a26378fbaa04.zip
[client] Improve authentication handling
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.java61
1 files changed, 9 insertions, 52 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 4476b1f9..0ff7cf76 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
@@ -2,16 +2,11 @@ package org.openslx.dozmod.thrift;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.bwlp.thrift.iface.ClientSessionData;
import org.openslx.bwlp.thrift.iface.ImagePermissions;
import org.openslx.bwlp.thrift.iface.LecturePermissions;
import org.openslx.bwlp.thrift.iface.SatelliteConfig;
-import org.openslx.bwlp.thrift.iface.SessionData;
-import org.openslx.bwlp.thrift.iface.TInvalidTokenException;
import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.bwlp.thrift.iface.WhoamiInfo;
-import org.openslx.dozmod.Config.SavedSession;
-import org.openslx.dozmod.authentication.ServiceProviderResponse;
import org.openslx.thrifthelper.ThriftManager;
public class Session {
@@ -34,51 +29,20 @@ public class Session {
private static String satelliteAddress = null;
- public static void fromClientSessionData(ClientSessionData session) {
- if (userId != null && !userId.equals(session.userInfo.userId))
- throw new IllegalArgumentException("Cannot set new session data with different user id!");
- firstName = session.userInfo.firstName;
- lastName = session.userInfo.lastName;
- eMail = session.userInfo.eMail;
- userId = session.userInfo.userId;
- 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);
+ public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken) {
+ UserInfo ui = whoami.getUser();
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) {
- 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;
- userId = response.userId;
- organizationId = response.organizationId;
- masterToken = response.sessionId;
- satelliteToken = response.token;
- }
-
- public static void fromSavedSession(SavedSession session) throws TInvalidTokenException, TException {
- satelliteToken = session.token;
- WhoamiInfo wi = ThriftManager.getSatClient().whoami(satelliteToken);
- UserInfo ui = wi.getUser();
+ throw new IllegalArgumentException("Cannot set new session data with different user id");
+ if (satelliteAddress != null && !satelliteAddress.equals(satAddress))
+ throw new IllegalArgumentException("Cannot set new session data with different satellite address");
firstName = ui.firstName;
lastName = ui.lastName;
eMail = ui.eMail;
userId = ui.userId;
- // TODO check if correct/ mastertoken?
+ organizationId = ui.organizationId;
+ masterToken = masToken;
+ satelliteToken = satToken;
+ satelliteAddress = satAddress;
}
/**
@@ -137,13 +101,6 @@ public class Session {
return satelliteAddress;
}
- /**
- * @param satelliteAddress the satelliteAddress to set
- */
- public static void setSatelliteAddress(String satelliteAddress) {
- Session.satelliteAddress = satelliteAddress;
- }
-
private static SatelliteConfig satConf = null;
/**