Search in sources :

Example 36 with SysSystemEntityDto

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

the class DefaultAccTestHelper method createSystemEntity.

@Override
public SysSystemEntityDto createSystemEntity(SysSystemDto system) {
    SysSystemEntityDto systemEntity = new SysSystemEntityDto(createName(), SystemEntityType.IDENTITY);
    systemEntity.setSystem(system.getId());
    systemEntity.setWish(true);
    return systemEntityService.save(systemEntity);
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 37 with SysSystemEntityDto

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

the class RoleSynchronizationExecutor method assignMissingIdentityRoles.

/**
 * Assign missing identity roles.
 */
private void assignMissingIdentityRoles(IdmRoleDto roleDto, SysSyncRoleConfigDto config, SysSyncItemLogDto logItem, List<IdmIdentityRoleDto> existsIdentityRoleDtos, Set<UUID> membersContractIds, SysSystemDto userSystemDto, int[] count, String uid, SynchronizationContext context) {
    // On every 20th item will be hibernate flushed and check if sync was not ended.
    if (count[0] % 20 == 0 && count[0] > 0) {
        if (!checkForCancelAndFlush(config)) {
            return;
        }
    }
    count[0]++;
    // Need to find account using SysSystemEntityDto uid, because uid of AccAccountDto can be different.
    SysSystemEntityFilter entityFilter = new SysSystemEntityFilter();
    entityFilter.setEntityType(SystemEntityType.IDENTITY);
    entityFilter.setSystemId(userSystemDto.getId());
    entityFilter.setUid(uid);
    SysSystemEntityDto systemEntity = systemEntityService.find(entityFilter, null).stream().findFirst().orElse(null);
    if (systemEntity == null) {
        return;
    }
    AccAccountFilter accAccountFilter = new AccAccountFilter();
    accAccountFilter.setSystemEntityId(systemEntity.getId());
    final UUID accAccountId = accountService.findIds(accAccountFilter, null).stream().findFirst().orElse(null);
    if (accAccountId == null) {
        return;
    }
    AccIdentityAccountFilter identityAccountWithoutRelationFilter = new AccIdentityAccountFilter();
    identityAccountWithoutRelationFilter.setAccountId(accAccountId);
    AccIdentityAccountDto identityAccountDto = identityAccountService.find(identityAccountWithoutRelationFilter, null).getContent().stream().findFirst().orElse(null);
    if (identityAccountDto == null) {
        return;
    }
    UUID identityId = identityAccountDto.getIdentity();
    IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identityId);
    if (primeContract == null) {
        addToItemLog(logItem, MessageFormat.format("!!Role was not assigned to the user [{0}], because primary contract was not found!!", uid));
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, context.getLog(), context.getActionLogs());
        return;
    }
    membersContractIds.add(primeContract.getId());
    IdmIdentityRoleDto existIdentityRoleDto = existsIdentityRoleDtos.stream().filter(identityRole -> primeContract.getId().equals(identityRole.getIdentityContract())).findFirst().orElse(null);
    if (existIdentityRoleDto != null) {
        // Identity already has the role.
        return;
    }
    addToItemLog(logItem, MessageFormat.format("Role is not assigned for user [{0}] and contract [{1}]. Role request for add role will be created.", uid, primeContract.getId()));
    // Get cache with role-requests by identity-contract.
    Map<UUID, UUID> roleRequestCache = getRoleRequestCache();
    // Get role-request for the primary contract from a cache. If no request is present, then create one.
    initRoleRequest(primeContract, roleRequestCache, config);
    UUID roleRequestId = roleRequestCache.get(primeContract.getId());
    IdmRoleRequestDto mockRoleRequest = new IdmRoleRequestDto();
    mockRoleRequest.setId(roleRequestId);
    // Create a concept for assign a role to primary contract.
    roleRequestService.createConcept(mockRoleRequest, primeContract, null, roleDto.getId(), ConceptRoleRequestOperation.ADD);
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) UUID(java.util.UUID) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)

Example 38 with SysSystemEntityDto

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

the class IdentitySyncTest method testLinkIdentityRemoveWishSync.

// unlinked, system entity has "wish" => removed "wish"
@Test
public void testLinkIdentityRemoveWishSync() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    // Create system entity with "wish"
    createSystemEntityWish(system);
    helper.createIdentity(IDENTITY_ONE);
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK, 1, OperationResultType.SUCCESS);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // System entity is no longer "wish"
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, IDENTITY_ONE);
    Assert.assertFalse(systemEntity.isWish());
    // Delete log
    syncLogService.delete(log);
    syncConfigService.delete(config);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Example 39 with SysSystemEntityDto

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

the class IdentitySyncTest method createSystemEntityWish.

private void createSystemEntityWish(SysSystemDto system) {
    SysSystemEntityDto systemEntity = new SysSystemEntityDto();
    systemEntity.setUid(IDENTITY_ONE);
    systemEntity.setEntityType(SystemEntityType.IDENTITY);
    systemEntity.setWish(true);
    systemEntity.setSystem(system.getId());
    systemEntity = systemEntityService.save(systemEntity);
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)

Example 40 with SysSystemEntityDto

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

the class PrepareConnectorObjectProcessor method process.

/**
 * Prepare provisioning operation execution
 */
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
    SysSystemEntityDto systemEntity = provisioningOperationService.getByProvisioningOperation(provisioningOperation);
    String uid = systemEntity.getUid();
    boolean isWish = systemEntity.isWish();
    LOG.debug("Start preparing attribubes for 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()));
    }
    try {
        IcConnectorObject existsConnectorObject = null;
        // We do not want search account on the target system, when this is the first
        // call the connector and auto mapping is not allowed.
        ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(system);
        if (!isWish || provisioningConfiguration.isAllowedAutoMappingOnExistingAccount()) {
            existsConnectorObject = connectorType.readConnectorObject(system, uid, objectClass);
        }
        if (existsConnectorObject == null) {
            processCreate(provisioningOperation);
        } else {
            processUpdate(provisioningOperation, existsConnectorObject, connectorType);
            // prepare attributes on target system for FE view
            ProvisioningContext context = provisioningOperation.getProvisioningContext();
            IcConnectorObject systemAttrs = intersectAccountAndSystemAttrs(context.getAccountObject(), existsConnectorObject);
            context.setSystemConnectorObject(systemAttrs);
            if (!provisioningOperation.isDryRun()) {
                provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
            }
        }
        // 
        LOG.debug("Preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}] is sucessfully completed", provisioningOperation.getOperationType(), uid, objectClass.getType());
        if (!provisioningOperation.isDryRun()) {
            // set back to event content
            provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
            // log attributes used in provisioning context into provisioning attributes
            provisioningAttributeService.saveAttributes(provisioningOperation);
        }
        event.setContent(provisioningOperation);
        return new DefaultEventResult<>(event, this);
    } catch (Exception ex) {
        if (!provisioningOperation.isDryRun()) {
            provisioningOperation = provisioningOperationService.handleFailed(provisioningOperation, ex);
        }
        // TODO nastavit vyjimku stav do provisioning operation podobne jak se deje v handleFailed
        event.setContent(provisioningOperation);
        return new DefaultEventResult<>(event, this, true);
    }
}
Also used : ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) 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) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

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