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);
}
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();
}
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);
}
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();
}
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();
}
Aggregations