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 org.apache.commons.collections4.CollectionUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
|
@ -109,8 +110,19 @@ public class ClusterSessionRegistryImpl<T extends org.springframework.session.Se
|
|||
//转为实体
|
||||
Authentication authentication = securityContext.getAuthentication();
|
||||
Object principal = authentication.getPrincipal();
|
||||
if(principal instanceof UserDetails){
|
||||
UserDetails userDetails = (UserDetails) principal;
|
||||
if (principal instanceof UserDetails userDetails) {
|
||||
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
|
||||
.getDetails();
|
||||
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());
|
||||
//会话ID
|
||||
sessionDetails.setSessionId(session.getId());
|
||||
list.add(sessionDetails);
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
//处理
|
||||
return list;
|
||||
return sessionDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue