use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createSystem.
/**
* @param tableName
* @param systemName
* @return
*/
@Override
public SysSystemDto createSystem(String tableName, String systemName, String statusColumnName, String keyColumnName) {
// create owner
org.apache.tomcat.jdbc.pool.DataSource tomcatDataSource = ((org.apache.tomcat.jdbc.pool.DataSource) dataSource);
SysSystemDto system = new SysSystemDto();
system.setName(systemName == null ? tableName + "_" + System.currentTimeMillis() : systemName);
system.setConnectorKey(new SysConnectorKeyDto(systemService.getTestConnectorKey()));
system = systemService.save(system);
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system.getConnectorInstance());
List<IdmFormValueDto> values = new ArrayList<>();
IdmFormValueDto jdbcUrlTemplate = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("jdbcUrlTemplate"));
jdbcUrlTemplate.setValue(tomcatDataSource.getUrl());
values.add(jdbcUrlTemplate);
IdmFormValueDto jdbcDriver = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("jdbcDriver"));
jdbcDriver.setValue(tomcatDataSource.getDriverClassName());
values.add(jdbcDriver);
IdmFormValueDto user = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("user"));
user.setValue(tomcatDataSource.getUsername());
values.add(user);
IdmFormValueDto password = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("password"));
password.setValue(tomcatDataSource.getPoolProperties().getPassword());
values.add(password);
IdmFormValueDto table = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("table"));
table.setValue(tableName);
values.add(table);
if (!Strings.isNullOrEmpty(keyColumnName)) {
IdmFormValueDto keyColumn = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("keyColumn"));
keyColumn.setValue(keyColumnName);
values.add(keyColumn);
}
IdmFormValueDto passwordColumn = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("passwordColumn"));
passwordColumn.setValue("password");
values.add(passwordColumn);
IdmFormValueDto allNative = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("allNative"));
allNative.setValue(true);
values.add(allNative);
IdmFormValueDto rethrowAllSQLExceptions = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("rethrowAllSQLExceptions"));
rethrowAllSQLExceptions.setValue(true);
values.add(rethrowAllSQLExceptions);
if (!Strings.isNullOrEmpty(statusColumnName)) {
IdmFormValueDto statusColumn = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("statusColumn"));
statusColumn.setValue(statusColumnName);
values.add(statusColumn);
}
IdmFormValueDto disabledStatusValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("disabledStatusValue"));
disabledStatusValue.setValue("disabled");
values.add(disabledStatusValue);
IdmFormValueDto enabledStatusValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("enabledStatusValue"));
enabledStatusValue.setValue("enabled");
values.add(enabledStatusValue);
IdmFormValueDto changeLogColumnValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("changeLogColumn"));
changeLogColumnValue.setValue(null);
values.add(changeLogColumnValue);
// TODO: eav to dto
SysSystem systemEntity = systemRepository.findOne(system.getId());
formService.saveValues(systemEntity, savedFormDefinition, values);
return system;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleCatalogueProvisioningTest method initData.
private void initData() {
// create test system
system = helper.createSystem("test_tree_resource");
system.setName(SYSTEM_NAME);
system = systemService.save(system);
// key to EAV
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system.getConnectorInstance());
IdmFormAttributeDto attributeKeyColumn = savedFormDefinition.getMappedAttributeByCode("keyColumn");
formService.saveValues(system, attributeKeyColumn, ImmutableList.of("ID"));
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
// Create synchronization mapping
SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
syncSystemMapping.setName("default_" + System.currentTimeMillis());
syncSystemMapping.setEntityType(SystemEntityType.ROLE_CATALOGUE);
syncSystemMapping.setOperationType(SystemOperationType.PROVISIONING);
syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
createMapping(system, syncMapping);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate_Filtered.
@Test
public /**
* We will do synchronize with use inner connector synch function.
*/
void doStartSyncB_Linked_doEntityUpdate_Filtered() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
this.getBean().changeResourceData();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
SysSystemMappingDto systemMapping = systemMappingService.get(syncConfigCustom.getSystemMapping());
SysSystemDto system = systemService.get(schemaObjectClassService.get(systemMapping.getObjectClass()).getSystem());
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system.getConnectorInstance());
IdmFormAttributeDto changeLogColumn = savedFormDefinition.getMappedAttributeByCode("changeLogColumn");
formService.saveValues(system, changeLogColumn, ImmutableList.of("modified"));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setReconciliation(false);
// We want do sync for account changed in future
syncConfigCustom.setToken(LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
// We don`t use custom filter. This option will be not used.
syncConfigCustom.setFilterOperation(IcFilterOperationType.ENDS_WITH);
syncConfigService.save(syncConfigCustom);
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(1, items.size());
Assert.assertEquals("x" + IDENTITY_USERNAME_TWO, items.get(0).getIdentification());
// Delete log
syncLogService.delete(log);
// We have to change property of connector configuration "changeLogColumn" from "modified" on empty string.
// When is this property set, then custom filter not working. Bug in Table connector !!!
formService.saveValues(system, changeLogColumn, ImmutableList.of(""));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningExtendedAttribute.
@Test
public void doIdentityProvisioningExtendedAttribute() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
// We will use firstName attribute (password attribute is not returned
// by default)
SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
filterSchemaAttr.setIdmPropertyName("firstName");
filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
// Set attribute to extended attribute and modify idmPropety to
// extPassword
attributeHandling.setIdmPropertyName(IDENTITY_EXT_PASSWORD);
attributeHandling.setExtendedAttribute(true);
attributeHandling.setConfidentialAttribute(true);
attributeHandling.setEntityAttribute(false);
attributeHandling.setTransformToResourceScript("return attributeValue");
// Form attribute definition will be created during save attribute
// handling
attributeHandling = systemAttributeMappingService.save(attributeHandling);
// Create extended attribute value for password
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
List<IdmFormValueDto> values = new ArrayList<>();
IdmFormValueDto phoneValue = new IdmFormValueDto();
phoneValue.setFormAttribute(formDefinition.getMappedAttributeByCode(IDENTITY_EXT_PASSWORD).getId());
phoneValue.setStringValue(IDENTITY_PASSWORD_THREE);
values.add(phoneValue);
formService.saveValues(identityRepository.findOne(identity.getId()), formDefinition, values);
// save account
provisioningService.doProvisioning(identity);
TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(IDENTITY_PASSWORD_THREE, resourceAccoutn.getFirstname());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormService method getAttribute.
@Override
@Transactional(readOnly = true)
public IdmFormAttributeDto getAttribute(Class<? extends Identifiable> ownerType, String definitionCode, String attributeCode) {
Assert.notNull(ownerType, "Owner type is required!");
Assert.hasLength(attributeCode, "Form attribute code is required!");
//
IdmFormDefinitionDto definition = getDefinition(ownerType, definitionCode);
Assert.notNull(definition, "Definition is required!");
//
return formAttributeService.findAttribute(getDefaultDefinitionType(ownerType), definition.getCode(), attributeCode);
}
Aggregations