Skip to content

Commit

Permalink
LdapUserDetailsImpl temporarily removed in 104b2b1 used again in Sess…
Browse files Browse the repository at this point in the history
…ionController, dependency Import doesn't cause test fails in actuator sec tests anymore, as the dev branch has harmonized the import
  • Loading branch information
Nic12345678 committed Nov 26, 2024
1 parent c42aef1 commit fb76e1e
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.session.SessionInformation;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.security.ldap.userdetails.LdapUserDetailsImpl;
import org.springframework.session.jdbc.JdbcIndexedSessionRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -54,18 +55,15 @@ public ResponseEntity<OAuthServerSessions> listActiveSessions() {

sessionRegistry.getAllPrincipals().forEach(
principal -> sessionRegistry.getAllSessions(principal, false).forEach(currSessionInfo -> {
log.info("Principal is instanceof" + principal.getClass().getName());
OAuthServerSession currSession = new OAuthServerSession();
if (principal instanceof String) {
currSession.setUsername((String) principal);
log.info("PrincipalName String:" + principal);
} else if (principal instanceof org.springframework.security.core.userdetails.User) {
currSession.setUsername(((org.springframework.security.core.userdetails.User) principal).getUsername());
log.info("PrincipalName org.springframework.security.core.userdetails.User:"
+ ((org.springframework.security.core.userdetails.User) principal).getUsername());
} else if (principal instanceof Principal) {
currSession.setUsername(((Principal) principal).getName());
log.info("PrincipalName Principal:" + ((Principal) principal).getName());
} else if (principal instanceof LdapUserDetailsImpl) {
currSession.setUsername(((LdapUserDetailsImpl) principal).getUsername());
} else {
try {
currSession.setUsername((String) principal.getClass().getMethod("getUsername").invoke(principal));
Expand Down

0 comments on commit fb76e1e

Please sign in to comment.