diff options
author | Simon Rettberg | 2015-08-13 15:45:10 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-08-13 15:45:10 +0200 |
commit | 9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7 (patch) | |
tree | fc32e08b30d5643cf1bbd1753ec6f1cc076a8217 /dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java | |
parent | [client] Fix positioning of Wizard (diff) | |
download | tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.tar.gz tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.tar.xz tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.zip |
[client] Layout tweaks, Change owner feature
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.java | 64 |
1 files changed, 42 insertions, 22 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 0ff7cf76..2f5059b5 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java @@ -5,7 +5,6 @@ import org.apache.thrift.TException; 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.UserInfo; import org.openslx.bwlp.thrift.iface.WhoamiInfo; import org.openslx.thrifthelper.ThriftManager; @@ -13,15 +12,7 @@ public class Session { private static final Logger LOGGER = Logger.getLogger(Session.class); - private static String firstName = null; - - private static String lastName = null; - - private static String eMail = null; - - private static String userId = null; - - private static String organizationId = null; + private static WhoamiInfo data = null; private static String satelliteToken = null; @@ -30,16 +21,15 @@ public class Session { private static String satelliteAddress = null; public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken) { - UserInfo ui = whoami.getUser(); - if (userId != null && !userId.equals(ui.userId)) + if (whoami == null || whoami.user == null || whoami.user.userId == null) { + throw new IllegalArgumentException( + "Cannot initialize session: whoami-Information from satellite incomplete"); + } + if (data != null && !data.user.userId.equals(whoami.user.userId)) 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; - organizationId = ui.organizationId; + data = whoami; masterToken = masToken; satelliteToken = satToken; satelliteAddress = satAddress; @@ -49,35 +39,65 @@ public class Session { * @return the first name */ public static String getFirstName() { - return firstName; + if (data == null) + return null; + return data.user.firstName; } /** * @return the last name */ public static String getLastName() { - return lastName; + if (data == null) + return null; + return data.user.lastName; } /** * @return the eMail */ public static String getEMail() { - return eMail; + if (data == null) + return null; + return data.user.eMail; } /** * @return the user id */ public static String getUserId() { - return userId; + if (data == null) + return null; + return data.user.userId; } /** * @return the organization id */ public static String getOrganizationId() { - return organizationId; + if (data == null) + return null; + return data.user.organizationId; + } + + /** + * @return whether user is superuser (has all permissions on everything, can + * declare an image a template) + */ + public static boolean isSuperUser() { + if (data == null) + return false; + return data.isSuperUser; + } + + /** + * @return whether user can see list of images. students will only be able + * to list lectures + */ + public static boolean canListImages() { + if (data == null) + return false; + return data.canListImages; } /** |