Fix null userlist when assigning role permissions

remotes/1712966534876109980/master
Lasantha Dharmakeerthi 10 months ago
commit c6ec90801d

@ -556,6 +556,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername());
String[] stringUserList;
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
if (!userStoreManager.isExistingRole(roleName)) { if (!userStoreManager.isExistingRole(roleName)) {
@ -581,13 +582,16 @@ public class RoleManagementServiceImpl implements RoleManagementService {
final String[] usersToDelete = transformer.getObjectsToRemove().toArray(new String[transformer final String[] usersToDelete = transformer.getObjectsToRemove().toArray(new String[transformer
.getObjectsToRemove().size()]); .getObjectsToRemove().size()]);
userStoreManager.updateUserListOfRole(newRoleName, usersToDelete, usersToAdd); userStoreManager.updateUserListOfRole(newRoleName, usersToDelete, usersToAdd);
stringUserList = roleInfo.getUsers();
} else {
stringUserList = userStoreManager.getUserListOfRole(roleName);
} }
if (roleInfo.getPermissions() != null) { if (roleInfo.getPermissions() != null) {
String[] roleDetails = roleName.split("/"); String[] roleDetails = roleName.split("/");
updatePermissions(roleDetails[roleDetails.length - 1], roleInfo, userRealm); updatePermissions(roleDetails[roleDetails.length - 1], roleInfo, userRealm);
} }
String stringUsers = new Gson().toJson(roleInfo.getUsers()); String stringUsers = new Gson().toJson(stringUserList);
log.info( log.info(
"Role " + roleInfo.getRoleName().split("/")[1] + " updated", "Role " + roleInfo.getRoleName().split("/")[1] + " updated",
roleMgtContextBuilder roleMgtContextBuilder

Loading…
Cancel
Save