本文整理汇总了Java中org.springframework.security.authentication.UsernamePasswordAuthenticationToken.isAuthenticated方法的典型用法代码示例。如果您正苦于以下问题:Java UsernamePasswordAuthenticationToken.isAuthenticated方法的具体用法?Java UsernamePasswordAuthenticationToken.isAuthenticated怎么用?Java UsernamePasswordAuthenticationToken.isAuthenticated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.authentication.UsernamePasswordAuthenticationToken
的用法示例。
在下文中一共展示了UsernamePasswordAuthenticationToken.isAuthenticated方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signInUser
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
public String signInUser(){
boolean registered = userService.createUser(username, password);
if(registered){
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
userDetails,
password,
userDetails.getAuthorities());
authenticationManager.authenticate(token);
if (token.isAuthenticated()) {
SecurityContextHolder.getContext().setAuthentication(token);
}
return "/index.jsf";
} else {
return "/signin.jsf?error=true";
}
}
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:24,代码来源:SignInController.java
示例2: autoLogin
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
@Override
public void autoLogin(String username, String password) {
boolean isLogin = false;
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
authenticationManager.authenticate(usernamePasswordAuthenticationToken);
if (usernamePasswordAuthenticationToken.isAuthenticated()) {
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
isLogin = true;
}
}
示例3: autologin
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void autologin(final String username, final String password) {
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
authenticationManager.authenticate(usernamePasswordAuthenticationToken);
if (usernamePasswordAuthenticationToken.isAuthenticated()) {
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
logger.debug(String.format("Auto login %s successfully!", username));
}
}
示例4: autologin
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
@Override
public void autologin(String username, String password) {
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
authenticationManager.authenticate(usernamePasswordAuthenticationToken);
if (usernamePasswordAuthenticationToken.isAuthenticated()) {
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
logger.debug(String.format("Auto login %s successfully!", username));
}
}