use of io.lumeer.api.model.RoleType in project engine by Lumeer.
the class PermissionsCheckerTest method testGetActualRolesIntersection.
@Test
public void testGetActualRolesIntersection() {
Resource resource = prepareResource(Sets.newLinkedHashSet(new Role(RoleType.Read), new Role(RoleType.DataWrite)), Sets.newLinkedHashSet(new Role(RoleType.UserConfig), new Role(RoleType.PerspectiveConfig)));
Set<RoleType> roles = permissionsChecker.getActualRoles(resource);
assertThat(roles).containsOnly(RoleType.Read, RoleType.DataWrite, RoleType.UserConfig, RoleType.PerspectiveConfig);
}
use of io.lumeer.api.model.RoleType in project engine by Lumeer.
the class PermissionsCheckerTest method testGetActualRolesGroupOnly.
@Test
public void testGetActualRolesGroupOnly() {
Resource resource = prepareResource(Collections.emptySet(), Sets.newLinkedHashSet(new Role(RoleType.Read), new Role(RoleType.UserConfig)));
Set<RoleType> roles = permissionsChecker.getActualRoles(resource);
assertThat(roles).containsOnly(RoleType.Read, RoleType.UserConfig);
}
use of io.lumeer.api.model.RoleType in project engine by Lumeer.
the class PermissionUtils method getUserRolesInLinkType.
public static Set<RoleType> getUserRolesInLinkType(Organization organization, @Nullable Project project, LinkType linkType, java.util.Collection<Collection> collections, User user, List<Group> groups) {
if (linkType.getPermissionsType() == LinkPermissionsType.Custom) {
return getUserRolesInResource(organization, project, ResourceType.LINK_TYPE, linkType.getPermissions(), user, getUserGroups(organization, user, groups));
}
var linkTypeCollections = collections.stream().filter(collection -> linkType.getCollectionIds().contains(collection.getId())).collect(Collectors.toList());
var canReadCollections = linkTypeCollections.size() == 2;
for (Collection collection : linkTypeCollections) {
canReadCollections = canReadCollections && hasRole(organization, project, collection, RoleType.Read, user, groups);
}
if (!canReadCollections) {
return Collections.emptySet();
}
var roles1 = getUserRolesInResource(organization, project, linkTypeCollections.get(0), user, groups);
var roles2 = getUserRolesInResource(organization, project, linkTypeCollections.get(1), user, groups);
roles1.retainAll(roles2);
return roles1;
}
use of io.lumeer.api.model.RoleType in project engine by Lumeer.
the class RoleCodec method convertFromDocument.
public static Role convertFromDocument(Document bson) {
RoleType type = RoleType.fromString(bson.getString(TYPE));
boolean transitive = bson.getBoolean(TRANSITIVE, false);
return new Role(type, transitive);
}
Aggregations