Search in sources :

Example 21 with IdmFormValueDto

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;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)

Example 22 with IdmFormValueDto

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;
}
Also used : SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 23 with IdmFormValueDto

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);
}
Also used : MethodSorters(org.junit.runners.MethodSorters) RoleType(eu.bcvsolutions.idm.core.api.domain.RoleType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) SysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) After(org.junit.After) SynchronizationMissingEntityActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationMissingEntityActionType) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) SynchronizationUnlinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationUnlinkedActionType) SysSyncLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncLogService) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) Page(org.springframework.data.domain.Page) ReconciliationMissingAccountActionType(eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType) List(java.util.List) Query(javax.persistence.Query) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) FixMethodOrder(org.junit.FixMethodOrder) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) SynchronizationActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationActionType) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) Service(org.springframework.stereotype.Service) SynchronizationLinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Before(org.junit.Before) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Test(org.junit.Test) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) EntityManager(javax.persistence.EntityManager) LocalDateTime(org.joda.time.LocalDateTime) ApplicationContext(org.springframework.context.ApplicationContext) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SynchronizationService(eu.bcvsolutions.idm.acc.service.api.SynchronizationService) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestRoleResource(eu.bcvsolutions.idm.acc.entity.TestRoleResource) IcFilterOperationType(eu.bcvsolutions.idm.ic.domain.IcFilterOperationType) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncItemLogService) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSyncActionLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncActionLogService) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with IdmFormValueDto

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());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 25 with IdmFormValueDto

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());
}
Also used : IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) DateTime(org.joda.time.DateTime) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) Test(org.junit.Test)

Aggregations

IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)39 Test (org.junit.Test)24 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)23 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)19 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)13 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)12 Transactional (org.springframework.transaction.annotation.Transactional)11 ArrayList (java.util.ArrayList)10 List (java.util.List)9 UUID (java.util.UUID)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)6 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)6 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)5 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)4 FormService (eu.bcvsolutions.idm.core.eav.api.service.FormService)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 SysConnectorKeyDto (eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto)3 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)3 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)3