/**
* Return the current user, or throws an exception, if the user is not
* authenticated yet.
*
* @return the current user
*/
public static User getCurrentUser() {
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication authentication = securityContext.getAuthentication();
if (authentication != null) {
if (authentication.getPrincipal() instanceof User) {
return (User) authentication.getPrincipal();
}
}
throw new IllegalStateException("User not found!");
}
SecurityUtils.java 文件源码
java
阅读 39
收藏 0
点赞 0
评论 0
项目:shoucang
作者:
评论列表
文章目录