Search in sources :

Example 16 with SysSystemEntityDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemEntityServiceFilterTest method createEntitySystem.

/**
 * Create {@link SysSystemEntityDto}
 * @param uid
 * @param type
 * @param systemId
 * @param id
 * @return
 */
private SysSystemEntityDto createEntitySystem(String uid, SystemEntityType type, UUID systemId, UUID id) {
    SysSystemEntityDto entity = new SysSystemEntityDto();
    entity.setUid(uid);
    entity.setEntityType(type);
    entity.setSystem(systemId);
    entity.setId(id);
    entityService.save(entity);
    return entity;
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 17 with SysSystemEntityDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemEntityServiceFilterTest method testUid.

@Test
public void testUid() {
    SysSystemDto system = helper.createTestResourceSystem(false);
    SysSystemEntityDto entity1 = createEntitySystem("test1-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    createEntitySystem("test2-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    createEntitySystem("test3-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    // 
    SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
    testFilter.setUid(entity1.getUid());
    Page<SysSystemEntityDto> pages = entityService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(entity1.getId(), pages.getContent().get(0).getId());
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 18 with SysSystemEntityDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.

the class SysProvisioningOperationFilterIntegrationTest method createProvisioningOperation.

private SysProvisioningOperationDto createProvisioningOperation(SystemEntityType type, SysSystemDto system) {
    SysProvisioningOperationDto provisioningOperation = new SysProvisioningOperationDto();
    provisioningOperation.setEntityType(type);
    provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
    provisioningOperation.setProvisioningContext(new ProvisioningContext());
    provisioningOperation.setSystem(system.getId());
    provisioningOperation.setEntityIdentifier(UUID.randomUUID());
    SysSystemEntityDto systemEntity = ((TestHelper) getHelper()).createSystemEntity(system);
    provisioningOperation.setSystemEntity(systemEntity.getId());
    OperationResult result = new OperationResult();
    result.setState(OperationState.RUNNING);
    provisioningOperation.setResult(result);
    return operationService.save(provisioningOperation);
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 19 with SysSystemEntityDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto 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();
    SysSystemEntityDto systemEntity = systemEntityService.getByProvisioningOperation(provisioningOperation);
    // If exists password in attributes and system support password filter set also echo
    boolean processEcho = false;
    List<UUID> accountIds = null;
    LOG.debug("Start provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), systemEntity.getUid(), 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 from connectorType.
    ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(system);
    IcConnectorConfiguration connectorConfig = connectorType.getConnectorConfiguration(system);
    // 
    try {
        provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
        // convert confidential string to guarded strings before provisioning realization
        connectorObject = provisioningOperationService.getFullConnectorObject(provisioningOperation);
        provisioningOperation.getProvisioningContext().setConnectorObject(connectorObject);
        for (IcAttribute attribute : connectorObject.getAttributes()) {
            if (attribute.getName().equals(ProvisioningService.PASSWORD_SCHEMA_PROPERTY_NAME) && attribute instanceof IcPasswordAttribute) {
                if (this.hasSystemPasswordFilter(system)) {
                    IcPasswordAttributeImpl password = ((IcPasswordAttributeImpl) attribute);
                    accountIds = getAccounts(system.getId(), systemEntity.getId());
                    for (UUID accountId : accountIds) {
                        passwordFilterManager.setEchoForChange(accountId, password.getPasswordValue());
                    }
                    processEcho = true;
                }
                break;
            }
        }
        // 
        IcUidAttribute resultUid = processInternal(provisioningOperation, connectorConfig);
        // update system entity, when identifier on target system differs
        if (resultUid != null && resultUid.getUidValue() != 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());
            }
        } else {
            // e.g. update doesn't return
            if (systemEntity.isWish()) {
                systemEntity.setWish(false);
                systemEntity = systemEntityService.save(systemEntity);
                LOG.info("UID was changed. System entity with uid [{}] was updated", systemEntity.getUid());
            }
        }
        provisioningOperation = provisioningOperationService.handleSuccessful(provisioningOperation);
    } catch (Exception ex) {
        provisioningOperation = provisioningOperationService.handleFailed(provisioningOperation, ex);
        if (processEcho) {
            // Clear echo record about password change
            accountIds.forEach(accountId -> {
                passwordFilterManager.clearChangedEcho(accountId);
            });
        }
    }
    // set operation back to content
    event.setContent(provisioningOperation);
    return new DefaultEventResult<>(event, this);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) Autowired(org.springframework.beans.factory.annotation.Autowired) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) Enabled(eu.bcvsolutions.idm.core.security.api.domain.Enabled) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) ArrayList(java.util.ArrayList) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) PasswordFilterManager(eu.bcvsolutions.idm.acc.service.api.PasswordFilterManager) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) Map(java.util.Map) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) AbstractEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AbstractEntityEventProcessor) ImmutableMap(com.google.common.collect.ImmutableMap) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) Set(java.util.Set) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) UUID(java.util.UUID) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) ConnectorManager(eu.bcvsolutions.idm.acc.service.api.ConnectorManager) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) Optional(java.util.Optional) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert(org.springframework.util.Assert) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IcPasswordAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcPasswordAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) UUID(java.util.UUID) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 20 with SysSystemEntityDto

use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.

the class ProvisioningBreakProcessor method process.

@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    ProvisioningEventType operationType = provisioningOperation.getOperationType();
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    try {
        // system may be blocked
        boolean blocked = isSystemBlockedOperation(operationType, system);
        // 
        if (blocked) {
            // system is already blocked
            provisioningOperation = blockOperation(provisioningOperation, system);
            event.setContent(provisioningOperation);
            return new DefaultEventResult<>(event, this, blocked);
        }
        // 
        // try found provisioning break configuration
        SysProvisioningBreakConfigDto breakConfig = breakConfigService.getConfig(operationType, system.getId());
        if (breakConfig == null) {
            LOG.debug("Provisioning break configuration for system name: [{}] and operation: [{}] not found. Global configuration will be used.", system.getCode(), operationType.toString());
            breakConfig = breakConfigService.getGlobalBreakConfiguration(operationType);
        }
        // 
        if (breakConfig == null) {
            LOG.debug("Global configuration for provisioning break isn't found.");
            return new DefaultEventResult<>(event, this, blocked);
        }
        // 
        if (breakConfig.isDisabled()) {
            LOG.debug("Provisioning break configuration id: [{}] for system name: [{}] and operation: [{}] is disabled.", breakConfig.getId(), system.getCode(), operationType.toString());
            // break configuration is disable continue
            return new DefaultEventResult<>(event, this, blocked);
        }
        // Process provisioning break in synchronized method
        blocked = processProvisioningBreak(provisioningOperation, operationType, system, breakConfig);
        event.setContent(provisioningOperation);
        return new DefaultEventResult<>(event, this, blocked);
    } catch (Exception ex) {
        SysSystemEntityDto systemEntityDto = provisioningOperationService.getByProvisioningOperation(provisioningOperation);
        LOG.error("Unexpect error while evaluate provisioning break.", ex);
        throw new ProvisioningException(AccResultCode.PROVISIONING_FAILED, ImmutableMap.of("name", systemEntityDto.getUid(), "system", system.getName(), "operationType", operationType, "objectClass", provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass().getType()), ex);
    }
}
Also used : ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) 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)

Aggregations

SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)69 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)49 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)36 Test (org.junit.Test)36 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)25 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)22 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)19 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)15 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)14 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)14 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)13 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)12 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)12 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)11 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)10 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)10 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)10 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)8 SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)8