fix role mapping

This commit is contained in:
Hugo Renard 2022-04-22 17:17:05 +02:00
parent 67084d699a
commit a0958f728d
Signed by: hougo
GPG key ID: 3A285FD470209C59

View file

@ -100,26 +100,15 @@ public class UserAdapter extends Adapter<UserModel, UserResource> {
user.getGroupsStream().flatMap(g -> g.getRoleMappingsStream()) user.getGroupsStream().flatMap(g -> g.getRoleMappingsStream())
.filter((r) -> r.getFirstAttribute("scim").equals("true")).map((r) -> r.getName()) .filter((r) -> r.getFirstAttribute("scim").equals("true")).map((r) -> r.getName())
.forEach(r -> rolesSet.add(r)); .forEach(r -> rolesSet.add(r));
// Bug when new user.
try {
var roleStream = user.getRoleMappingsStream();
if (rolesSet == null) {
LOGGER.error("role stream is null");
}
roleStream.filter((r) -> {
var attr = r.getFirstAttribute("scim");
if (attr == null) {
LOGGER.debug("attribute is null");
return false;
}
return attr.equals("true");
}).map((r) -> r.getName()).forEach(r -> rolesSet.add(r));
// user.getRoleMappingsStream().filter((r) -> r.getFirstAttribute("scim").equals("true")) user.getRoleMappingsStream().filter((r) -> {
// .map((r) -> r.getName()).forEach(r -> rolesSet.add(r)); var attr = r.getFirstAttribute("scim");
} catch (Exception e) { if (attr == null) {
LOGGER.error(e); return false;
} }
return attr.equals("true");
}).map((r) -> r.getName()).forEach(r -> rolesSet.add(r));
var roles = new String[rolesSet.size()]; var roles = new String[rolesSet.size()];
rolesSet.toArray(roles); rolesSet.toArray(roles);
setRoles(roles); setRoles(roles);