Search in sources :

Example 1 with PermissionGrantVO

use of com.epam.pipeline.controller.vo.PermissionGrantVO in project cloud-pipeline by epam.

the class FolderTemplateManager method createFolderFromTemplate.

void createFolderFromTemplate(Folder folder, FolderTemplate template) {
    folder.setName(template.getName());
    Folder savedFolder = crudManager.create(folder);
    if (CollectionUtils.isNotEmpty(template.getDatastorages())) {
        template.getDatastorages().forEach(storage -> {
            storage.setParentFolderId(savedFolder.getId());
            AbstractDataStorage created = dataStorageManager.create(storage, true, true, false);
            if (!MapUtils.isEmpty(storage.getMetadata())) {
                updateMetadata(storage.getMetadata(), new EntityVO(created.getId(), AclClass.DATA_STORAGE));
            }
        });
    }
    if (!MapUtils.isEmpty(template.getMetadata())) {
        updateMetadata(template.getMetadata(), new EntityVO(savedFolder.getId(), AclClass.FOLDER));
    }
    if (CollectionUtils.isNotEmpty(template.getChildren())) {
        template.getChildren().forEach(child -> {
            Folder childFolder = new Folder();
            childFolder.setParentId(folder.getId());
            createFolderFromTemplate(childFolder, child);
        });
    }
    if (CollectionUtils.isNotEmpty(template.getPermissions())) {
        template.getPermissions().forEach(permission -> {
            PermissionGrantVO permissionGrantVO = permissionGrantVOMapper.toPermissionGrantVO(permission);
            permissionGrantVO.setId(savedFolder.getId());
            permissionGrantVO.setAclClass(AclClass.FOLDER);
            permissionManager.setPermissions(permissionGrantVO);
        });
    }
}
Also used : PermissionGrantVO(com.epam.pipeline.controller.vo.PermissionGrantVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 2 with PermissionGrantVO

use of com.epam.pipeline.controller.vo.PermissionGrantVO in project cloud-pipeline by epam.

the class PipelineWithPermissionsTest method grantPermissions.

private void grantPermissions(Integer mask, String user, AclClass aclClass, Long entityId) {
    PermissionGrantVO grantVO = new PermissionGrantVO();
    grantVO.setAclClass(aclClass);
    grantVO.setId(entityId);
    grantVO.setMask(mask);
    grantVO.setPrincipal(true);
    grantVO.setUserName(user);
    permissionManager.setPermissions(grantVO);
}
Also used : PermissionGrantVO(com.epam.pipeline.controller.vo.PermissionGrantVO)

Example 3 with PermissionGrantVO

use of com.epam.pipeline.controller.vo.PermissionGrantVO in project cloud-pipeline by epam.

the class ToolGroupManager method makePrivate.

private void makePrivate(ToolGroup group) {
    PermissionGrantVO grantVO = new PermissionGrantVO();
    grantVO.setUserName("ROLE_USER");
    grantVO.setPrincipal(false);
    grantVO.setMask(AclPermission.ALL_DENYING_PERMISSIONS.getMask());
    grantVO.setAclClass(AclClass.TOOL_GROUP);
    grantVO.setId(group.getId());
    grantPermissionManager.setPermissions(grantVO);
}
Also used : PermissionGrantVO(com.epam.pipeline.controller.vo.PermissionGrantVO)

Example 4 with PermissionGrantVO

use of com.epam.pipeline.controller.vo.PermissionGrantVO in project cloud-pipeline by epam.

the class ToolApiServiceTest method setUp.

@Before
public void setUp() {
    TestUtils.configureDockerClientMock(dockerClient, clientFactory);
    registry = new DockerRegistry();
    registry.setPath(TEST_REPO);
    registry.setOwner(TEST_USER);
    registryDao.createDockerRegistry(registry);
    // Create SID for "test" user
    testUserSid = new AclTestDao.AclSid(true, TEST_USER);
    aclTestDao.createAclSid(testUserSid);
    AclTestDao.AclClass registryAclClass = new AclTestDao.AclClass(DockerRegistry.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(registryAclClass);
    AclTestDao.AclObjectIdentity registryIdentity = new AclTestDao.AclObjectIdentity(testUserSid, registry.getId(), registryAclClass.getId(), null, true);
    aclTestDao.createObjectIdentity(registryIdentity);
    AclTestDao.AclEntry registryAclEntry = new AclTestDao.AclEntry(registryIdentity, 1, testUserSid, AclPermission.WRITE.getMask(), true);
    aclTestDao.createAclEntry(registryAclEntry);
    allowedGroup = new ToolGroup();
    allowedGroup.setRegistryId(registry.getId());
    allowedGroup.setName(TEST_GROUP_NAME);
    toolGroupManager.create(allowedGroup);
    PermissionGrantVO grantVO = new PermissionGrantVO();
    grantVO.setAclClass(AclClass.TOOL_GROUP);
    grantVO.setId(allowedGroup.getId());
    grantVO.setMask(AclPermission.WRITE.getMask());
    grantVO.setPrincipal(true);
    grantVO.setUserName(TEST_USER);
    grantPermissionManager.setPermissions(grantVO);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) PermissionGrantVO(com.epam.pipeline.controller.vo.PermissionGrantVO) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) AclTestDao(com.epam.pipeline.dao.util.AclTestDao) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Before(org.junit.Before)

Aggregations

PermissionGrantVO (com.epam.pipeline.controller.vo.PermissionGrantVO)4 EntityVO (com.epam.pipeline.controller.vo.EntityVO)1 AclTestDao (com.epam.pipeline.dao.util.AclTestDao)1 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)1 DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)1 Folder (com.epam.pipeline.entity.pipeline.Folder)1 ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)1 AclClass (com.epam.pipeline.entity.security.acl.AclClass)1 Before (org.junit.Before)1