mirror of https://gitee.com/topiam/eiam
pull/74/head
parent
c84bced48a
commit
17c955341d
|
@ -25,6 +25,7 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.data.redis.core.Cursor;
|
import org.springframework.data.redis.core.Cursor;
|
||||||
import org.springframework.data.redis.core.RedisCallback;
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
import org.springframework.data.redis.core.RedisOperations;
|
import org.springframework.data.redis.core.RedisOperations;
|
||||||
|
@ -109,8 +110,19 @@ public class ClusterSessionRegistryImpl<T extends org.springframework.session.Se
|
||||||
//转为实体
|
//转为实体
|
||||||
Authentication authentication = securityContext.getAuthentication();
|
Authentication authentication = securityContext.getAuthentication();
|
||||||
Object principal = authentication.getPrincipal();
|
Object principal = authentication.getPrincipal();
|
||||||
if(principal instanceof UserDetails){
|
if (principal instanceof UserDetails userDetails) {
|
||||||
UserDetails userDetails = (UserDetails) principal;
|
Session sessionDetails = getSession(session, userDetails, authentication);
|
||||||
|
list.add(sessionDetails);
|
||||||
|
}
|
||||||
|
} catch (NullPointerException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//处理
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static Session getSession(MapSession session, UserDetails userDetails, Authentication authentication) {
|
||||||
WebAuthenticationDetails details = (WebAuthenticationDetails) authentication
|
WebAuthenticationDetails details = (WebAuthenticationDetails) authentication
|
||||||
.getDetails();
|
.getDetails();
|
||||||
Session sessionDetails = new Session(userDetails.getId(), userDetails.getUsername());
|
Session sessionDetails = new Session(userDetails.getId(), userDetails.getUsername());
|
||||||
|
@ -133,13 +145,7 @@ public class ClusterSessionRegistryImpl<T extends org.springframework.session.Se
|
||||||
sessionDetails.setUserAgent(details.getUserAgent());
|
sessionDetails.setUserAgent(details.getUserAgent());
|
||||||
//会话ID
|
//会话ID
|
||||||
sessionDetails.setSessionId(session.getId());
|
sessionDetails.setSessionId(session.getId());
|
||||||
list.add(sessionDetails);
|
return sessionDetails;
|
||||||
}
|
|
||||||
} catch (NullPointerException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//处理
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue