本文整理汇总了Java中org.springframework.security.authentication.RememberMeAuthenticationToken类的典型用法代码示例。如果您正苦于以下问题:Java RememberMeAuthenticationToken类的具体用法?Java RememberMeAuthenticationToken怎么用?Java RememberMeAuthenticationToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RememberMeAuthenticationToken类属于org.springframework.security.authentication包,在下文中一共展示了RememberMeAuthenticationToken类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
public void authenticate(Connection<?> connection) {
Facebook facebook = (Facebook) connection.getApi();
String [] fields = { "id", "name", "email", "first_name", "last_name" };
User userProfile = facebook.fetchObject("me", User.class, fields);
String username = userProfile.getName();
log.info("User Profile by facebook {} {} {}", userProfile.getFirstName(), userProfile.getLastName(), userProfile.getEmail());
Optional<io.osoon.domain.User> byEmail = userService.findByEmail(userProfile.getEmail());
io.osoon.domain.User osoonUser;
if (byEmail.isPresent()) {
osoonUser = byEmail.get();
} else {
io.osoon.domain.User newUser = io.osoon.domain.User.of(userProfile.getEmail(), username);
newUser.setImageUrl(connection.getImageUrl());
osoonUser = userService.saveOne(newUser);
}
OSoonUserDetails userDetails = new OSoonUserDetails(osoonUser);
RememberMeAuthenticationToken rememberMeToken = new RememberMeAuthenticationToken("osoon-remember-me", userDetails, null);
SecurityContextHolder.getContext().setAuthentication(rememberMeToken);
log.info("User {} {} {} connected.", userProfile.getFirstName(), userProfile.getLastName(), userProfile.getEmail());
}
示例2: doFilter
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null && auth instanceof RememberMeAuthenticationToken) {
rememberMeServices.loginSuccess((HttpServletRequest) servletRequest,
(HttpServletResponse) servletResponse, auth);
}
filterChain.doFilter(servletRequest, servletResponse);
}
示例3: isRememberMeAuthenticated
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
/**
* Check if user is login by remember me cookie, refer
* org.springframework.security.authentication.
* AuthenticationTrustResolverImpl
*/
@SuppressWarnings("unused")
private boolean isRememberMeAuthenticated() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return false;
}
return RememberMeAuthenticationToken.class.isAssignableFrom(authentication.getClass());
}
示例4: onValidTokenFound
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
protected void onValidTokenFound(HttpServletRequest request, HttpServletResponse response, RemoteToken token) {
try {
FlowableAppUser appUser = userCache.get(token.getUserId());
validateRequiredPriviliges(request, response, appUser);
SecurityContextHolder.getContext().setAuthentication(new RememberMeAuthenticationToken(token.getId(),
appUser, appUser.getAuthorities()));
} catch (Exception e) {
LOGGER.trace("Could not set necessary threadlocals for token", e);
redirectOrSendNotPermitted(request, response, token.getUserId());
}
}
示例5: convertUsernamePasswordToRememberMeAuthentication
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
/**
* This is needed so that expressions in spring-security SPEL work properly.
*/
public static void convertUsernamePasswordToRememberMeAuthentication() {
final UsernamePasswordAuthenticationToken usernamePassword = (UsernamePasswordAuthenticationToken) getAuthentication();
final RememberMeAuthenticationToken rememberMe = new RememberMeAuthenticationToken(
ExtendedAnonymousAuthenticationFilter.KEY, usernamePassword.getPrincipal(),
usernamePassword.getAuthorities());
setAuthentication(rememberMe);
}
示例6: isRemembered
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
public boolean isRemembered(Authentication authentication, String attribute) {
return IS_REMEMBERED.equals(attribute)
&& RememberMeAuthenticationToken.class
.isAssignableFrom(authentication.getClass());
}
示例7: supports
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
@Override
public boolean supports(Class<?> authentication) {
return (RememberMeAuthenticationToken.class.isAssignableFrom(authentication));
}
示例8: login
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
protected void login(User user) {
OSoonUserDetails userDetails = new OSoonUserDetails(user);
RememberMeAuthenticationToken rememberMeToken = new RememberMeAuthenticationToken("osoon-remember-me", userDetails, null);
SecurityContextHolder.getContext().setAuthentication(rememberMeToken);
}
示例9: isFullyAuthenticated
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
protected boolean isFullyAuthenticated(Authentication authentication) {
return !(authentication instanceof AnonymousAuthenticationToken ||
authentication instanceof RememberMeAuthenticationToken);
}
示例10: isRememberMe
import org.springframework.security.authentication.RememberMeAuthenticationToken; //导入依赖的package包/类
@Override
public boolean isRememberMe() {
return getAuthentication() instanceof RememberMeAuthenticationToken;
}