X-Git-Url: https://juplo.de/gitweb/?p=examples%2Ffacebook-app;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fyourshouter%2FSecurityContext.java;fp=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fyourshouter%2FSecurityContext.java;h=0000000000000000000000000000000000000000;hp=37ca54c9bb90b9ff60d179f896cd564f1cd3f1e1;hb=8f6d3c83aa9651e593b57b3d47cfd50a4ae73661;hpb=ca351a3eb7442fbb183aa62e1a58cd85bc1f2ef7 diff --git a/src/main/java/de/juplo/yourshouter/SecurityContext.java b/src/main/java/de/juplo/yourshouter/SecurityContext.java deleted file mode 100644 index 37ca54c..0000000 --- a/src/main/java/de/juplo/yourshouter/SecurityContext.java +++ /dev/null @@ -1,66 +0,0 @@ -package de.juplo.yourshouter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Simple SecurityContext that stores the currently signed-in connection in a - * thread local. - * - * @author Kai Moritz - */ -public final class SecurityContext -{ - private final static Logger LOG = LoggerFactory.getLogger(SecurityContext.class); - private final static ThreadLocal CURRENT_USER = new ThreadLocal<>(); - - - /** - * Fetches the ID of the current user from the thread-local. - * - * @return - * The ID of the current user, or null if no user is known. - */ - public static String getCurrentUser() - { - String user = CURRENT_USER.get(); - LOG.debug("current user: {}", user); - return user; - } - - /** - * Stores the given ID as the ID of the current user in the thread-local. - * - * @param user - * The ID to store as the ID of the current user. - */ - public static void setCurrentUser(String user) - { - LOG.debug("setting current user: {}", user); - CURRENT_USER.set(user); - } - - /** - * Checks, if a user is signed in. That is, if the ID of a user is stored in - * the thread-local. - * - * @return - * true, if a user is signed in, false otherwise. - */ - public static boolean userSignedIn() - { - boolean signedIn = CURRENT_USER.get() != null; - LOG.debug("user signed in: {}", signedIn); - return signedIn; - } - - /** - * Removes the ID of the current user from the thread-local. - */ - public static void remove() - { - LOG.debug("removing current user"); - CURRENT_USER.remove(); - } -}