use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto in project CzechIdMng by bcvsolutions.
the class AbstractFormPropertyConverter method convertMultipleConnectorPropertyValue.
/**
* Converts eav form values to connector property values (multi)
*
* @param propertyConfiguration
* @param formValues
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object convertMultipleConnectorPropertyValue(IcConfigurationProperty propertyConfiguration, List<IdmFormValueDto> formValues) {
Object value = null;
List valueList = new ArrayList<>();
for (IdmFormValueDto formValue : formValues) {
valueList.add(convertSingleConnectorPropertyValue(propertyConfiguration, formValue));
}
if (!valueList.isEmpty()) {
// override for other data types
if (PersistentType.TEXT == getFormPropertyType()) {
value = valueList.toArray(new String[] {});
} else if (PersistentType.UUID == getFormPropertyType()) {
value = valueList.toArray(new UUID[] {});
} else {
value = valueList.toArray();
}
}
return value;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto 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.IdmFormValueDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doStartSyncC_filterByToken.
@Test
public void doStartSyncC_filterByToken() {
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));
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setProperty(IdmRole_.name.getName());
roleFilter.setValue("3");
IdmRoleDto roleThree = roleService.find(roleFilter, null).getContent().get(0);
Assert.assertNotNull(roleThree);
IdmFormValueDto changedRole = (IdmFormValueDto) formService.getValues(roleThree.getId(), IdmRole.class, "changed").get(0);
Assert.assertNotNull(changedRole);
// Set sync config
syncConfigCustom.setReconciliation(false);
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setFilterOperation(IcFilterOperationType.GREATER_THAN);
syncConfigCustom.setFilterAttribute(syncConfigCustom.getTokenAttribute());
syncConfigCustom.setToken(changedRole.getStringValue());
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
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 createEntityActionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
SysSyncItemLogDto item = items.stream().filter(logitem -> {
return "4".equals(logitem.getIdentification());
}).findFirst().orElse(null);
Assert.assertNotNull("Log for role 4 must exist!", item);
item = items.stream().filter(logitem -> {
return "5".equals(logitem.getIdentification());
}).findFirst().orElse(null);
Assert.assertNotNull("Log for role 5 must exist!", item);
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto 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.IdmFormValueDto in project CzechIdMng by bcvsolutions.
the class AbstractFormValueUnitTest method testDateValueAsDateTime.
@Test
public void testDateValueAsDateTime() {
IdmFormValueDto formValue = new IdmFormValueDto();
formValue.setPersistentType(PersistentType.DATETIME);
DateTime current = new DateTime();
formValue.setValue(current);
assertEquals(current, formValue.getValue());
}
Aggregations