use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method doCreateSyncConfig.
public SysSyncIdentityConfigDto doCreateSyncConfig(SysSystemDto system) {
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
mappingFilter.setSystemId(system.getId());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto uidAttribute = attributes.stream().filter(attribute -> {
return attribute.isUid();
}).findFirst().orElse(null);
// Create default synchronization config
SysSyncIdentityConfigDto syncConfigCustom = new SysSyncIdentityConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom = (SysSyncIdentityConfigDto) syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class ContractSynchronizationExecutor method validate.
@Override
protected SynchronizationContext validate(UUID synchronizationConfigId) {
AbstractSysSyncConfigDto config = synchronizationConfigService.get(synchronizationConfigId);
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
Assert.notNull(mapping, "Mapping is required.");
SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
attributeHandlingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> mappedAttributes = systemAttributeMappingService.find(attributeHandlingFilter, null).getContent();
SysSystemAttributeMappingDto ownerAttribute = mappedAttributes.stream().filter(attribute -> {
return CONTRACT_IDENTITY_FIELD.equals(attribute.getIdmPropertyName());
}).findFirst().orElse(null);
if (ownerAttribute == null) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_MAPPED_ATTR_MUST_EXIST, ImmutableMap.of("property", CONTRACT_IDENTITY_FIELD));
}
return super.validate(synchronizationConfigId);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method validate.
/**
* Validate synchronization on: Exist, enable, running, has mapping, has
* connector key, has connector configuration
*
* @param synchronizationConfigId
* @return
*/
protected SynchronizationContext validate(UUID synchronizationConfigId) {
SynchronizationContext context = new SynchronizationContext();
// Set context as main context for whole sync.
syncContext = context;
AbstractSysSyncConfigDto config = synchronizationConfigService.get(synchronizationConfigId);
//
if (config == null) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_NOT_FOUND, ImmutableMap.of("id", synchronizationConfigId));
}
// Synchronization must be enabled
if (!config.isEnabled()) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IS_NOT_ENABLED, ImmutableMap.of("name", config.getName()));
}
// Synchronization can not be running twice
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(config.getId());
logFilter.setRunning(Boolean.TRUE);
if (!synchronizationLogService.find(logFilter, null).getContent().isEmpty()) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IS_RUNNING, ImmutableMap.of("name", config.getName()));
}
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
Assert.notNull(mapping, "Mapping is required.");
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system);
Assert.notNull(system, "System is required.");
// System must be enabled
if (system.isDisabled()) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_SYSTEM_IS_NOT_ENABLED, ImmutableMap.of("name", config.getName(), "system", system.getName()));
}
SystemEntityType entityType = mapping.getEntityType();
SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
attributeHandlingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> mappedAttributes = systemAttributeMappingService.find(attributeHandlingFilter, null).getContent();
// 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()));
}
context.addConfig(config).addSystem(system).addEntityType(entityType).addMappedAttributes(mappedAttributes).addConnectorConfig(connectorConfig);
return context;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultPasswordFilterManager method getAttributeMappingForPasswordFilter.
/**
* Get {@link SysSystemAttributeMappingDto} that define configuration for password filter.
*
* @param system
* @return
*/
private SysSystemAttributeMappingDto getAttributeMappingForPasswordFilter(SysSystemDto system) {
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system.getId());
filter.setPasswordAttribute(Boolean.TRUE);
filter.setPasswordFilter(Boolean.TRUE);
List<SysSystemAttributeMappingDto> content = systemAttributeMappingService.find(filter, null).getContent();
if (content.isEmpty()) {
throw new ResultCodeException(AccResultCode.PASSWORD_FILTER_DEFINITION_NOT_FOUND, ImmutableMap.of("systemId", system.getId()));
}
// Attribute with password filter may be only one!
return content.get(0);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationService method resolveMissingEntitySituation.
@Override
public SysSyncItemLogDto resolveMissingEntitySituation(String uid, SystemEntityType entityType, List<IcAttribute> icAttributes, UUID configId, String actionType) {
Assert.notNull(uid, "Uid is required.");
Assert.notNull(entityType, "Entity type is required.");
Assert.notNull(icAttributes, "Connector attribues are required.");
Assert.notNull(configId, "Configuration identifier is required.");
Assert.notNull(actionType, "Action type is required.");
AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto sysSchemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(sysSchemaObjectClassDto, SysSchemaObjectClass_.system);
SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
attributeHandlingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> mappedAttributes = attributeHandlingService.find(attributeHandlingFilter, null).getContent();
SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
// Little workaround, we have only IcAttributes ... we create IcObject manually
IcConnectorObjectImpl icObject = new IcConnectorObjectImpl();
icObject.setAttributes(icAttributes);
icObject.setUidValue(uid);
SynchronizationContext context = new SynchronizationContext();
//
context.addUid(uid).addSystem(//
system).addConfig(//
config).addEntityType(//
entityType).addLogItem(//
itemLog).addMappedAttributes(//
mappedAttributes).addIcObject(//
icObject);
getSyncExecutor(entityType, configId).resolveMissingEntitySituation(SynchronizationMissingEntityActionType.valueOf(actionType), context);
return itemLog;
}
Aggregations