Search in sources :

Example 36 with IdmIdentityDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto 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)

Example 37 with IdmIdentityDto

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

the class AbstractWorkflowEventProcessor method processInstance.

/**
 * Execute wf - returns process instance
 *
 * @param variables
 * @return
 */
protected ProcessInstance processInstance(Map<String, Object> variables) {
    if (StringUtils.isEmpty(getWorkflowDefinitionKey())) {
        // wf is not configured
        return null;
    }
    // execute process
    AbstractAuthentication authentication = securityService.getAuthentication();
    IdmIdentityDto modifier = authentication == null ? null : authentication.getCurrentIdentity();
    return workflowService.startProcess(getWorkflowDefinitionKey(), modifier == null ? null : modifier.getClass().getSimpleName(), authentication == null ? null : authentication.getCurrentUsername(), modifier == null || modifier.getId() == null ? null : modifier.getId().toString(), variables);
}
Also used : AbstractAuthentication(eu.bcvsolutions.idm.core.security.api.domain.AbstractAuthentication) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 38 with IdmIdentityDto

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

the class IdentityContractExclusionProcessor method process.

/**
 * Check identity state after contract is excluded
 *
 * @param contract
 * @param skipRecalculation Skip automatic role recalculation
 * @return
 */
public OperationResult process(IdmIdentityContractDto contract, Boolean skipRecalculation) {
    IdmIdentityDto identity = identityService.get(contract.getIdentity());
    IdentityState newState = identityService.evaluateState(identity.getId());
    // 
    if (identity.getState() != newState) {
        LOG.info("Change identity [{}] state [{}]", identity.getUsername(), newState);
        // 
        identity.setState(newState);
        // is necessary publish new event with skip recalculation automatic roles
        IdentityEvent identityEvent = new IdentityEvent(IdentityEventType.UPDATE, identity);
        identityEvent.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, skipRecalculation);
        identityService.publish(identityEvent);
    }
    return new OperationResult.Builder(OperationState.EXECUTED).build();
}
Also used : IdentityEvent(eu.bcvsolutions.idm.core.model.event.IdentityEvent) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState)

Example 39 with IdmIdentityDto

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

the class IdentityContractSaveProcessor method process.

@Override
public EventResult<IdmIdentityContractDto> process(EntityEvent<IdmIdentityContractDto> event) {
    IdmIdentityContractDto contract = event.getContent();
    contract = service.saveInternal(contract);
    event.setContent(contract);
    // 
    // check identity state
    IdmIdentityContractDto previousContract = event.getOriginalSource();
    IdmIdentityDto identity = DtoUtils.getEmbedded(contract, IdmIdentityContract_.identity.getName(), IdmIdentityDto.class);
    if ((identity.getState() == IdentityState.CREATED || identity.isDisabled()) && contractChanged(previousContract, contract)) {
        // synchronize identity states, which has no effect on HR processes
        identity = identityService.get(contract.getIdentity());
        IdentityState newState = identityService.evaluateState(identity.getId());
        if (newState.isDisabled() && identity.getState() != newState) {
            identity.setState(newState);
            // publish new save event for identity with skip recalculation
            IdentityEvent identityEvent = new IdentityEvent(IdentityEventType.UPDATE, identity);
            identityEvent.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, true);
            identityService.publish(identityEvent);
        }
    }
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdentityEvent(eu.bcvsolutions.idm.core.model.event.IdentityEvent) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState)

Example 40 with IdmIdentityDto

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

the class AbstractIdentityPasswordProcessor method process.

@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
    IdmIdentityDto identity = event.getContent();
    PasswordChangeDto passwordChangeDto = (PasswordChangeDto) event.getProperties().get(PROPERTY_PASSWORD_CHANGE_DTO);
    Assert.notNull(passwordChangeDto);
    // 
    if (passwordChangeDto.isIdm()) {
        // change identity's password
        savePassword(identity, passwordChangeDto);
        Map<String, Object> parameters = new LinkedHashMap<>();
        parameters.put("account", new IdmAccountDto(identity.getId(), true, identity.getUsername()));
        return new DefaultEventResult.Builder<>(event, this).setResult(new OperationResult.Builder(OperationState.EXECUTED).setModel(new DefaultResultModel(CoreResultCode.PASSWORD_CHANGE_ACCOUNT_SUCCESS, parameters)).build()).build();
    }
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)568 Test (org.junit.Test)433 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)328 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)206 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)157 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)99 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)95 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)69 ArrayList (java.util.ArrayList)63 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)61 UUID (java.util.UUID)59 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)58 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)55 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)54 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)54 Transactional (org.springframework.transaction.annotation.Transactional)53 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)51 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)50 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)49 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)48