use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningExecutor method resolveMappedAttributes.
/**
* Return all mapped attributes for this account (include overloaded
* attributes)
*
* @param uid
* @param account
* @param entity
* @param system
* @param entityType
* @return
*/
@Override
public List<AttributeMapping> resolveMappedAttributes(AccAccountDto account, DTO dto, SysSystemDto system, SystemEntityType entityType) {
EntityAccountFilter filter = this.createEntityAccountFilter();
filter.setEntityId(dto.getId());
filter.setSystemId(system.getId());
filter.setOwnership(Boolean.TRUE);
filter.setAccountId(account.getId());
List<? extends EntityAccountDto> entityAccoutnList = this.getEntityAccountService().find(filter, null).getContent();
if (entityAccoutnList == null) {
return null;
}
// All identity account with flag ownership on true
// All role system attributes (overloading) for this uid and same system
List<SysRoleSystemAttributeDto> roleSystemAttributesAll = findOverloadingAttributes(dto, system, entityAccoutnList, entityType);
// All default mapped attributes from system
List<? extends AttributeMapping> defaultAttributes = findAttributeMappings(system, entityType);
// Final list of attributes use for provisioning
return compileAttributes(defaultAttributes, roleSystemAttributesAll, entityType);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.
the class IdentityProvisioningExecutor method findOverloadingAttributes.
/**
* Return list of all overloading attributes for given identity, system and
* uid
*
* @param identityAccount
* @param idenityAccoutnList
* @param operationType
* @param entityType
* @return
*/
@Override
protected List<SysRoleSystemAttributeDto> findOverloadingAttributes(IdmIdentityDto entity, SysSystemDto system, List<? extends EntityAccountDto> idenityAccoutnList, SystemEntityType entityType) {
List<SysRoleSystemAttributeDto> roleSystemAttributesAll = new ArrayList<>();
idenityAccoutnList.stream().filter(ia -> {
AccAccountDto account = DtoUtils.getEmbedded((AccIdentityAccountDto) ia, AccIdentityAccount_.account, AccAccountDto.class);
return ((AccIdentityAccountDto) ia).getIdentityRole() != null && account.getSystem() != null && account.getSystem().equals(system.getId()) && ia.isOwnership();
}).forEach((identityAccountInner) -> {
AbstractDto identityAccount = (AbstractDto) identityAccountInner;
// All identity account with same system and with filled
// identityRole
AccAccountDto account = DtoUtils.getEmbedded(identityAccount, AccIdentityAccount_.account, AccAccountDto.class);
IdmIdentityRoleDto identityRole = DtoUtils.getEmbedded(identityAccount, AccIdentityAccount_.identityRole, IdmIdentityRoleDto.class);
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setRoleId(identityRole.getRole());
roleSystemFilter.setSystemId(account.getSystem());
List<SysRoleSystemDto> roleSystems = roleSystemService.find(roleSystemFilter, null).getContent();
if (roleSystems.size() > 1) {
SysRoleSystemDto roleSystem = roleSystems.get(0);
IdmRoleDto roleDto = roleService.get(roleSystem.getRole());
SysSystemDto systemDto = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.system, SysSystemDto.class);
throw new ProvisioningException(AccResultCode.PROVISIONING_DUPLICATE_ROLE_MAPPING, ImmutableMap.of("role", roleDto.getName(), "system", systemDto.getName(), "entityType", entityType));
}
if (!roleSystems.isEmpty()) {
SysRoleSystemDto roleSystem = roleSystems.get(0);
SysRoleSystemAttributeFilter roleSystemAttributeFilter = new SysRoleSystemAttributeFilter();
roleSystemAttributeFilter.setRoleSystemId(roleSystem.getId());
List<SysRoleSystemAttributeDto> roleAttributes = roleSystemAttributeService.find(roleSystemAttributeFilter, null).getContent();
if (!CollectionUtils.isEmpty(roleAttributes)) {
roleSystemAttributesAll.addAll(roleAttributes);
}
}
});
return roleSystemAttributesAll;
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemAttributeService method addRoleMappingAttribute.
@Transactional
@Override
public SysRoleSystemAttributeDto addRoleMappingAttribute(UUID systemId, UUID roleId, String attributeName, String transformationScript, String objectClassName) {
// ObjectClassName "__ACCOUNT__"
Assert.notNull(systemId, "SystemId cannot be null!");
Assert.notNull(roleId, "RoleId cannot be null!");
Assert.notNull(attributeName, "Attribute name cannot be null");
Assert.hasLength(attributeName, "Attribute name cannot be blank");
UUID roleSystemId = getSysRoleSystem(systemId, roleId, objectClassName);
SysRoleSystemAttributeDto systemAttribute = getSystemAttribute(roleSystemId, attributeName);
if (systemAttribute == null) {
systemAttribute = new SysRoleSystemAttributeDto();
}
systemAttribute.setEntityAttribute(false);
systemAttribute.setStrategyType(AttributeMappingStrategyType.MERGE);
UUID systemAttributeMappingId = getSystemAttributeMapping(systemId, attributeName, objectClassName).getId();
systemAttribute.setName(attributeName);
systemAttribute.setRoleSystem(roleSystemId);
systemAttribute.setSystemAttributeMapping(systemAttributeMappingId);
//
if (transformationScript != null) {
systemAttribute.setTransformScript(transformationScript);
}
return this.save(systemAttribute);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemAttributeService method save.
@Override
@Transactional
public SysRoleSystemAttributeDto save(SysRoleSystemAttributeDto dto, BasePermission... permission) {
SysRoleSystemAttributeDto savedDto = super.save(dto, permission);
SysSystemAttributeMappingDto attributeMappingDto = systemAttributeMappingService.get(savedDto.getSystemAttributeMapping());
// If is mapped attribute marks as evicted, then we will start LRT for recalculation controlled values
if (!systemAttributeMappingService.isNew(attributeMappingDto) && attributeMappingDto.isEvictControlledValuesCache() == true) {
// Since 9.7.5 is recalculation is disabled ... caused many problem because is async and is call redundantly when are attributes changed in some bulk operations (WF ...).
// Attribute is marks as evicted now only and will be recalculated during first provisioning.
recalculationOfControlledValues(attributeMappingDto);
}
return savedDto;
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountManagementService method generateUID.
/**
* Return UID for this identity and roleSystem. First will be find and use
* transform script from roleSystem attribute. If isn't UID attribute for
* roleSystem defined, then will be use default UID attribute handling.
*
* @param entity
* @param roleSystem
* @return
*/
@Override
public String generateUID(AbstractDto entity, SysRoleSystemDto roleSystem) {
// Find attributes for this roleSystem
SysRoleSystemAttributeFilter roleSystemAttrFilter = new SysRoleSystemAttributeFilter();
roleSystemAttrFilter.setRoleSystemId(roleSystem.getId());
roleSystemAttrFilter.setIsUid(Boolean.TRUE);
List<SysRoleSystemAttributeDto> attributesUid = roleSystemAttributeService.find(roleSystemAttrFilter, //
null).getContent();
if (attributesUid.size() > 1) {
IdmRoleDto roleDto = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.role);
SysSystemDto systemDto = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.system);
throw new ProvisioningException(AccResultCode.PROVISIONING_ROLE_ATTRIBUTE_MORE_UID, ImmutableMap.of("role", roleDto.getCode(), "system", systemDto.getName()));
}
SysRoleSystemAttributeDto uidRoleAttribute = !attributesUid.isEmpty() ? attributesUid.get(0) : null;
// script.
if (uidRoleAttribute != null) {
// Default values (values from schema attribute handling)
SysSystemAttributeMappingDto systemAttributeMapping = DtoUtils.getEmbedded(uidRoleAttribute, SysRoleSystemAttribute_.systemAttributeMapping.getName(), SysSystemAttributeMappingDto.class);
uidRoleAttribute.setSchemaAttribute(systemAttributeMapping.getSchemaAttribute());
uidRoleAttribute.setTransformFromResourceScript(systemAttributeMapping.getTransformFromResourceScript());
Object uid = systemAttributeMappingService.getAttributeValue(null, entity, uidRoleAttribute);
if (uid == null) {
SysSystemDto systemEntity = DtoUtils.getEmbedded(roleSystem, SysRoleSystem_.system);
throw new ProvisioningException(AccResultCode.PROVISIONING_GENERATED_UID_IS_NULL, ImmutableMap.of("system", systemEntity.getName()));
}
if (!(uid instanceof String)) {
throw new ProvisioningException(AccResultCode.PROVISIONING_ATTRIBUTE_UID_IS_NOT_STRING, ImmutableMap.of("uid", uid));
}
return (String) uid;
}
// If roleSystem UID was not found, then we use default UID schema
// attribute handling
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(roleSystem.getSystemMapping());
attributeMappingFilter.setIsUid(Boolean.TRUE);
attributeMappingFilter.setDisabledAttribute(Boolean.FALSE);
List<SysSystemAttributeMappingDto> defaultUidAttributes = systemAttributeMappingService.find(attributeMappingFilter, null).getContent();
if (defaultUidAttributes.size() == 1) {
return systemAttributeMappingService.generateUid(entity, defaultUidAttributes.get(0));
}
// Default UID attribute was not correctly found, getUidAttribute method will be throw exception.
// This is good time for loading the system (is used in exception message)
SysSystemMappingDto mapping = systemMappingService.get(roleSystem.getSystemMapping());
SysSchemaObjectClassDto objectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(objectClassDto, SysSchemaObjectClass_.system);
systemAttributeMappingService.getUidAttribute(defaultUidAttributes, system);
// Exception occurred
return null;
}
Aggregations