Remove unnessary for loops
@@ -325,23 +325,16 @@ public class DefaultClaimHandler implements ClaimHandler {
Map<String, String> localToSpRoleMapping = applicationConfig.getRoleMappings();
- if (MapUtils.isEmpty(localToSpRoleMapping)) {
- return StringUtils.join(locallyMappedUserRoles, ",");
- }
-
- StringBuilder spMappedUserRoles = new StringBuilder();
+ if (!MapUtils.isEmpty(localToSpRoleMapping)) {
for (Map.Entry<String, String> roleMapping : localToSpRoleMapping.entrySet()) {
if (locallyMappedUserRoles.contains(roleMapping.getKey())) {
- spMappedUserRoles.append(roleMapping.getValue()).append(claimSeparator);
locallyMappedUserRoles.remove(roleMapping.getKey());
+ locallyMappedUserRoles.add(roleMapping.getValue());
}
}
-
- for (String remainingRole : locallyMappedUserRoles) {
- spMappedUserRoles.append(remainingRole).append(claimSeparator);
}
- return spMappedUserRoles.toString().substring(0, spMappedUserRoles.length() - 1);
+ return StringUtils.join(locallyMappedUserRoles, claimSeparator);
}
/**
