Fixing role claim not available in oauth2 and userinfo endpoint invocations
@@ -320,13 +320,13 @@ public class DefaultClaimHandler implements ClaimHandler {
* @return
*/
private static String getServiceProviderMappedUserRoles(ApplicationConfig applicationConfig,
- List<String> locallyMappedUserRoles, String claimSeparator) throws FrameworkException {
- if (CollectionUtils.isNotEmpty(locallyMappedUserRoles)) {
+ List<String> locallyMappedUserRoles, String claimSeparator)
+ throws FrameworkException {
Map<String, String> localToSpRoleMapping = applicationConfig.getRoleMappings();
if (MapUtils.isEmpty(localToSpRoleMapping)) {
- return null;
+ return StringUtils.join(locallyMappedUserRoles, ",");
}
StringBuilder spMappedUserRoles = new StringBuilder();
@@ -341,12 +341,7 @@ public class DefaultClaimHandler implements ClaimHandler {
spMappedUserRoles.append(remainingRole).append(claimSeparator);
}
- return spMappedUserRoles.length() > 0 ?
- spMappedUserRoles.toString().substring(0, spMappedUserRoles.length() - 1) :
- null;
- }
-
- return null;
+ return spMappedUserRoles.toString().substring(0, spMappedUserRoles.length() - 1);
}
/**
