private static MetkaAuthenticationDetails getDetails() throws AuthenticationCredentialsNotFoundException {
SecurityContext context = SecurityContextHolder.getContext();
if(context == null) {
Logger.error(AuthenticationUtil.class, "User name was requested but no SecurityContext was found");
throw new AuthenticationCredentialsNotFoundException("Couldn't find security context");
}
Authentication authentication = context.getAuthentication();
if(authentication == null) {
Logger.error(AuthenticationUtil.class, "SecurityContext was found but no authentication details were set");
throw new AuthenticationCredentialsNotFoundException("Couldn't find Authentication information");
}
if(authentication.getDetails() == null || !(authentication.getDetails() instanceof MetkaAuthenticationDetails)) {
Logger.error(AuthenticationUtil.class, "Authentication details are null or don't match expected format");
throw new AuthenticationCredentialsNotFoundException("Authentication details are null or not in expected format");
}
return (MetkaAuthenticationDetails)authentication.getDetails();
}
AuthenticationUtil.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:metka
作者:
评论列表
文章目录