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..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 @@ -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(),