user store role mapping feature

apim_420_httpclient
Amalka Subasinghe 11 months ago
parent 53c48d87ca
commit 3d159c0111

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

Loading…
Cancel
Save