Skip to content

Commit

Permalink
Issue #LR-676 fix: Fixed KC multiple session remove. (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmiableAnil authored Feb 6, 2024
1 parent cf5df72 commit 38fa371
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.keycloak.RSATokenVerifier;
Expand Down Expand Up @@ -94,6 +95,9 @@ public boolean removePII(String userId, RequestContext context) {
user.setEnabled(false);
logger.info("KeyCloakServiceImpl::removePII:: userId:: " + fedUserId);
userResource.update(user);
List userSessions = userResource.getUserSessions();
for (Object userSession : userSessions)
userSessions.remove(userSession);
return true;
} catch (Exception e) {
logger.error(context, "removePII: Exception occurred: ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,12 @@ public void testGetFederatedUserId()
@Test
public void testUpdatePassword() throws Exception {
boolean updated = keyCloakService.updatePassword(userId.get(JsonKey.USER_ID), "password", null);
Assert.assertNotNull(updated);
Assert.assertTrue(updated);
}

@Test
public void testRemovePII() {
keyCloakService.removePII(userId.get(JsonKey.USER_ID), new RequestContext());
boolean piiRemoved = keyCloakService.removePII(userId.get(JsonKey.USER_ID), new RequestContext());
Assert.assertTrue(piiRemoved);
}
}

0 comments on commit 38fa371

Please sign in to comment.