user store role mapping feature

backup
Amalka Subasinghe 1 year ago
parent 53c48d87ca
commit 3d159c0111

@ -75,6 +75,7 @@ public class UserStoreRoleMapper implements ServerStartupObserver {
.getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager();
for (RoleMapping mapping : roleMappings) {
if (userStoreManager.isExistingRole(mapping.getSecondaryRole())) {
String[] users = userStoreManager.getUserListOfRole(mapping.getSecondaryRole());
if (users != null && users.length > 0) {
List<String> primaryRoles = mapping.getInternalRoles();
@ -83,7 +84,7 @@ public class UserStoreRoleMapper implements ServerStartupObserver {
String[] existingUsers = userStoreManager.getUserListOfRole(role);
List<String> existingUserList = new ArrayList<>(Arrays.asList(existingUsers));
List<String> newUserList = new ArrayList<>();
for (String user: users) {
for (String user : users) {
if (existingUserList.contains(user)) {
// if contains, remove from existing list
existingUserList.remove(user);
@ -95,7 +96,7 @@ public class UserStoreRoleMapper implements ServerStartupObserver {
List<String> deleteUserList = new ArrayList<>();
if (!existingUserList.isEmpty()) {
String domain = mapping.getSecondaryRole().substring(0,mapping.getSecondaryRole().indexOf("/"));
String domain = mapping.getSecondaryRole().substring(0, mapping.getSecondaryRole().indexOf("/"));
for (String user : existingUserList) {
if (user.startsWith(domain.toUpperCase())) {
deleteUserList.add(user);
@ -113,6 +114,7 @@ public class UserStoreRoleMapper implements ServerStartupObserver {
}
}
}
}
} catch (Exception e) {
log.error("Error while getting user store...", e);
} finally {

Loading…
Cancel
Save