1 package de.juplo.yourshouter;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.social.UserIdSource;
9 * Implementation of {@link UserIdSource}, that retrieves the ID of the current
10 * user from the {@link SecurityContext}.
14 public class SecurityContextUserIdSource implements UserIdSource
16 private final static Logger LOG =
17 LoggerFactory.getLogger(SecurityContextUserIdSource.class);
21 * Retrieves the ID of the current user from the {@link SecurityContext}.
24 * The ID of the current user, or the special ID <code>anonymous</code>,
25 * if no current user is present.
28 public String getUserId()
30 String user = SecurityContext.getCurrentUser();
33 LOG.debug("found user \"{}\" in the security-context", user);
37 LOG.info("found no user in the security-context, using \"anonymous\"");