Created
March 24, 2011 08:29
-
-
Save sfussenegger/884744 to your computer and use it in GitHub Desktop.
extract accountId from User set as "user" property at session scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import java.io.Serializable; | |
import org.springframework.social.web.connect.AccountIdExtractor; | |
import org.springframework.web.context.request.RequestAttributes; | |
import org.springframework.web.context.request.WebRequest; | |
// your own User class | |
import org.example.User; | |
/** | |
* extract accountId from User set as "user" property at session scope | |
*/ | |
public class UserAccountIdExtractor implements AccountIdExtractor { | |
@Override | |
public Serializable extractAccountId(final WebRequest request) { | |
User user = (User) request.getAttribute("user", RequestAttributes.SCOPE_SESSION); | |
return user == null ? null : user.getId(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment