use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class CrossDomainAdUserConnectorTypeTest method testUpdateAccountInCrossDomainOnOneSystem.
@Test
public void testUpdateAccountInCrossDomainOnOneSystem() {
ConnectorType connectorType = connectorManager.getConnectorType(MockCrossDomainAdUserConnectorType.NAME);
// System one
SysSystemDto systemDto = initSystem(connectorType);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(systemDto.getId());
filter.setName(MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE);
List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(filter, null).getContent();
assertEquals(1, attributes.size());
SysSystemAttributeMappingDto ldapGroupsAttribute = attributes.stream().findFirst().get();
// System two
SysSystemDto systemTwoDto = initSystem(connectorType);
SysSystemAttributeMappingFilter filterTwo = new SysSystemAttributeMappingFilter();
filterTwo.setSystemId(systemTwoDto.getId());
filterTwo.setName(MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE);
List<SysSystemAttributeMappingDto> attributesTwo = attributeMappingService.find(filterTwo, null).getContent();
assertEquals(1, attributesTwo.size());
SysSystemAttributeMappingDto ldapGroupsAttributeTwo = attributesTwo.stream().findFirst().get();
// Creates cross-domain group.
SysSystemGroupDto groupSystemDto = new SysSystemGroupDto();
groupSystemDto.setCode(getHelper().createName());
groupSystemDto.setType(SystemGroupType.CROSS_DOMAIN);
groupSystemDto = systemGroupService.save(groupSystemDto);
SysSystemGroupSystemDto systemGroupSystemOne = new SysSystemGroupSystemDto();
systemGroupSystemOne.setSystemGroup(groupSystemDto.getId());
systemGroupSystemOne.setMergeAttribute(ldapGroupsAttribute.getId());
systemGroupSystemOne.setSystem(systemDto.getId());
systemGroupSystemService.save(systemGroupSystemOne);
SysSystemGroupSystemDto systemGroupSystemTwo = new SysSystemGroupSystemDto();
systemGroupSystemTwo.setSystemGroup(groupSystemDto.getId());
systemGroupSystemTwo.setMergeAttribute(ldapGroupsAttributeTwo.getId());
systemGroupSystemTwo.setSystem(systemTwoDto.getId());
systemGroupSystemService.save(systemGroupSystemTwo);
// Creates the login role ONE.
IdmRoleDto loginRole = helper.createRole();
helper.createRoleSystem(loginRole, systemDto);
// Creates the login role TWO.
IdmRoleDto loginRoleTwo = helper.createRole();
helper.createRoleSystem(loginRoleTwo, systemTwoDto);
// Creates cross-domain no-login role ONE.
IdmRoleDto noLoginRole = helper.createRole();
SysRoleSystemDto roleSystem = helper.createRoleSystem(noLoginRole, systemDto);
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setIsInCrossDomainGroupRoleId(noLoginRole.getId());
roleSystemFilter.setCheckIfIsInCrossDomainGroup(Boolean.TRUE);
roleSystemFilter.setId(roleSystem.getId());
List<SysRoleSystemDto> roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
assertEquals(0, roleSystemDtos.size());
createOverriddenLdapGroupAttribute(ldapGroupsAttribute, roleSystem);
// Creates cross-domain no-login role TWO.
SysRoleSystemDto roleSystemTwo = helper.createRoleSystem(noLoginRole, systemTwoDto);
SysRoleSystemFilter roleSystemFilterTwo = new SysRoleSystemFilter();
roleSystemFilterTwo.setIsInCrossDomainGroupRoleId(noLoginRole.getId());
roleSystemFilterTwo.setCheckIfIsInCrossDomainGroup(Boolean.TRUE);
roleSystemFilterTwo.setId(roleSystemTwo.getId());
List<SysRoleSystemDto> roleSystemDtosTwo = roleSystemService.find(roleSystemFilterTwo, null).getContent();
assertEquals(0, roleSystemDtosTwo.size());
createOverriddenLdapGroupAttribute(ldapGroupsAttributeTwo, roleSystemTwo, "return 'TWO';");
// Role-system should be in cross-domain group now.
roleSystemDtos = roleSystemService.find(roleSystemFilterTwo, null).getContent();
assertEquals(1, roleSystemDtos.size());
SysRoleSystemDto roleSystemDto = roleSystemDtos.stream().findFirst().get();
assertTrue(roleSystemDto.isInCrossDomainGroup());
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityContractDto contract = getHelper().createContract(identity);
mockCrossDomainAdUserConnectorType.setReadConnectorObjectCallBack((system, uid, objectClass) -> {
IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl(identity.getUsername(), null, null);
connectorObject.getAttributes().add(new IcAttributeImpl(MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE, "THREE"));
connectorObject.getAttributes().add(new IcAttributeImpl(MockCrossDomainAdUserConnectorType.SID_ATTRIBUTE_KEY, "SID".getBytes(StandardCharsets.UTF_8)));
return mockCrossDomainAdUserConnectorType.getCrossDomainConnectorObject(system, uid, objectClass, connectorObject);
});
// Assign login (ONE and TWO) and no-login roles.
// But no-login role will be set only on system two!
IdmRoleRequestDto roleRequestDto = getHelper().createRoleRequest(contract, noLoginRole, loginRole, loginRoleTwo);
List<IdmConceptRoleRequestDto> concepts = conceptRoleRequestService.findAllByRoleRequest(roleRequestDto.getId());
IdmConceptRoleRequestDto noLoginConcept = concepts.stream().filter(concept -> noLoginRole.getId().equals(concept.getRole())).findFirst().get();
assertNotNull(noLoginConcept);
noLoginConcept.setRoleSystem(roleSystemTwo.getId());
conceptRoleRequestService.save(noLoginConcept);
roleRequestDto = getHelper().executeRequest(roleRequestDto, true);
assertEquals(RoleRequestState.EXECUTED, roleRequestDto.getState());
assertNotNull(roleRequestDto.getSystemState());
IdmIdentityRoleDto identityRoleWithRoleSystemDto = identityRoleService.findAllByIdentity(identity.getId()).stream().filter(identityRole -> roleSystemTwo.getId().equals(identityRole.getRoleSystem())).findFirst().get();
assertNotNull(identityRoleWithRoleSystemDto);
AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
identityAccountFilter.setIdentityId(identity.getId());
assertEquals(2, identityAccountService.find(identityAccountFilter, null).getContent().size());
// Check if provisioning contains ldapGroups attribute with value ('ONE') from the role.
SysProvisioningOperationFilter provisioningOperationFilter = new SysProvisioningOperationFilter();
provisioningOperationFilter.setSystemId(systemDto.getId());
provisioningOperationFilter.setEntityType(SystemEntityType.IDENTITY);
provisioningOperationFilter.setEntityIdentifier(identity.getId());
List<SysProvisioningOperationDto> provisioningOperationDtos = provisioningOperationService.find(provisioningOperationFilter, null).getContent();
assertEquals(1, provisioningOperationDtos.size());
SysProvisioningOperationDto provisioningOperationDto = provisioningOperationDtos.stream().findFirst().get();
assertEquals(ProvisioningEventType.UPDATE, provisioningOperationDto.getOperationType());
ProvisioningAttributeDto provisioningAttributeLdapGroupsDto = provisioningOperationDto.getProvisioningContext().getAccountObject().keySet().stream().filter(provisioningAtt -> MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE.equals(provisioningAtt.getSchemaAttributeName())).findFirst().get();
assertNotNull(provisioningAttributeLdapGroupsDto);
Object ldapGroupsValue = provisioningOperationDto.getProvisioningContext().getAccountObject().get(provisioningAttributeLdapGroupsDto);
assertEquals(0, ((List<?>) ldapGroupsValue).size());
IcAttribute ldapGroups = provisioningOperationDto.getProvisioningContext().getConnectorObject().getAttributeByName(MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE);
IcAttribute ldapGroupsOld = provisioningOperationDto.getProvisioningContext().getConnectorObject().getAttributeByName(MessageFormat.format(MockCrossDomainAdUserConnectorType.OLD_ATTRIBUTE_PATTERN, MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE));
assertNull(ldapGroups);
assertNull(ldapGroupsOld);
// Check if provisioning contains ldapGroups attribute with value ('TWO') from the role.
provisioningOperationFilter = new SysProvisioningOperationFilter();
provisioningOperationFilter.setSystemId(systemTwoDto.getId());
provisioningOperationFilter.setEntityType(SystemEntityType.IDENTITY);
provisioningOperationFilter.setEntityIdentifier(identity.getId());
provisioningOperationDtos = provisioningOperationService.find(provisioningOperationFilter, null).getContent();
assertEquals(1, provisioningOperationDtos.size());
provisioningOperationDto = provisioningOperationDtos.stream().findFirst().get();
assertEquals(ProvisioningEventType.UPDATE, provisioningOperationDto.getOperationType());
provisioningAttributeLdapGroupsDto = provisioningOperationDto.getProvisioningContext().getAccountObject().keySet().stream().filter(provisioningAtt -> MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE.equals(provisioningAtt.getSchemaAttributeName())).findFirst().get();
assertNotNull(provisioningAttributeLdapGroupsDto);
ldapGroupsValue = provisioningOperationDto.getProvisioningContext().getAccountObject().get(provisioningAttributeLdapGroupsDto);
assertEquals(1, ((List<?>) ldapGroupsValue).size());
assertTrue(((List<?>) ldapGroupsValue).stream().anyMatch(value -> value.equals("TWO")));
ldapGroups = provisioningOperationDto.getProvisioningContext().getConnectorObject().getAttributeByName(MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE);
ldapGroupsOld = provisioningOperationDto.getProvisioningContext().getConnectorObject().getAttributeByName(MessageFormat.format(MockCrossDomainAdUserConnectorType.OLD_ATTRIBUTE_PATTERN, MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE));
assertNotNull(ldapGroups);
assertTrue(ldapGroups.getValues().stream().anyMatch(value -> value.equals("TWO")));
assertTrue(ldapGroups.getValues().stream().anyMatch(value -> value.equals("THREE")));
assertNotNull(ldapGroupsOld);
assertEquals(2, ldapGroupsOld.getValues().size());
assertTrue(ldapGroupsOld.getValues().stream().anyMatch(value -> value.equals("THREE")));
assertTrue(ldapGroupsOld.getValues().stream().anyMatch(value -> value.equals("EXTERNAL_ONE")));
// Clean
provisioningOperationService.deleteOperations(systemDto.getId());
provisioningOperationService.deleteOperations(systemTwoDto.getId());
systemGroupService.delete(groupSystemDto);
getHelper().deleteIdentity(identity.getId());
mockCrossDomainAdUserConnectorType.setReadConnectorObjectCallBack(null);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class CrossDomainAdUserConnectorTypeTest method testRoleInCrossDomainGroupCannotCreateAccountForAutomaticRole.
@Test
public void testRoleInCrossDomainGroupCannotCreateAccountForAutomaticRole() {
ConnectorType connectorType = connectorManager.getConnectorType(MockCrossDomainAdUserConnectorType.NAME);
SysSystemDto systemDto = initSystem(connectorType);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(systemDto.getId());
filter.setName(MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE);
List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(filter, null).getContent();
assertEquals(1, attributes.size());
SysSystemAttributeMappingDto ldapGroupsAttribute = attributes.stream().findFirst().get();
// Creates cross-domain group.
SysSystemGroupDto groupSystemDto = new SysSystemGroupDto();
groupSystemDto.setCode(getHelper().createName());
groupSystemDto.setType(SystemGroupType.CROSS_DOMAIN);
groupSystemDto = systemGroupService.save(groupSystemDto);
SysSystemGroupSystemDto systemGroupSystemOne = new SysSystemGroupSystemDto();
systemGroupSystemOne.setSystemGroup(groupSystemDto.getId());
systemGroupSystemOne.setMergeAttribute(ldapGroupsAttribute.getId());
systemGroupSystemOne.setSystem(systemDto.getId());
systemGroupSystemService.save(systemGroupSystemOne);
// Creates the login role.
IdmRoleDto loginRole = helper.createRole();
helper.createRoleSystem(loginRole, systemDto);
// Creates no-login role.
IdmRoleDto noLoginRole = helper.createRole();
SysRoleSystemDto roleSystem = helper.createRoleSystem(noLoginRole, systemDto);
roleSystem.setCreateAccountByDefault(true);
roleSystemService.save(roleSystem);
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setIsInCrossDomainGroupRoleId(noLoginRole.getId());
roleSystemFilter.setCheckIfIsInCrossDomainGroup(Boolean.TRUE);
roleSystemFilter.setId(roleSystem.getId());
List<SysRoleSystemDto> roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
assertEquals(0, roleSystemDtos.size());
// Creates overridden ldapGroup merge attribute.
createOverriddenLdapGroupAttribute(ldapGroupsAttribute, roleSystem);
// Role-system should be in cross-domain group now.
roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
assertEquals(1, roleSystemDtos.size());
SysRoleSystemDto roleSystemDto = roleSystemDtos.stream().findFirst().get();
assertTrue(roleSystemDto.isInCrossDomainGroup());
String automaticRoleValue = getHelper().createName();
IdmAutomaticRoleAttributeDto automaticRole = getHelper().createAutomaticRole(noLoginRole.getId());
getHelper().createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY, IdmIdentity_.description.getName(), null, automaticRoleValue);
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityContractDto contract = getHelper().getPrimeContract(identity.getId());
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityId(identity.getId());
identityRoleFilter.setRoleId(noLoginRole.getId());
assertEquals(0, identityRoleService.count(identityRoleFilter));
// Assign automatic role.
identity.setDescription(automaticRoleValue);
identityService.save(identity);
assertEquals(1, identityRoleService.count(identityRoleFilter));
AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
identityAccountFilter.setIdentityId(identity.getId());
identityAccountFilter.setSystemId(systemDto.getId());
assertEquals(0, identityAccountService.find(identityAccountFilter, null).getContent().size());
IdmRoleRequestDto roleRequestDto = getHelper().assignRoles(contract, false, loginRole);
assertEquals(RoleRequestState.EXECUTED, roleRequestDto.getState());
assertNotNull(roleRequestDto.getSystemState());
assertEquals(1, identityAccountService.find(identityAccountFilter, null).getContent().size());
// Check if provisioning contains ldapGroups attribute with value ('ONE') from the role.
SysProvisioningOperationFilter provisioningOperationFilter = new SysProvisioningOperationFilter();
provisioningOperationFilter.setSystemId(systemDto.getId());
provisioningOperationFilter.setEntityType(SystemEntityType.IDENTITY);
provisioningOperationFilter.setEntityIdentifier(identity.getId());
List<SysProvisioningOperationDto> provisioningOperationDtos = provisioningOperationService.find(provisioningOperationFilter, null).getContent();
assertEquals(1, provisioningOperationDtos.size());
SysProvisioningOperationDto provisioningOperationDto = provisioningOperationDtos.stream().findFirst().get();
ProvisioningAttributeDto provisioningAttributeLdapGroupsDto = provisioningOperationDto.getProvisioningContext().getAccountObject().keySet().stream().filter(provisioningAtt -> MockCrossDomainAdUserConnectorType.LDAP_GROUPS_ATTRIBUTE.equals(provisioningAtt.getSchemaAttributeName())).findFirst().get();
assertNotNull(provisioningAttributeLdapGroupsDto);
Object ldapGroupsValue = provisioningOperationDto.getProvisioningContext().getAccountObject().get(provisioningAttributeLdapGroupsDto);
assertEquals("ONE", ((List<?>) ldapGroupsValue).get(0));
// Clean
provisioningOperationService.deleteOperations(systemDto.getId());
getHelper().deleteIdentity(identity.getId());
automaticRoleAttributeService.delete(automaticRole);
getHelper().deleteRole(noLoginRole.getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method initData.
private void initData() {
// create test system
SysSystemDto system = helper.createTestResourceSystem(true, SYSTEM_NAME);
//
// Create test identity for provisioning test
IdmIdentityDto identity = new IdmIdentityDto();
identity.setUsername(IDENTITY_USERNAME);
identity.setFirstName(IDENTITY_USERNAME);
identity.setLastName(IDENTITY_USERNAME);
identity.setEmail(IDENTITY_EMAIL);
identity = identityService.save(identity);
// Create mapped attributes to schema
SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
SysSystemAttributeMappingDto attributeHandlingLastName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), helper.getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_LASTNAME));
SysSystemAttributeMappingDto attributeHandlingFirstName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), helper.getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME));
SysSystemAttributeMappingDto attributeHandlingUserName = schemaAttributeHandlingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_NAME);
// username is transformed
attributeHandlingUserName.setTransformToResourceScript("return \"" + "x" + IDENTITY_USERNAME + "\";");
attributeHandlingUserName = schemaAttributeHandlingService.save(attributeHandlingUserName);
/*
* Create role with link on system (default)
*/
IdmRoleDto roleDefault = new IdmRoleDto();
roleDefault.setCode(ROLE_DEFAULT);
roleDefault = roleService.save(roleDefault);
SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
roleSystemDefault.setRole(roleDefault.getId());
roleSystemDefault.setSystem(system.getId());
roleSystemDefault.setSystemMapping(systemMapping.getId());
roleSystemDefault = roleSystemService.save(roleSystemDefault);
/*
* Create role with link on system (overloading last name attribute)
*/
IdmRoleDto roleOverloadingLastName = new IdmRoleDto();
roleOverloadingLastName.setCode(ROLE_OVERLOADING_LAST_NAME);
roleOverloadingLastName = roleService.save(roleOverloadingLastName);
SysRoleSystemDto roleSystemLastName = new SysRoleSystemDto();
roleSystemLastName.setRole(roleOverloadingLastName.getId());
roleSystemLastName.setSystem(system.getId());
roleSystemLastName.setSystemMapping(systemMapping.getId());
roleSystemLastName = roleSystemService.save(roleSystemLastName);
// Attribute for overloading last name attribute
SysRoleSystemAttributeDto attributeLastName = new SysRoleSystemAttributeDto();
attributeLastName.setEntityAttribute(true);
attributeLastName.setIdmPropertyName("email");
attributeLastName.setName("Overloaded lastName with email");
attributeLastName.setRoleSystem(roleSystemLastName.getId());
attributeLastName.setSystemAttributeMapping(attributeHandlingLastName.getId());
attributeLastName = roleSystemAttributeService.save(attributeLastName);
/*
* Create role with link on system (overloading password attribute)
*/
IdmRoleDto roleOverloadingPassword = new IdmRoleDto();
// Since 9.3.0 password can't be overridden
roleOverloadingPassword.setCode(ROLE_OVERLOADING_PASSWORD);
roleOverloadingPassword = roleService.save(roleOverloadingPassword);
SysRoleSystemDto roleSystemPassword = new SysRoleSystemDto();
roleSystemPassword.setRole(roleOverloadingPassword.getId());
roleSystemPassword.setSystem(system.getId());
roleSystemPassword.setSystemMapping(systemMapping.getId());
roleSystemPassword = roleSystemService.save(roleSystemPassword);
/*
* Create role with link on system (overloading (disable) first name
* attribute)
*/
IdmRoleDto roleOverloadingFirstName = new IdmRoleDto();
roleOverloadingFirstName.setCode(ROLE_OVERLOADING_FIRST_NAME);
roleOverloadingFirstName = roleService.save(roleOverloadingFirstName);
SysRoleSystemDto roleSystemFirstName = new SysRoleSystemDto();
roleSystemFirstName.setRole(roleOverloadingFirstName.getId());
roleSystemFirstName.setSystem(system.getId());
roleSystemFirstName.setSystemMapping(systemMapping.getId());
roleSystemFirstName = roleSystemService.save(roleSystemFirstName);
// Attribute for overloading first name attribute (disable him)
SysRoleSystemAttributeDto attributeFirstName = new SysRoleSystemAttributeDto();
attributeFirstName.setDisabledDefaultAttribute(true);
attributeFirstName.setName("Disable first name");
attributeFirstName.setRoleSystem(roleSystemFirstName.getId());
attributeFirstName.setSystemAttributeMapping(attributeHandlingFirstName.getId());
attributeFirstName = roleSystemAttributeService.save(attributeFirstName);
/*
* Create role with link on system (overloading name attribute ...
* create Y account)
*/
IdmRoleDto roleOverloadingName = new IdmRoleDto();
roleOverloadingName.setCode(ROLE_OVERLOADING_Y_ACCOUNT);
roleOverloadingName = roleService.save(roleOverloadingName);
SysRoleSystemDto roleSystemName = new SysRoleSystemDto();
roleSystemName.setRole(roleOverloadingName.getId());
roleSystemName.setSystem(system.getId());
roleSystemName.setSystemMapping(systemMapping.getId());
roleSystemName = roleSystemService.save(roleSystemName);
// Attribute for overloading first name attribute (disable him)
SysRoleSystemAttributeDto attributeName = new SysRoleSystemAttributeDto();
attributeName.setUid(true);
attributeName.setEntityAttribute(true);
attributeName.setIdmPropertyName("username");
attributeName.setName("Account with Y-prefix name");
attributeName.setTransformScript("return \"y\" + attributeValue ;");
attributeName.setRoleSystem(roleSystemName.getId());
attributeName.setSystemAttributeMapping(attributeHandlingUserName.getId());
attributeName = roleSystemAttributeService.save(attributeName);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingService method createMappingIdmPath.
/**
* Creates a list of attribute mapping info from which an error originates
* Contains: system name / mapping or role name / mapped attribute name
*
* @param attributeMapping
* @return
*/
private List<String> createMappingIdmPath(AttributeMapping attributeMapping) {
List<String> path = new ArrayList<>();
// attribute name
path.add(String.format("Attr: %s", attributeMapping.getName()));
// role and system mapping name
SysSystemAttributeMappingDto sysMapping = null;
if (attributeMapping instanceof SysRoleSystemAttributeDto) {
SysRoleSystemAttributeDto mapping = (SysRoleSystemAttributeDto) attributeMapping;
// get role name
SysRoleSystemDto roleSystem = DtoUtils.getEmbedded(mapping, SysRoleSystemAttribute_.roleSystem, SysRoleSystemDto.class, null);
// mapping name and role name are not be available in case of script pre-evaluation during saving
if (roleSystem != null) {
IdmRoleDto roleDto = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.role, IdmRoleDto.class);
path.add(String.format("Role: %s", roleDto.getCode()));
sysMapping = DtoUtils.getEmbedded(mapping, SysRoleSystemAttribute_.systemAttributeMapping, SysSystemAttributeMappingDto.class, null);
}
} else if (attributeMapping instanceof SysSystemAttributeMappingDto) {
sysMapping = (SysSystemAttributeMappingDto) attributeMapping;
}
if (sysMapping != null) {
String mappingName = DtoUtils.getEmbedded(sysMapping, SysSystemAttributeMapping_.systemMapping, SysSystemMappingDto.class).getName();
path.add(String.format("Mapping: %s", mappingName));
}
// system name
path.add(String.format("System: %s", getSystemFromAttributeMapping(attributeMapping).getCode()));
return path;
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemService method internalExport.
@Override
protected SysRoleSystemDto internalExport(UUID id) {
SysRoleSystemDto roleSystemDto = this.get(id);
// We cannot clear all embedded data, because we need to export DTO for connected role.
BaseDto roleDto = roleSystemDto.getEmbedded().get(SysRoleSystem_.role.getName());
roleSystemDto.getEmbedded().clear();
roleSystemDto.getEmbedded().put(SysRoleSystem_.role.getName(), roleDto);
return roleSystemDto;
}
Aggregations