Search in sources :

Example 16 with DefaultEventResult

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

the class SystemMappingDeleteProcessor method process.

@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
    SysSystemMappingDto systemMapping = event.getContent();
    // 
    if (configService.countBySystemMapping(systemMapping) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName()));
    }
    // 
    // remove all handled attributes
    SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
    filter.setSystemMappingId(systemMapping.getId());
    systemAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
        systemAttributeMappingService.delete(systemAttributeMapping);
    });
    // 
    // delete mapped roles
    SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
    roleSystemFilter.setSystemMappingId(systemMapping.getId());
    roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
        roleSystemService.delete(roleSystem);
    });
    // 
    systemMappingService.deleteInternal(systemMapping);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 17 with DefaultEventResult

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

the class SystemSaveProcessor method process.

@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
    SysSystemDto dto = event.getContent();
    // create default connector server
    if (dto.getConnectorServer() == null) {
        dto.setConnectorServer(new SysConnectorServerDto());
    }
    // create default connector key
    if (dto.getConnectorKey() == null) {
        dto.setConnectorKey(new SysConnectorKeyDto());
    }
    // create default blocked operations
    if (dto.getBlockedOperation() == null) {
        dto.setBlockedOperation(new SysBlockedOperationDto());
    }
    if (!service.isNew(dto)) {
        // Check if is connector changed
        SysSystemDto oldSystem = service.get(dto.getId());
        if (!dto.getConnectorKey().equals(oldSystem.getConnectorKey())) {
            // If is connector changed, we set virtual to false. (Virtual
            // connectors set this attribute on true by themselves)
            dto.setVirtual(false);
        }
        // check blocked provisioning operation and clear provisioning break cache
        clearProvisionignBreakCache(dto, oldSystem);
    }
    SysSystemDto newSystem = service.saveInternal(dto);
    event.setContent(newSystem);
    // save password from remote connector server to confidential storage
    if (dto.getConnectorServer().getPassword() != null) {
        // save for newSystem
        confidentialStorage.save(newSystem.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD, dto.getConnectorServer().getPassword().asString());
        // 
        // set asterix
        newSystem.getConnectorServer().setPassword(new GuardedString(GuardedString.SECRED_PROXY_STRING));
    }
    // TODO: clone content - mutable previous event content :/
    return new DefaultEventResult<>(event, this);
}
Also used : SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 18 with DefaultEventResult

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

the class IdentityContractProvisioningProcessor method process.

@Override
@SuppressWarnings("unchecked")
public EventResult<IdmIdentityContractDto> process(EntityEvent<IdmIdentityContractDto> event) {
    UUID identityId = event.getContent().getIdentity();
    // 
    // register change => provisioning will be executed for manager
    doProvisioning(identityId, event);
    // execute provisioning for all subordinates by given contract
    if (isIncludeSubordinates()) {
        Set<UUID> originalSubordinates = (Set<UUID>) event.getProperties().get(PROPERTY_PREVIOUS_SUBORDINATES);
        findAllSubordinates(identityId).forEach(subordinate -> {
            if (originalSubordinates != null && originalSubordinates.contains(subordinate.getId())) {
                originalSubordinates.remove(subordinate.getId());
            } else {
                // provisioning will be executed for new subordinate
                doProvisioning(subordinate, event);
            }
        });
        if (originalSubordinates != null) {
            originalSubordinates.forEach(originalSubordinateId -> {
                // provisioning will be executed for new subordinate
                doProvisioning(originalSubordinateId, event);
            });
        }
    }
    return new DefaultEventResult<>(event, this);
}
Also used : Set(java.util.Set) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) UUID(java.util.UUID)

Example 19 with DefaultEventResult

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

the class AbstractProvisioningProcessor method process.

/**
 * Prepare provisioning operation execution
 */
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    IcConnectorObject connectorObject = provisioningOperation.getProvisioningContext().getConnectorObject();
    IcObjectClass objectClass = connectorObject.getObjectClass();
    String uid = systemEntityService.getByProvisioningOperation(provisioningOperation).getUid();
    LOG.debug("Start provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), uid, objectClass.getType());
    // Find connector identification persisted in system
    if (system.getConnectorKey() == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // load connector configuration
    IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(systemService.get(provisioningOperation.getSystem()));
    if (connectorConfig == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // 
    try {
        provisioningOperation = provisioningOperationService.save(provisioningOperation);
        // convert confidential string to guarded strings before provisioning realization
        connectorObject = provisioningOperationService.getFullConnectorObject(provisioningOperation);
        provisioningOperation.getProvisioningContext().setConnectorObject(connectorObject);
        // 
        IcUidAttribute resultUid = processInternal(provisioningOperation, connectorConfig);
        // update system entity, when identifier on target system differs
        if (resultUid != null && resultUid.getUidValue() != null) {
            SysSystemEntityDto systemEntity = systemEntityService.getByProvisioningOperation(provisioningOperation);
            // If system entity was not found, we try found system entity by returned UID
            if (systemEntity == null) {
                systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, provisioningOperation.getEntityType(), resultUid.getUidValue());
            }
            Asserts.notNull(systemEntity, "Systeme entity cannot be null!");
            if (!systemEntity.getUid().equals(resultUid.getUidValue()) || systemEntity.isWish()) {
                systemEntity.setUid(resultUid.getUidValue());
                systemEntity.setWish(false);
                systemEntity = systemEntityService.save(systemEntity);
                LOG.info("UID was changed. System entity with uid [{}] was updated", systemEntity.getUid());
            }
        }
        provisioningOperationService.handleSuccessful(provisioningOperation);
    } catch (Exception ex) {
        provisioningOperationService.handleFailed(provisioningOperation, ex);
    }
    // set operation back to content
    event.setContent(provisioningOperation);
    return new DefaultEventResult<>(event, this);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException)

Example 20 with DefaultEventResult

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

the class DisabledSystemProcessor method process.

@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    boolean closed = false;
    if (system.isDisabled()) {
        ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_DISABLED, ImmutableMap.of("name", uid, "system", system.getName()));
        provisioningOperation.setResult(new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(resultModel).build());
        // 
        provisioningOperation = provisioningOperationService.save(provisioningOperation);
        // 
        LOG.info(resultModel.toString());
        notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
        // 
        closed = true;
    }
    // set back to event content
    event.setContent(provisioningOperation);
    return new DefaultEventResult<>(event, this, closed);
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

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