Search in sources :

Example 41 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class VsRequestRealizationProcessor method process.

@Override
public EventResult<VsRequestDto> process(EntityEvent<VsRequestDto> event) {
    VsRequestDto dto = event.getContent();
    // 
    dto = service.createRequest(dto);
    IcUidAttribute uid = service.internalStart(dto);
    event.getProperties().put(VsRequestRealizationProcessor.RESULT_UID, uid);
    event.setContent(dto);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto)

Example 42 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class AccountDeleteProcessor method process.

@Override
public EventResult<AccAccountDto> process(EntityEvent<AccAccountDto> event) {
    AccAccountDto account = event.getContent();
    UUID entityId = null;
    Object entityIdObj = event.getProperties().get(AccAccountService.ENTITY_ID_PROPERTY);
    if (entityIdObj instanceof UUID) {
        entityId = (UUID) entityIdObj;
    }
    boolean deleteTargetAccount = false;
    Object deleteTargetAccountObj = event.getProperties().get(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY);
    if (deleteTargetAccountObj instanceof Boolean) {
        deleteTargetAccount = (boolean) deleteTargetAccountObj;
    }
    Assert.notNull(account, "Account cannot be null!");
    // We do not allow delete account in protection
    if (account.isAccountProtectedAndValid()) {
        throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_BE_DELETED_IS_PROTECTED, ImmutableMap.of("uid", account.getUid()));
    }
    // delete all identity accounts
    AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
    identityAccountFilter.setAccountId(account.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
    identityAccounts.forEach(identityAccount -> {
        identityAccountService.delete(identityAccount);
    });
    // delete all role accounts
    AccRoleAccountFilter roleAccountFilter = new AccRoleAccountFilter();
    roleAccountFilter.setAccountId(account.getId());
    List<AccRoleAccountDto> roleAccounts = roleAccountService.find(roleAccountFilter, null).getContent();
    roleAccounts.forEach(roleAccount -> {
        roleAccountService.delete(roleAccount);
    });
    // delete all roleCatalogue accounts
    AccRoleCatalogueAccountFilter roleCatalogueAccountFilter = new AccRoleCatalogueAccountFilter();
    roleCatalogueAccountFilter.setAccountId(account.getId());
    List<AccRoleCatalogueAccountDto> roleCatalogueAccounts = roleCatalogueAccountService.find(roleCatalogueAccountFilter, null).getContent();
    roleCatalogueAccounts.forEach(roleCatalogueAccount -> {
        roleCatalogueAccountService.delete(roleCatalogueAccount);
    });
    // delete all tree accounts
    AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
    treeAccountFilter.setAccountId(account.getId());
    List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
    treeAccounts.forEach(treeAccount -> {
        treeAccountService.delete(treeAccount);
    });
    // delete all contract accounts
    AccContractAccountFilter contractAccountFilter = new AccContractAccountFilter();
    contractAccountFilter.setAccountId(account.getId());
    List<AccContractAccountDto> contractAccounts = contractAccountService.find(contractAccountFilter, null).getContent();
    contractAccounts.forEach(contractAccount -> {
        contractAccountService.delete(contractAccount);
    });
    // 
    AccAccountDto refreshAccount = accountService.get(account.getId());
    // If account still exists (was not deleted by entity-account), we delete him directly now
    if (refreshAccount != null) {
        accountService.deleteInternal(refreshAccount);
    }
    if (deleteTargetAccount) {
        if (SystemEntityType.CONTRACT == account.getEntityType()) {
            LOG.warn(MessageFormat.format("Provisioning is not supported for contract now [{0}]!", account.getUid()));
            return new DefaultEventResult<>(event, this);
        }
        this.provisioningService.doDeleteProvisioning(account, account.getEntityType(), entityId);
    }
    return new DefaultEventResult<>(event, this);
}
Also used : AccRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccRoleAccountFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AccContractAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccContractAccountFilter) AccContractAccountDto(eu.bcvsolutions.idm.acc.dto.AccContractAccountDto) AccTreeAccountDto(eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto) AccRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto) AccTreeAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AccRoleCatalogueAccountDto(eu.bcvsolutions.idm.acc.dto.AccRoleCatalogueAccountDto) UUID(java.util.UUID) AccRoleCatalogueAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccRoleCatalogueAccountFilter)

Example 43 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class IdentityAccountSaveProcessor method process.

@Override
public EventResult<AccIdentityAccountDto> process(EntityEvent<AccIdentityAccountDto> event) {
    AccIdentityAccountDto entity = event.getContent();
    UUID account = entity.getAccount();
    AccAccountDto accountEntity = accountService.get(account);
    Assert.notNull(account, "Account cannot be null!");
    // identity-account
    if (service.isNew(entity) && entity.isOwnership() && accountEntity.isInProtection()) {
        AccIdentityAccountDto protectedIdentityAccount = findProtectedIdentityAccount(account);
        // First we save new identity-account
        event.setContent(service.saveInternal(entity));
        // Second we delete protected identity-account
        service.delete(protectedIdentityAccount);
        // Next we set account to unprotected state
        this.deactivateProtection(accountEntity);
        accountEntity = accountService.save(accountEntity);
        return new DefaultEventResult<>(event, this);
    }
    event.setContent(service.saveInternal(entity));
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) UUID(java.util.UUID) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Example 44 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class IdentityContractDeleteProcessor method process.

@Override
public EventResult<IdmIdentityContractDto> process(EntityEvent<IdmIdentityContractDto> event) {
    // delete relations on account (includes delete of account	)
    AccContractAccountFilter filter = new AccContractAccountFilter();
    filter.setEntityId(event.getContent().getId());
    entityAccountService.find(filter, null).forEach(entityAccount -> {
        LOG.debug("Remove contract-account for account [{}]", entityAccount.getId());
        entityAccountService.delete(entityAccount);
    });
    return new DefaultEventResult<>(event, this);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) AccContractAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccContractAccountFilter)

Example 45 with DefaultEventResult

use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.

the class IdentityDeleteProcessor method process.

@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
    IdmIdentityDto identity = event.getContent();
    Assert.notNull(identity);
    Assert.notNull(identity.getId());
    syncConfigRepository.clearDefaultLeader(identity.getId());
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    identityAccountService.find(filter, null).forEach(identityAccount -> {
        identityAccountService.forceDelete(identityAccount);
    });
    // 
    // remove all recipients from provisioning break
    deleteProvisioningRecipients(identity.getId());
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Aggregations

DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)91 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)11 UUID (java.util.UUID)11 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)10 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)7 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)7 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)6 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)5 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)5 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)5 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)5 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)5 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)4 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)4 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)4 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 ArrayList (java.util.ArrayList)4