use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class VsProvisioningMergeTest method testAttribteControlledValues.
@Test
public void testAttribteControlledValues() {
VsSystemDto config = new VsSystemDto();
config.setName(helper.createName());
config.setCreateDefaultRole(false);
SysSystemDto system = helper.createVirtualSystem(config);
IdmRoleDto roleOne = helper.createRole();
IdmRoleDto roleTwo = helper.createRole();
SysRoleSystemDto roleSystemOne = helper.createRoleSystem(roleOne, system);
SysRoleSystemDto roleSystemTwo = helper.createRoleSystem(roleTwo, system);
SysSystemMappingDto mapping = mappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemMappingId(mapping.getId());
attributeFilter.setSchemaAttributeName(RIGHTS_ATTRIBUTE);
List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(attributeFilter, null).getContent();
assertEquals(1, attributes.size());
SysSystemAttributeMappingDto rightsAttribute = attributes.get(0);
SysRoleSystemAttributeDto roleAttributeOne = new SysRoleSystemAttributeDto();
roleAttributeOne.setName(RIGHTS_ATTRIBUTE);
roleAttributeOne.setRoleSystem(roleSystemOne.getId());
roleAttributeOne.setEntityAttribute(false);
roleAttributeOne.setExtendedAttribute(false);
roleAttributeOne.setUid(false);
roleAttributeOne.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeOne.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
SysRoleSystemAttributeDto roleAttributeTwo = new SysRoleSystemAttributeDto();
roleAttributeTwo.setName(RIGHTS_ATTRIBUTE);
roleAttributeTwo.setRoleSystem(roleSystemTwo.getId());
roleAttributeTwo.setEntityAttribute(false);
roleAttributeTwo.setExtendedAttribute(false);
roleAttributeTwo.setUid(false);
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeTwo.setTransformToResourceScript("return '" + TWO_VALUE + "';");
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
IdmIdentityDto identity = helper.createIdentity();
helper.createIdentityRole(identity, roleOne);
helper.createIdentityRole(identity, roleTwo);
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setSystemId(system.getId());
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
assertEquals(1, accounts.size());
AccAccountDto account = accounts.get(0);
IcConnectorObject connectorObject = accountService.getConnectorObject(account);
IcAttribute rightsAttributeFromSystem = connectorObject.getAttributeByName(RIGHTS_ATTRIBUTE);
List<Object> rightsValues = rightsAttributeFromSystem.getValues();
assertEquals(2, rightsValues.size());
assertTrue(rightsValues.contains(ONE_VALUE));
assertTrue(rightsValues.contains(TWO_VALUE));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingService method getAuthenticationAttribute.
@Override
public SysSystemAttributeMappingDto getAuthenticationAttribute(UUID systemId, SystemEntityType entityType) {
Assert.notNull(systemId, "System identifier is required.");
Assert.notNull(entityType, "Entity type is required.");
// authentication attribute is only from provisioning operation type
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setEntityType(entityType);
filter.setSystemId(systemId);
filter.setOperationType(SystemOperationType.PROVISIONING);
filter.setAuthenticationAttribute(Boolean.TRUE);
List<SysSystemAttributeMappingDto> attributes = this.find(filter, null).getContent();
// UID authentication attribute may be only one the integrity is checked by application before.
if (attributes.isEmpty()) {
filter.setIsUid(Boolean.TRUE);
filter.setAuthenticationAttribute(null);
attributes = this.find(filter, null).getContent();
if (attributes.isEmpty()) {
return null;
}
return attributes.get(0);
}
return attributes.get(0);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingService method findBySystemMappingAndName.
@Override
@Transactional(readOnly = true)
public SysSystemAttributeMappingDto findBySystemMappingAndName(UUID systemMappingId, String name) {
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(systemMappingId);
filter.setName(name);
List<SysSystemAttributeMappingDto> content = this.find(filter, null).getContent();
// Name must be unique for system mapping, checked by application and database
return content.isEmpty() ? null : content.get(0);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDeleteBulkActionTest method prevalidationBulkActionByIds.
@Test
public void prevalidationBulkActionByIds() {
SysSystemDto system = helper.createTestResourceSystem(true, getHelper().createName());
// Gets existing mapping in the system
SysSystemMappingFilter systemFilter = new SysSystemMappingFilter();
systemFilter.setSystemId(system.getId());
List<SysSystemMappingDto> mapping = mappingService.find(systemFilter, null).getContent();
// Tests that a mapping was found
assertNotEquals(0, mapping.size());
// Finds mapped attributes in existing system
SysSystemAttributeMappingFilter attrMapFilter = new SysSystemAttributeMappingFilter();
attrMapFilter.setSystemId(system.getId());
List<SysSystemAttributeMappingDto> attrMapping = attrMappingService.find(attrMapFilter, null).getContent();
SysSystemAttributeMappingDto attrMappingDto = //
attrMapping.stream().filter(//
attrMap -> {
return TestHelper.ATTRIBUTE_MAPPING_NAME.equals(attrMap.getName());
}).findFirst().orElse(null);
// Tests presence of desired mapped attribute
assertNotNull(attrMappingDto);
// Running prevalidation which is supposed to return no validation errors
// because this mapping is not used in any synchronization settings.
SysSystemMappingDto mappingDto = mapping.get(0);
IdmBulkActionDto bulkAction = this.findBulkAction(SysSystemMapping.class, SystemMappingDeleteBulkAction.NAME);
bulkAction.setIdentifiers(ImmutableSet.of(mappingDto.getId()));
ResultModels resultModels = bulkActionManager.prevalidate(bulkAction);
assertEquals(0, resultModels.getInfos().size());
// Creates synchronization with set existing mapping
SysSyncConfigDto syncConfig = new SysSyncConfigDto();
syncConfig.setName(getHelper().createName());
syncConfig.setSystemMapping(mappingDto.getId());
syncConfig.setCorrelationAttribute(attrMappingDto.getId());
syncConfig = (SysSyncConfigDto) syncService.save(syncConfig);
// Tests that attempt to delete a system mapping used in a synchronization setting fails
resultModels = bulkActionManager.prevalidate(bulkAction);
assertNotEquals(0, resultModels.getInfos().size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method testCreateIdentityWithAutomaticRoleByEavAttribute.
@Test
public void testCreateIdentityWithAutomaticRoleByEavAttribute() {
String username = getHelper().createName();
SysSystemDto system = initData(username, "mockIdentity@idm.eu");
Assert.assertNotNull(system);
SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
config.setCreateDefaultContract(true);
config.setStartAutoRoleRec(true);
syncConfigService.save(config);
//
// create form definition, roles, automatic role etc.
IdmRoleDto role = getHelper().createRole();
IdmRoleDto subRole = getHelper().createRole();
getHelper().createRoleComposition(role, subRole);
// sync supports default definition only
IdmFormAttributeDto formAttribute = new IdmFormAttributeDto(getHelper().createName());
IdmFormAttributeDto formAttributeIdentity = formService.saveAttribute(IdmIdentityDto.class, formAttribute);
//
IdmAutomaticRoleAttributeDto automaticRole = getHelper().createAutomaticRole(role.getId());
getHelper().createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY_EAV, null, formAttributeIdentity.getId(), "mockIdentity@idm.eu");
//
// create mapping to eav attribute - leader = eav
SysSystemMappingDto syncSystemMapping = systemMappingService.get(config.getSystemMapping());
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(syncSystemMapping.getId());
SysSystemAttributeMappingDto lastnameAttributeMapping = schemaAttributeMappingService.findBySystemMappingAndName(syncSystemMapping.getId(), ATTRIBUTE_EMAIL);
lastnameAttributeMapping.setEntityAttribute(false);
lastnameAttributeMapping.setExtendedAttribute(true);
lastnameAttributeMapping.setIdmPropertyName(formAttributeIdentity.getCode());
schemaAttributeMappingService.save(lastnameAttributeMapping);
//
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1, OperationResultType.SUCCESS);
Assert.assertFalse(log.isRunning());
IdmIdentityFilter identityFilter = new IdmIdentityFilter();
identityFilter.setUsername(username);
identityFilter.setAddEavMetadata(Boolean.TRUE);
List<IdmIdentityDto> identities = identityService.find(identityFilter, null).getContent();
Assert.assertEquals(1, identities.size());
Assert.assertEquals("mockIdentity@idm.eu", identities.get(0).getEavs().stream().filter(fi -> fi.getFormDefinition().isMain()).findFirst().get().getValues().stream().filter(v -> v.getFormAttribute().equals(formAttributeIdentity.getId())).findFirst().get().getShortTextValue());
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityId(identities.get(0).getId());
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.find(identityRoleFilter, null).getContent();
Assert.assertEquals(2, assignedRoles.size());
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getRole().equals(role.getId())));
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getRole().equals(subRole.getId())));
// Delete log
syncLogService.delete(log);
syncConfigService.delete(config);
}
Aggregations