From e818afcd1987753267d31757ab53915c3116149e Mon Sep 17 00:00:00 2001 From: Pasindu Yeshan Date: Mon, 16 Dec 2024 17:23:09 +0530 Subject: [PATCH 1/2] Ignore groups without IDs --- .../identity/password/expiry/util/PasswordPolicyUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java b/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java index 6d1a99866..966a9173a 100644 --- a/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java +++ b/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java @@ -54,6 +54,7 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -463,7 +464,7 @@ private static Set getUserGroupIds(String userId, UserStoreManager userS List userGroups = ((AbstractUserStoreManager) userStoreManager).getGroupListOfUser(userId, null, null); - return userGroups.stream().map(Group::getGroupID).collect(Collectors.toSet()); + return userGroups.stream().map(Group::getGroupID).filter(Objects::nonNull) .collect(Collectors.toSet()); } catch (UserStoreException e) { throw new PostAuthenticationFailedException(PasswordPolicyConstants.ErrorMessages. ERROR_WHILE_RETRIEVING_USER_GROUPS.getCode(), From aea0643e5f66ce099405dcd85adabe51ae0dbd48 Mon Sep 17 00:00:00 2001 From: Pasindu Yeshan Date: Mon, 16 Dec 2024 17:25:40 +0530 Subject: [PATCH 2/2] Refactor --- .../identity/password/expiry/util/PasswordPolicyUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java b/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java index 966a9173a..ca12272a6 100644 --- a/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java +++ b/components/org.wso2.carbon.identity.password.expiry/src/main/java/org/wso2/carbon/identity/password/expiry/util/PasswordPolicyUtils.java @@ -464,7 +464,7 @@ private static Set getUserGroupIds(String userId, UserStoreManager userS List userGroups = ((AbstractUserStoreManager) userStoreManager).getGroupListOfUser(userId, null, null); - return userGroups.stream().map(Group::getGroupID).filter(Objects::nonNull) .collect(Collectors.toSet()); + return userGroups.stream().map(Group::getGroupID).filter(Objects::nonNull).collect(Collectors.toSet()); } catch (UserStoreException e) { throw new PostAuthenticationFailedException(PasswordPolicyConstants.ErrorMessages. ERROR_WHILE_RETRIEVING_USER_GROUPS.getCode(),