From fb76e1e1d5c970031bddd7d4b39046b3d5ef26df Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:43:17 +0100 Subject: [PATCH] LdapUserDetailsImpl temporarily removed in 104b2b1f81bd77a0b1813fdc2d5a6a5e5150a175 used again in SessionController, dependency Import doesn't cause test fails in actuator sec tests anymore, as the dev branch has harmonized the import --- .../authservice/rest/SessionController.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/rest/SessionController.java b/wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/rest/SessionController.java index 3b3507763..d23b93240 100644 --- a/wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/rest/SessionController.java +++ b/wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/rest/SessionController.java @@ -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; @@ -54,18 +55,15 @@ public ResponseEntity 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));