Search in sources :

Example 1 with IdmIdentityContractDto

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

the class IdentityRolePublishChangeProcessor method setAdditionalEventProperties.

@Override
protected EntityEvent<IdmIdentityRoleDto> setAdditionalEventProperties(EntityEvent<IdmIdentityRoleDto> event) {
    event = super.setAdditionalEventProperties(event);
    // we need to set super entity owner - identity roles should not be processed concurrently for given identity
    // TODO: can be removed, if account management can be executed concurrently for given identity
    IdmIdentityContractDto identityContract = DtoUtils.getEmbedded(event.getContent(), IdmIdentityRole_.identityContract, IdmIdentityContractDto.class, null);
    if (identityContract == null) {
        identityContract = (IdmIdentityContractDto) lookupService.lookupDto(IdmIdentityContractDto.class, event.getContent().getIdentityContract());
    }
    event.getProperties().put(EntityEventManager.EVENT_PROPERTY_SUPER_OWNER_ID, identityContract.getIdentity());
    // 
    return event;
}
Also used : IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 2 with IdmIdentityContractDto

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

the class DefaultIdmAutomaticRoleAttributeService method processAutomaticRolesForContract.

@Override
public void processAutomaticRolesForContract(UUID contractId, Set<AbstractIdmAutomaticRoleDto> passedAutomaticRoles, Set<AbstractIdmAutomaticRoleDto> notPassedAutomaticRoles) {
    // Assign new passed automatic roles (assign to default contract)
    IdmIdentityContractDto contract = identityContractService.get(contractId);
    // 
    if (contract == null) {
        LOG.debug(MessageFormat.format("Contract id [{0}] not found.", contractId));
        return;
    }
    // TODO: this behavior can be optimalized by add it into query
    if (!contract.isValidNowOrInFuture() || contract.getState() == ContractState.DISABLED) {
        // null all new passed automatic roles
        passedAutomaticRoles = null;
    }
    // 
    // find all automatic roles for identity
    IdmIdentityRoleFilter roleIdentityFilter = new IdmIdentityRoleFilter();
    roleIdentityFilter.setIdentityContractId(contractId);
    roleIdentityFilter.setAutomaticRole(Boolean.TRUE);
    // 
    if (passedAutomaticRoles != null && !passedAutomaticRoles.isEmpty()) {
        this.addAutomaticRoles(contract, passedAutomaticRoles);
    }
    // 
    if (notPassedAutomaticRoles != null && !notPassedAutomaticRoles.isEmpty()) {
        this.removeAutomaticRoles(contract.getId(), notPassedAutomaticRoles);
    }
}
Also used : IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 3 with IdmIdentityContractDto

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

the class IdmIdentityContractController method saveFormValues.

/**
 * Saves entity's form values
 *
 * @param backendId
 * @param formValues
 * @return
 */
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.IDENTITYCONTRACT_UPDATE + "')")
@RequestMapping(value = "/{backendId}/form-values", method = RequestMethod.POST)
@ApiOperation(value = "Identity contract form definition - save values", nickname = "postIdentityContractFormValues", tags = { IdmIdentityContractController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITYCONTRACT_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITYCONTRACT_UPDATE, description = "") }) })
public Resource<?> saveFormValues(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Code of form definition (default will be used if no code is given).", required = false, defaultValue = FormService.DEFAULT_DEFINITION_CODE) @RequestParam(name = "definitionCode", required = false) String definitionCode, @ApiParam(value = "Filled form data.", required = true) @RequestBody @Valid List<IdmFormValueDto> formValues) {
    IdmIdentityContractDto dto = getDto(backendId);
    if (dto == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    // 
    checkAccess(dto, IdmBasePermission.UPDATE);
    // 
    IdmFormDefinitionDto formDefinition = formDefinitionController.getDefinition(IdmIdentityContract.class, definitionCode);
    // 
    return formDefinitionController.saveFormValues(dto, formDefinition, formValues);
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) 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 4 with IdmIdentityContractDto

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

the class ProcessAllAutomaticRoleByAttributeTaskExecutor method processAutomaticRoleForContract.

/**
 * Start recalculation for automatic role
 *
 * @param automaticRolAttributeDto
 */
private void processAutomaticRoleForContract(IdmAutomaticRoleAttributeDto automaticRolAttributeDto) {
    UUID automaticRoleId = automaticRolAttributeDto.getId();
    Set<AbstractIdmAutomaticRoleDto> automaticRoleSet = new HashSet<AbstractIdmAutomaticRoleDto>();
    automaticRoleSet.add(automaticRolAttributeDto);
    // 
    // process contracts
    Page<UUID> newPassedContracts = automaticRoleAttributeService.getContractsForAutomaticRole(automaticRoleId, true, new PageRequest(0, DEFAULT_PAGE_SIZE_PAGE_SIZE_IDENTITIES));
    Page<UUID> newNotPassedContracts = automaticRoleAttributeService.getContractsForAutomaticRole(automaticRoleId, false, new PageRequest(0, DEFAULT_PAGE_SIZE_PAGE_SIZE_IDENTITIES));
    // 
    boolean canContinue = true;
    while (canContinue) {
        for (UUID contractId : newPassedContracts) {
            IdmIdentityContractDto contract = identityContractService.get(contractId);
            // check for contract validity
            if (contract.getState() == ContractState.DISABLED || !contract.isValidNowOrInFuture()) {
                continue;
            }
            // 
            automaticRoleAttributeService.addAutomaticRoles(contract, automaticRoleSet);
            canContinue = updateState();
            if (!canContinue) {
                break;
            }
        }
        if (newPassedContracts.hasNext()) {
            newPassedContracts = automaticRoleAttributeService.getContractsForAutomaticRole(automaticRoleId, true, newPassedContracts.nextPageable());
        } else {
            break;
        }
    }
    // 
    while (canContinue) {
        for (UUID contractId : newNotPassedContracts) {
            IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
            filter.setIdentityContractId(contractId);
            filter.setAutomaticRoleId(automaticRoleId);
            List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(filter, null).getContent();
            for (IdmIdentityRoleDto identityRole : identityRoles) {
                automaticRoleAttributeService.removeAutomaticRoles(identityRole);
            }
            canContinue = updateState();
            if (!canContinue) {
                break;
            }
        }
        if (newNotPassedContracts.hasNext()) {
            newNotPassedContracts = automaticRoleAttributeService.getContractsForAutomaticRole(automaticRoleId, false, newNotPassedContracts.nextPageable());
        } else {
            break;
        }
    }
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) UUID(java.util.UUID) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) HashSet(java.util.HashSet)

Example 5 with IdmIdentityContractDto

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

the class IdentityRoleSaveProvisioningProcessor method process.

@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
    IdmIdentityRoleDto identityRole = event.getContent();
    IdmIdentityContractDto identityContract = identityContractService.get(identityRole.getIdentityContract());
    IdmIdentityDto identity = DtoUtils.getEmbedded(identityContract, IdmIdentityContract_.identity, IdmIdentityDto.class);
    // 
    // TODO: full account management should be moved into NOTIFY on identity => super owner id can be removed then in IdentityRolePublishChangeProcessor
    // all identity roles are processed now => doesn't support concurrency - duplicate accounts can be created now (ux constraint ex. is thrown)
    LOG.debug("Call account management for identity [{}]", identity.getUsername());
    provisioningService.accountManagement(identity);
    LOG.debug("Register change for identity [{}]", identity.getUsername());
    entityEventManager.changedEntity(identity, event);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Aggregations

IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)220 Test (org.junit.Test)170 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)156 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)92 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)91 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)53 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)48 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)45 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)36 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)35 LocalDate (org.joda.time.LocalDate)34 ArrayList (java.util.ArrayList)31 List (java.util.List)29 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)28 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)24 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)24 Transactional (org.springframework.transaction.annotation.Transactional)24 UUID (java.util.UUID)19 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)18