use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class SchemaAttributeDeleteProcessor method process.
@Override
public EventResult<SysSchemaAttributeDto> process(EntityEvent<SysSchemaAttributeDto> event) {
SysSchemaAttributeDto schemaAttribute = event.getContent();
// remove all handled attributes
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSchemaAttributeId(schemaAttribute.getId());
systeAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
systeAttributeMappingService.delete(systemAttributeMapping);
});
//
schemaAttributeService.deleteInternal(schemaAttribute);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningExecutor method resolveAdditionalPasswordChangeAttributes.
private List<AttributeMapping> resolveAdditionalPasswordChangeAttributes(AccAccountDto account, DTO dto, SysSystemDto system, SystemEntityType entityType) {
EntityAccountFilter filter = this.createEntityAccountFilter();
filter.setEntityId(dto.getId());
filter.setSystemId(system.getId());
filter.setOwnership(Boolean.TRUE);
filter.setAccountId(account.getId());
List<? extends EntityAccountDto> entityAccoutnList = this.getEntityAccountService().find(filter, null).getContent();
if (entityAccoutnList == null) {
return Collections.<AttributeMapping>emptyList();
}
//
SysSystemMappingDto mapping = getMapping(system, entityType);
if (mapping == null) {
return Collections.<AttributeMapping>emptyList();
}
//
// All additional mapped attributes from system, witch has to be send on
// password change
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemMappingId(mapping.getId());
attributeFilter.setSendOnPasswordChange(Boolean.TRUE);
List<? extends AttributeMapping> additionalPasswordChangeAttributes = attributeMappingService.find(attributeFilter, null).getContent();
//
// All role system attributes (overloading) for this uid and same system
List<SysRoleSystemAttributeDto> roleSystemAttributesAll = findOverloadingAttributes(dto, system, entityAccoutnList, entityType);
//
// Final list of attributes use for provisioning
List<AttributeMapping> results = compileAttributes(additionalPasswordChangeAttributes, roleSystemAttributesAll, entityType);
//
return results == null ? Collections.<AttributeMapping>emptyList() : results;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doCreateSyncConfig.
@Test
@Transactional
public void doCreateSyncConfig() {
initData();
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.ROLE);
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);
SysSystemAttributeMappingDto tokenAttribute = attributes.stream().filter(attribute -> {
return "changed".equals(attribute.getIdmPropertyName());
}).findFirst().orElse(null);
// Create default synchronization config
AbstractSysSyncConfigDto syncConfigCustom = new SysSyncConfigDto();
syncConfigCustom.setReconciliation(false);
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setTokenAttribute(tokenAttribute.getId());
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncE_StrategyWriteIfNull_EAV.
@Test
public void doStartSyncE_StrategyWriteIfNull_EAV() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Find email attribute and change strategy on WRITE_IF_NULL
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
SysSystemMappingDto systemMapping = systemMappingService.get(syncConfigCustom.getSystemMapping());
SysSystemDto system = systemService.get(schemaObjectClassService.get(systemMapping.getObjectClass()).getSystem());
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 eavAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(EAV_ATTRIBUTE);
}).findFirst().get();
eavAttribute.setStrategyType(AttributeMappingStrategyType.WRITE_IF_NULL);
schemaAttributeMappingService.save(eavAttribute);
//
// Set eav on identity ONE to null
IdmIdentityDto one = identityService.getByUsername("x" + IDENTITY_USERNAME_ONE);
formService.saveValues(one.getId(), IdmIdentity.class, eavAttribute.getIdmPropertyName(), null);
IdmIdentityDto two = identityService.getByUsername("x" + IDENTITY_USERNAME_TWO);
formService.saveValues(two.getId(), IdmIdentity.class, eavAttribute.getIdmPropertyName(), ImmutableList.of(ATTRIBUTE_EMAIL));
// Prepare resource data
this.getBean().deleteAllResourceData();
this.getBean().initResourceData();
this.getBean().changeResourceData();
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setReconciliation(true);
syncConfigService.save(syncConfigCustom);
// Start synchronization
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
// Check state after sync
one = identityService.getByUsername("x" + IDENTITY_USERNAME_ONE);
Assert.assertEquals(ATTRIBUTE_VALUE_CHANGED, formService.getValues(one.getId(), IdmIdentity.class, eavAttribute.getIdmPropertyName()).get(0).getStringValue());
two = identityService.getByUsername("x" + IDENTITY_USERNAME_TWO);
Assert.assertEquals(ATTRIBUTE_EMAIL, formService.getValues(two.getId(), IdmIdentity.class, eavAttribute.getIdmPropertyName()).get(0).getStringValue());
// Revert strategy
eavAttribute.setStrategyType(AttributeMappingStrategyType.SET);
schemaAttributeMappingService.save(eavAttribute);
// Set EAV value to default
formService.saveValues(one.getId(), IdmIdentity.class, eavAttribute.getIdmPropertyName(), ImmutableList.of("1"));
formService.saveValues(two.getId(), IdmIdentity.class, eavAttribute.getIdmPropertyName(), ImmutableList.of("2"));
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncE_StrategyCreate.
@Test
public void doStartSyncE_StrategyCreate() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Delete all accounts in resource
this.getBean().deleteAllResourceData();
// Create new accounts
this.getBean().initResourceData();
// Find email attribute and change startegy on CREATE
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
SysSystemMappingDto systemMapping = systemMappingService.get(syncConfigCustom.getSystemMapping());
SysSystemDto system = systemService.get(schemaObjectClassService.get(systemMapping.getObjectClass()).getSystem());
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 emailAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(ATTRIBUTE_EMAIL);
}).findFirst().get();
emailAttribute.setStrategyType(AttributeMappingStrategyType.CREATE);
schemaAttributeMappingService.save(emailAttribute);
//
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setReconciliation(true);
syncConfigService.save(syncConfigCustom);
// Check state before sync
Assert.assertNull(identityService.getByUsername("x" + IDENTITY_USERNAME_ONE));
Assert.assertNull(identityService.getByUsername("x" + IDENTITY_USERNAME_TWO));
// Start synchronization
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.CREATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
// Check state after sync
Assert.assertEquals(IDENTITY_USERNAME_ONE, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getFirstName());
Assert.assertEquals(IDENTITY_USERNAME_TWO, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getLastName());
Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getEmail());
Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getEmail());
// Delete log
syncLogService.delete(log);
// Change data
this.getBean().changeResourceData();
// Start synchronization aging
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
// Check state after sync
Assert.assertEquals(ATTRIBUTE_VALUE_CHANGED, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getFirstName());
Assert.assertEquals(ATTRIBUTE_VALUE_CHANGED, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getLastName());
Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getEmail());
Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getEmail());
// Delete log
syncLogService.delete(log);
}
Aggregations