public static String getUserName() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof UsernamePasswordAuthenticationToken) {
return authentication.getName();
}
if (authentication instanceof OAuth2Authentication) {
log.info("third part login.authentication:{}, user {},from {}", authentication, authentication.getName(), NetworkUtil.getRemoteIp());
return authentication.getName();
}
if (authentication instanceof AnonymousAuthenticationToken) {
log.warn(" user {} not login,from {}", authentication.getName(), NetworkUtil.getRemoteIp());
return authentication.getName();
}
log.warn("{} isAuthenticated():{},name:{},details:{}", Flag.BizLogFlag.WARN_CHECK, authentication.isAuthenticated(), authentication.getName(), authentication.getDetails());
throw new ApiBizException(GlobalCode.UNKNOWN);
}
SecurityUtil.java 文件源码
java
阅读 55
收藏 0
点赞 0
评论 0
项目:sns-todo
作者:
评论列表
文章目录