use of org.molgenis.data.security.auth.UserMetaData.USER in project molgenis by molgenis.
the class PermissionManagerController method toPluginPermissions.
private Permissions toPluginPermissions(List<Plugin> plugins, Map<ObjectIdentity, Acl> aclMap, Sid sid) {
Permissions permissions = new Permissions();
// set permissions: entity ids
Map<String, String> pluginMap = plugins.stream().collect(toMap(Plugin::getId, Plugin::getId, (u, v) -> {
throw new IllegalStateException(format("Duplicate key %s", u));
}, LinkedHashMap::new));
permissions.setEntityIds(pluginMap);
// set permissions: user of group id
boolean isUser = setUserOrGroup(sid, permissions);
// set permissions: permissions
aclMap.forEach((objectIdentity, acl) -> {
String pluginId = objectIdentity.getIdentifier().toString();
acl.getEntries().forEach(ace -> {
if (ace.getSid().equals(sid)) {
org.molgenis.security.permission.Permission pluginPermission = toPluginPermission(ace);
if (isUser) {
permissions.addUserPermission(pluginId, pluginPermission);
} else {
permissions.addGroupPermission(pluginId, pluginPermission);
}
}
});
});
return permissions;
}
Aggregations