summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/server/SessionManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver/src/main/java/server/SessionManager.java')
-rw-r--r--dozentenmodulserver/src/main/java/server/SessionManager.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/dozentenmodulserver/src/main/java/server/SessionManager.java b/dozentenmodulserver/src/main/java/server/SessionManager.java
index 75336de0..3f4d4257 100644
--- a/dozentenmodulserver/src/main/java/server/SessionManager.java
+++ b/dozentenmodulserver/src/main/java/server/SessionManager.java
@@ -5,7 +5,9 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
-import org.openslx.imagemaster.thrift.iface.UserInfo;
+import org.openslx.bwlp.thrift.iface.AuthorizationError;
+import org.openslx.bwlp.thrift.iface.TAuthorizationException;
+import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.thrifthelper.ThriftManager;
/**
@@ -35,11 +37,26 @@ public class SessionManager {
private static Map<String, Entry> tokenManager = new ConcurrentHashMap<>();
/**
+ * Get the user corresponding to the given token.
+ *
+ * @param token user's token
+ * @return UserInfo for the matching user
+ * @throws TAuthorizationException if the token is not known or the session
+ * expired
+ */
+ public static UserInfo getOrFail(String token) throws TAuthorizationException {
+ UserInfo ui = get(token);
+ if (ui != null)
+ return ui;
+ throw new TAuthorizationException(AuthorizationError.NOT_AUTHENTICATED,
+ "Your session token is not known to the server");
+ }
+
+ /**
* Get the user corresponding to the given token. Returns null if the token
* is not known, or the session already timed out.
*
- * @param token
- * user's token
+ * @param token user's token
* @return UserInfo for the matching user
*/
public static UserInfo get(String token) {