Search in sources :

Example 6 with ProvisioningContext

use of eu.bcvsolutions.idm.acc.domain.ProvisioningContext 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());
    SysSystemEntityDto systemEntity = helper.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) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 7 with ProvisioningContext

use of eu.bcvsolutions.idm.acc.domain.ProvisioningContext in project CzechIdMng by bcvsolutions.

the class AbstractProvisioningExecutor method prepareProvisioning.

private SysProvisioningOperationDto prepareProvisioning(SysSystemEntityDto systemEntity, DTO dto, UUID entityId, ProvisioningOperationType operationType, List<? extends AttributeMapping> attributes) {
    Assert.notNull(systemEntity);
    Assert.notNull(systemEntity.getUid());
    Assert.notNull(systemEntity.getEntityType());
    SysSystemDto system = DtoUtils.getEmbedded(systemEntity, SysSystemEntity_.system, SysSystemDto.class);
    Assert.notNull(system);
    // If are input attributes null, then we load default mapped attributes
    if (attributes == null) {
        attributes = findAttributeMappings(system, systemEntity.getEntityType());
    }
    if (attributes == null || attributes.isEmpty()) {
        return null;
    }
    // Find connector identification persisted in system
    IcConnectorKey connectorKey = system.getConnectorKey();
    if (connectorKey == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // Find connector configuration persisted in system
    IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(system);
    if (connectorConfig == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // One IDM object can be mapped to one connector object (= one connector
    // class).
    SysSystemMappingDto mapping = getMapping(system, systemEntity.getEntityType());
    if (mapping == null) {
        // TODO: delete operation?
        return null;
    }
    // 
    Map<ProvisioningAttributeDto, Object> accountAttributes = prepareMappedAttributesValues(dto, operationType, systemEntity, attributes);
    // public provisioning event
    SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(systemEntity.getUid(), new IcObjectClassImpl(schemaObjectClassDto.getObjectClassName()), null);
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(operationType).setSystemEntity(systemEntity).setEntityIdentifier(entityId).setProvisioningContext(new ProvisioningContext(accountAttributes, connectorObject));
    // 
    return operationBuilder.build();
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 8 with ProvisioningContext

use of eu.bcvsolutions.idm.acc.domain.ProvisioningContext in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemServiceTest method testReferentialIntegrityProvisioningOperationExists.

@Test(expected = ResultCodeException.class)
public void testReferentialIntegrityProvisioningOperationExists() {
    SysSystemDto system = new SysSystemDto();
    String systemName = "t_s_" + System.currentTimeMillis();
    system.setName(systemName);
    system = systemService.save(system);
    // system entity
    SysSystemEntityDto systemEntity = new SysSystemEntityDto();
    systemEntity.setUid("test");
    systemEntity.setSystem(system.getId());
    systemEntity.setEntityType(SystemEntityType.IDENTITY);
    systemEntity = systemEntityService.save(systemEntity);
    SysProvisioningOperationDto provisioningOperation = new SysProvisioningOperationDto();
    provisioningOperation.setSystem(system.getId());
    provisioningOperation.setEntityType(SystemEntityType.IDENTITY);
    provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
    provisioningOperation.setSystemEntity(systemEntity.getId());
    provisioningOperation.setEntityIdentifier(UUID.randomUUID());
    provisioningOperation.setProvisioningContext(new ProvisioningContext());
    provisioningOperation.setResult(new OperationResult());
    provisioningOperationService.save(provisioningOperation);
    // 
    systemService.delete(system);
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with ProvisioningContext

use of eu.bcvsolutions.idm.acc.domain.ProvisioningContext in project CzechIdMng by bcvsolutions.

the class AbstractProvisioningExecutor method prepareProvisioningForAttribute.

private SysProvisioningOperationDto prepareProvisioningForAttribute(SysSystemEntityDto systemEntity, AttributeMapping attributeMapping, Object value, ProvisioningOperationType operationType, DTO dto) {
    Assert.notNull(systemEntity);
    Assert.notNull(systemEntity.getSystem());
    Assert.notNull(systemEntity.getEntityType());
    Assert.notNull(systemEntity.getUid());
    Assert.notNull(attributeMapping);
    SysSchemaAttributeDto schemaAttributeDto = getSchemaAttribute(attributeMapping);
    if (!schemaAttributeDto.isUpdateable()) {
        throw new ProvisioningException(AccResultCode.PROVISIONING_SCHEMA_ATTRIBUTE_IS_NOT_UPDATEABLE, ImmutableMap.of("property", attributeMapping.getIdmPropertyName(), "uid", systemEntity.getUid()));
    }
    SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(schemaAttributeDto.getObjectClass());
    String objectClassName = schemaObjectClassDto.getObjectClassName();
    // We do transformation to system if is attribute only constant
    Object valueTransformed = value;
    if (!attributeMapping.isEntityAttribute() && !attributeMapping.isExtendedAttribute()) {
    // If is attribute handling resolve as constant, then we don't want
    // do transformation again (was did in getAttributeValue)
    } else {
        valueTransformed = attributeMappingService.transformValueToResource(systemEntity.getUid(), value, attributeMapping, dto);
    }
    IcAttribute icAttributeForCreate = attributeMappingService.createIcAttribute(schemaAttributeDto, valueTransformed);
    // 
    // Call ic modul for update single attribute
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(systemEntity.getUid(), new IcObjectClassImpl(objectClassName), ImmutableList.of(icAttributeForCreate));
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(ProvisioningEventType.UPDATE).setSystemEntity(systemEntity).setEntityIdentifier(dto == null ? null : dto.getId()).setProvisioningContext(new ProvisioningContext(connectorObject));
    // 
    return operationBuilder.build();
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 10 with ProvisioningContext

use of eu.bcvsolutions.idm.acc.domain.ProvisioningContext in project CzechIdMng by bcvsolutions.

the class DefaultProvisioningExecutorIntegrationTest method createProvisioningOperation.

/**
 * Prepare provisioning context and operation
 *
 * @param system
 * @return
 */
private SysProvisioningOperationDto createProvisioningOperation(SysSystemDto system, String firstname) {
    ProvisioningContext context = new ProvisioningContext();
    SysSystemEntityDto systemEntity = helper.createSystemEntity(system);
    Map<ProvisioningAttributeDto, Object> accoutObject = createAccountObject(systemEntity, firstname);
    context.setAccountObject(accoutObject);
    // 
    // prepare provisioning operation
    SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
    IcObjectClass objectClass = new IcObjectClassImpl(schemaObjectClassService.get(systemMapping.getObjectClass()).getObjectClassName());
    IcConnectorObject connectorObject = new IcConnectorObjectImpl(null, objectClass, null);
    SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(ProvisioningOperationType.CREATE).setSystemEntity(systemEntity).setProvisioningContext(new ProvisioningContext(accoutObject, connectorObject));
    return operationBuilder.build();
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Aggregations

ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)16 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)11 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)8 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)7 IcConnectorObjectImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)7 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)5 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)5 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)5 ConfidentialString (eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 Test (org.junit.Test)5 SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)4 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)4 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)4 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)4 AbstractVerifiableUnitTest (eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest)4 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)3