diff options
| author | Simon Rettberg | 2015-06-10 20:22:04 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-06-10 20:22:04 +0200 |
| commit | d684cd4dbdadb11a0017556e802bdf3141336f2b (patch) | |
| tree | d1f863957b2c0241b036fb9c82821e7f1df50023 /dozentenmodulserver/src/main/java/server/SessionManager.java | |
| parent | [server] Compiling again, still lots of stubs (diff) | |
| download | tutor-module-d684cd4dbdadb11a0017556e802bdf3141336f2b.tar.gz tutor-module-d684cd4dbdadb11a0017556e802bdf3141336f2b.tar.xz tutor-module-d684cd4dbdadb11a0017556e802bdf3141336f2b.zip | |
[server] db stuff, new interface, ...
Diffstat (limited to 'dozentenmodulserver/src/main/java/server/SessionManager.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/server/SessionManager.java | 23 |
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) { |
