Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #LR-676 fix: Fixed KC multiple session remove. #1240

Merged
merged 9 commits into from
Feb 6, 2024
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);
}
}