Search in sources :

Example 11 with IdmRoleTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method saveAutomaticRole.

/**
 * Save automatic role with repository and manual create and wait for task
 * @param automaticRole
 * @return
 */
private IdmRoleTreeNodeDto saveAutomaticRole(IdmRoleTreeNodeDto automaticRole, boolean withLongRunningTask) {
    // default name
    automaticRole.setName("default");
    IdmRoleTreeNodeDto roleTreeNode = roleTreeNodeService.saveInternal(automaticRole);
    // 
    if (withLongRunningTask) {
        AddNewAutomaticRoleTaskExecutor task = new AddNewAutomaticRoleTaskExecutor();
        task.setAutomaticRoleId(roleTreeNode.getId());
        taskManager.executeSync(task);
    }
    // 
    return roleTreeNodeService.get(roleTreeNode.getId());
}
Also used : AddNewAutomaticRoleTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.AddNewAutomaticRoleTaskExecutor) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)

Example 12 with IdmRoleTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method prepareAutomaticRoles.

/**
 */
private void prepareAutomaticRoles() {
    // prepare automatic roles
    automaticRoleA = new IdmRoleTreeNodeDto();
    automaticRoleA.setRecursionType(RecursionType.DOWN);
    automaticRoleA.setRole(roleA.getId());
    automaticRoleA.setTreeNode(nodeA.getId());
    automaticRoleA = saveAutomaticRole(automaticRoleA, false);
    automaticRoleD = new IdmRoleTreeNodeDto();
    automaticRoleD.setRecursionType(RecursionType.DOWN);
    automaticRoleD.setRole(roleB.getId());
    automaticRoleD.setTreeNode(nodeD.getId());
    automaticRoleD = saveAutomaticRole(automaticRoleD, false);
    automaticRoleF = new IdmRoleTreeNodeDto();
    automaticRoleF.setRecursionType(RecursionType.UP);
    automaticRoleF.setRole(roleC.getId());
    automaticRoleF.setTreeNode(nodeF.getId());
    automaticRoleF = saveAutomaticRole(automaticRoleF, false);
    automaticRoleE = new IdmRoleTreeNodeDto();
    automaticRoleE.setRecursionType(RecursionType.NO);
    automaticRoleE.setRole(roleD.getId());
    automaticRoleE.setTreeNode(nodeE.getId());
    automaticRoleE = saveAutomaticRole(automaticRoleE, false);
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)

Example 13 with IdmRoleTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleForContractValidInTheFuture.

@Test
public void testAssingRoleForContractValidInTheFuture() {
    IdmIdentityDto identity = helper.createIdentity();
    // 
    IdmIdentityContractDto contractD = new IdmIdentityContractDto();
    contractD.setIdentity(identity.getId());
    contractD.setWorkPosition(nodeD.getId());
    contractD.setValidFrom(new LocalDate().plusDays(1));
    contractD = service.save(contractD);
    // 
    // create new automatic role
    automaticRoleD = new IdmRoleTreeNodeDto();
    automaticRoleD.setRecursionType(RecursionType.NO);
    automaticRoleD.setRole(roleA.getId());
    automaticRoleD.setTreeNode(nodeD.getId());
    automaticRoleD = saveAutomaticRole(automaticRoleD, true);
    // 
    // check
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
    assertEquals(1, identityRoles.size());
    assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 14 with IdmRoleTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.

the class IdmRoleTreeNodeController method delete.

@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLETREENODE_DELETE + "')")
@ApiOperation(value = "Delete automatic role. Uses request!", nickname = "deleteRoleTreeNode", tags = { IdmRoleTreeNodeController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_DELETE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_DELETE, description = "") }) })
public ResponseEntity<?> delete(@ApiParam(value = "Automatic role's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
    IdmRoleTreeNodeDto automaticRole = this.getDto(backendId);
    Assert.notNull(automaticRole);
    requestService.deleteAutomaticRole(automaticRole, AutomaticRoleRequestType.TREE);
    throw new AcceptedException();
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with IdmRoleTreeNodeDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.

the class IdmRoleTreeNodeController method post.

@Override
@ResponseBody
@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLETREENODE_CREATE + "')" + " or hasAuthority('" + CoreGroupPermission.ROLETREENODE_UPDATE + "')")
@ApiOperation(value = "Create / update automatic role", nickname = "postRoleTreeNode", response = IdmRoleTreeNodeDto.class, tags = { IdmRoleTreeNodeController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_UPDATE, description = "") }) }, notes = "If role has guarantee assigned, then automatic role has to be approved by him at first (configurable by entity event processor).")
public ResponseEntity<?> post(@Valid @RequestBody IdmRoleTreeNodeDto dto) {
    Assert.notNull(dto);
    IdmRoleTreeNodeDto result = requestService.createTreeAutomaticRole(dto);
    if (result == null) {
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    return new ResponseEntity<>(toResource(result), HttpStatus.CREATED);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)29 Test (org.junit.Test)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)9 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)7 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)6 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)6 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)6 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)6 UUID (java.util.UUID)6 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)5 IdmAutomaticRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto)5 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)3 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 RoleRequestException (eu.bcvsolutions.idm.core.api.exception.RoleRequestException)3 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)2 ApiOperation (io.swagger.annotations.ApiOperation)2 LocalDate (org.joda.time.LocalDate)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2