mirror of https://gitee.com/topiam/eiam
pull/74/head
parent
eeffe4d3de
commit
c84bced48a
|
@ -108,10 +108,12 @@ public class ClusterSessionRegistryImpl<T extends org.springframework.session.Se
|
|||
SecurityContext securityContext = session.getAttribute(SPRING_SECURITY_CONTEXT);
|
||||
//转为实体
|
||||
Authentication authentication = securityContext.getAuthentication();
|
||||
UserDetails principal = (UserDetails) authentication.getPrincipal();
|
||||
Object principal = authentication.getPrincipal();
|
||||
if(principal instanceof UserDetails){
|
||||
UserDetails userDetails = (UserDetails) principal;
|
||||
WebAuthenticationDetails details = (WebAuthenticationDetails) authentication
|
||||
.getDetails();
|
||||
Session sessionDetails = new Session(principal.getId(), principal.getUsername());
|
||||
Session sessionDetails = new Session(userDetails.getId(), userDetails.getUsername());
|
||||
//last request
|
||||
Instant instant = session.getLastAccessedTime();
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
|
@ -124,7 +126,7 @@ public class ClusterSessionRegistryImpl<T extends org.springframework.session.Se
|
|||
sessionDetails
|
||||
.setAuthenticationProvider(details.getAuthenticationProvider().getType());
|
||||
//用户类型
|
||||
sessionDetails.setUserType(principal.getUserType());
|
||||
sessionDetails.setUserType(userDetails.getUserType());
|
||||
//地理位置
|
||||
sessionDetails.setGeoLocation(details.getGeoLocation());
|
||||
//用户代理
|
||||
|
@ -132,6 +134,7 @@ public class ClusterSessionRegistryImpl<T extends org.springframework.session.Se
|
|||
//会话ID
|
||||
sessionDetails.setSessionId(session.getId());
|
||||
list.add(sessionDetails);
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue