use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method initData.
private SysSystemDto initData() {
// create test system
SysSystemDto system = helper.createSystem(TestResource.TABLE_NAME);
Assert.assertNotNull(system);
// 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.IDENTITY);
syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
createMapping(system, syncMapping);
this.getBean().initIdentityData();
return system;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class TreeProvisioningExecutor method findSystemMappingsForEntityType.
@Override
protected List<SysSystemMappingDto> findSystemMappingsForEntityType(IdmTreeNodeDto entity, SystemEntityType entityType) {
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(entityType);
mappingFilter.setTreeTypeId(entity.getTreeType());
mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
List<SysSystemMappingDto> systemMappings = systemMappingService.find(mappingFilter, null).getContent();
return systemMappings;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method getValueByMappedAttribute.
@Override
protected Object getValueByMappedAttribute(AttributeMapping attribute, List<IcAttribute> icAttributes, SynchronizationContext context) {
Object transformedValue = super.getValueByMappedAttribute(attribute, icAttributes, context);
if (transformedValue != null && PARENT_FIELD.equals(attribute.getIdmPropertyName())) {
String parentUid = transformedValue.toString();
SysSystemMappingDto systemMapping = systemMappingService.get(((SysSystemAttributeMappingDto) attribute).getSystemMapping());
SysSchemaObjectClassDto schemaObjectClass = schemaObjectClassService.get(systemMapping.getObjectClass());
UUID systemId = schemaObjectClass.getSystem();
// Find account by UID from parent field
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setUid(parentUid);
accountFilter.setSystemId(systemId);
transformedValue = null;
List<AccAccountDto> parentAccounts = accountService.find(accountFilter, null).getContent();
if (!parentAccounts.isEmpty()) {
UUID parentAccount = parentAccounts.get(0).getId();
// Find relation between tree and account
AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
treeAccountFilter.setAccountId(parentAccount);
List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
if (!treeAccounts.isEmpty()) {
// Find parent tree node by ID
// TODO: resolve more treeAccounts situations
// parent uuid - we are working with dtos
transformedValue = treeAccounts.get(0).getTreeNode();
} else {
LOG.warn("For parent UID: [{}] on system ID [{}] and acc account: [{}], was not found tree accounts! Return null value in parent!!", parentUid, systemId, parentAccount);
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_TREE_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentUid", parentUid, "systemId", systemId, "parentAccount", parentAccount));
}
} else {
LOG.warn("For parent UID: [{}] on system ID [{}], was not found parents account! Return null value in parent!!", parentUid, systemId);
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentUid", parentUid, "systemId", systemId));
}
}
return transformedValue;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createMappingSystem.
@Override
public SysSystemMappingDto createMappingSystem(SystemEntityType type, SysSchemaObjectClassDto objectClass) {
// system mapping
SysSystemMappingDto mapping = new SysSystemMappingDto();
mapping.setName(createName());
mapping.setEntityType(type);
mapping.setObjectClass(objectClass.getId());
mapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
//
return mappingService.save(mapping);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class AsynchronousAccountManagementIntegrationTest method testAsynchronousAccountManagementError.
@Test
public void testAsynchronousAccountManagementError() {
// add error to some script
SysSystemDto system = helper.createTestResourceSystem(true);
SysSystemMappingDto mapping = helper.getDefaultMapping(system);
SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(mapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
// username is transformed with error
attributeHandlingUserName.setTransformToResourceScript("returan \"" + "error" + "\";");
attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = helper.createRole();
helper.createRoleSystem(role, system);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
try {
helper.waitForResult(res -> {
return !(entityEventService.findByState(configurationService.getInstanceId(), OperationState.CREATED).isEmpty() && entityEventService.findByState(configurationService.getInstanceId(), OperationState.RUNNING).isEmpty());
});
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNull(account);
//
// find event result with exception
IdmEntityEventFilter eventFilter = new IdmEntityEventFilter();
eventFilter.setOwnerId(identityRole.getId());
eventFilter.setStates(Lists.newArrayList(OperationState.EXCEPTION));
List<IdmEntityEventDto> failedEvents = entityEventService.find(eventFilter, null).getContent();
//
Assert.assertEquals(1, failedEvents.size());
Assert.assertEquals(CoreResultCode.GROOVY_SCRIPT_EXCEPTION.getCode(), failedEvents.get(0).getResult().getCode());
} finally {
identityService.delete(identity);
systemService.delete(system);
}
}
Aggregations