use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class RoleSynchronizationExecutor method checkMembershipChange.
/**
* Check if role membership value is different.
*/
private void checkMembershipChange(IdmRoleDto dto, SynchronizationContext context, String attributeProperty, Object transformedValue) {
if (!context.isEntityDifferent() && dto.getId() != null && getConfig(context).isMembershipSwitch()) {
// Check if forward ACM value should be modified (differential sync).
SysSystemAttributeMappingDto memberOfAttributeDto = lookupService.lookupEmbeddedDto(getConfig(context), SysSyncRoleConfig_.memberOfAttribute);
Assert.notNull(memberOfAttributeDto, "Member attribute cannot be null!");
SysSchemaAttributeDto schemaAttributeDto = lookupService.lookupEmbeddedDto(memberOfAttributeDto, SysSystemAttributeMapping_.schemaAttribute);
SysSchemaObjectClassDto schemaObjectClassDto = lookupService.lookupEmbeddedDto(schemaAttributeDto, SysSchemaAttribute_.objectClass);
Assert.notNull(schemaObjectClassDto, "Schema cannot be null!");
String roleIdentifier = null;
if (transformedValue != null) {
Assert.isInstanceOf(String.class, transformedValue, "Role identifier must be String!");
roleIdentifier = (String) transformedValue;
} else {
// Identifier form transformation is null -> We will delete role-system relations.
setDifferentChange(context, attributeProperty);
return;
}
SysRoleSystemDto roleSystemDto = findRoleSystemDto(dto, memberOfAttributeDto, schemaObjectClassDto);
if (roleSystemDto != null) {
SysRoleSystemAttributeDto roleMemberOfAttributeDto = findMemberAttribute(memberOfAttributeDto, schemaObjectClassDto, roleSystemDto);
if (roleMemberOfAttributeDto == null) {
// Role attribute by mapping system attribute will be created.
setDifferentChange(context, attributeProperty);
return;
}
String membershipTransformationScript = getMembershipTransformationScript(roleIdentifier);
if (!roleMemberOfAttributeDto.getTransformScript().equals(membershipTransformationScript)) {
// Transformation script is different and will be updated.
setDifferentChange(context, attributeProperty);
}
} else {
// Role system will be created.
setDifferentChange(context, attributeProperty);
}
}
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class RoleWorkflowAdSyncTest method createMapping.
private void createMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
schemaAttributesPage.forEach(schemaAttr -> {
if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName("name");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_DN.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMappingTwo = new SysSystemAttributeMappingDto();
attributeMappingTwo.setIdmPropertyName(ATTRIBUTE_DN);
attributeMappingTwo.setEntityAttribute(false);
attributeMappingTwo.setExtendedAttribute(true);
attributeMappingTwo.setName("distinguishedName");
attributeMappingTwo.setSchemaAttribute(schemaAttr.getId());
attributeMappingTwo.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMappingTwo);
} else if (ATTRIBUTE_MEMBER.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMappingTwo = new SysSystemAttributeMappingDto();
attributeMappingTwo.setIdmPropertyName(ATTRIBUTE_MEMBER);
attributeMappingTwo.setEntityAttribute(false);
attributeMappingTwo.setExtendedAttribute(true);
attributeMappingTwo.setName(ATTRIBUTE_MEMBER);
attributeMappingTwo.setSchemaAttribute(schemaAttr.getId());
attributeMappingTwo.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMappingTwo);
}
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class TreeSyncTest method createMapping.
private void createMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
schemaAttributesPage.forEach(schemaAttr -> {
if (TestHelper.ATTRIBUTE_MAPPING_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setUid(true);
attributeHandlingName.setEntityAttribute(false);
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
// For provisioning .. we need create UID
attributeHandlingName.setTransformToResourceScript("if(uid){return uid;}\nreturn entity.getCode();");
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("CODE".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("code");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("PARENT".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("parent");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("NAME".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("name");
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
}
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class SystemMappingRoleCatalogueAutoAttributesProcessor method process.
@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
SysSystemMappingDto dto = event.getContent();
UUID schemaId = dto.getObjectClass();
if (schemaId == null) {
return new DefaultEventResult<>(event, this);
}
List<SysSchemaAttributeDto> schemaAttributes = getSchemaAttributes(schemaId);
// UID - code attribute
SysSchemaAttributeDto primarySchemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getPrimaryKeyCatalogue());
if (primarySchemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, primarySchemaAttribute, IdmRoleCatalogue_.code.getName(), true);
}
// Name attribute
SysSchemaAttributeDto schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getNameCatalogue());
if (schemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmRoleCatalogue_.name.getName(), false);
}
// Description attribute
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getDescriptionCatalogue());
if (schemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmRoleCatalogue_.description.getName(), false);
}
// Parent attribute
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getParentCatalogue());
if (schemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmRoleCatalogue_.parent.getName(), false);
}
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto in project CzechIdMng by bcvsolutions.
the class MsAdMappingIdentityAutoAttributesProcessor method process.
@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
SysSystemMappingDto dto = event.getContent();
UUID schemaId = dto.getObjectClass();
if (schemaId == null) {
return new DefaultEventResult<>(event, this);
}
List<SysSchemaAttributeDto> schemaAttributes = getSchemaAttributes(schemaId);
// UID attribute
SysSchemaAttributeDto primarySchemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getPrimaryKeyCatalogue());
if (primarySchemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, primarySchemaAttribute, IdmIdentity_.username.getName(), true);
}
// First name attribute
SysSchemaAttributeDto schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getFirstNameCatalogue());
if (schemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.firstName.getName(), false);
}
// Last name attribute
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getLastNameCatalogue());
if (schemaAttribute != null) {
createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.lastName.getName(), false);
}
// Display name attribute (script "getFullName")
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getDisplayName());
if (schemaAttribute != null) {
// Find "getFullName" script.
createAttributeWithScript(dto, schemaAttribute, FULL_NAME_SCRIPT, IdmScriptCategory.DEFAULT);
}
// Enable attribute (script "getOppositeBoolean")
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setObjectClassId(schemaId);
schemaAttributeFilter.setName(IcAttributeInfo.ENABLE);
SysSchemaAttributeDto enableAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (enableAttribute != null) {
SysSystemAttributeMappingDto attributeEnableWithScript = createAttributeWithScript(dto, enableAttribute, ENABLE_SCRIPT, IdmScriptCategory.TRANSFORM_TO);
if (attributeEnableWithScript != null) {
attributeEnableWithScript.setEntityAttribute(true);
attributeEnableWithScript.setIdmPropertyName(IdmIdentity_.disabled.getName());
systemAttributeMappingService.save(attributeEnableWithScript);
}
}
// Password attribute
schemaAttributeFilter.setName(IcAttributeInfo.PASSWORD);
SysSchemaAttributeDto passwordSchemaAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (passwordSchemaAttribute != null) {
SysSystemAttributeMappingDto passwordAttribute = createAttributeMappingBySchemaAttribute(dto, passwordSchemaAttribute, null, false);
if (passwordAttribute != null) {
passwordAttribute.setPasswordAttribute(true);
systemAttributeMappingService.save(passwordAttribute);
}
}
// Ldap groups (Merge)
schemaAttributeFilter.setName(AdUserConnectorType.LDAP_GROUPS_ATTRIBUTE);
SysSchemaAttributeDto ldapGroupsSchemaAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (ldapGroupsSchemaAttribute != null) {
SysSystemAttributeMappingDto ldapGroupsAttribute = createAttributeMappingBySchemaAttribute(dto, ldapGroupsSchemaAttribute, null, false);
if (ldapGroupsAttribute != null) {
ldapGroupsAttribute.setStrategyType(AttributeMappingStrategyType.MERGE);
systemAttributeMappingService.save(ldapGroupsAttribute);
}
}
// DN attribute ("__NAME__"). Use the getDefaultDN script.
SysSchemaAttributeDto dnAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getDNCode());
if (dnAttribute != null) {
SysSystemAttributeMappingDto attributeDnWithScript = createAttributeWithScript(dto, dnAttribute, DEFAULT_DN_SCRIPT, IdmScriptCategory.TRANSFORM_TO);
if (attributeDnWithScript != null) {
attributeDnWithScript.setEntityAttribute(true);
attributeDnWithScript.setIdmPropertyName(IdmIdentity_.username.getName());
systemAttributeMappingService.save(attributeDnWithScript);
// Add connectorObject to the context.
if (!dto.isAddContextConnectorObject()) {
dto.setAddContextConnectorObject(true);
systemMappingService.save(dto);
}
}
}
// UserPrincipalName attribute. Use the getUserPrincipalName script.
SysSchemaAttributeDto principleNameAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getUserPrincipalName());
if (principleNameAttribute != null) {
SysSystemAttributeMappingDto attributeWithScript = createAttributeWithScript(dto, principleNameAttribute, USER_PRINCIPAL_NAME_SCRIPT, IdmScriptCategory.TRANSFORM_TO);
if (attributeWithScript != null) {
// By default disabled.
attributeWithScript.setDisabledAttribute(true);
systemAttributeMappingService.save(attributeWithScript);
}
}
// Email attribute.
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getEmailCatalogue());
if (schemaAttribute != null) {
SysSystemAttributeMappingDto attribute = createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.email.getName(), false);
// Set attribute as disabled.
attribute.setDisabledAttribute(true);
systemAttributeMappingService.save(attribute);
}
// Department attribute.
// TODO: department - Name of a org ("c" = "CZ", "co" = "Česká republika")
// Manager attribute.
// TODO: manager - DN of the manager according to the primary contract.
// Employee ID attribute.
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getPersonalNumberCode());
if (schemaAttribute != null) {
SysSystemAttributeMappingDto attribute = createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.externalCode.getName(), false);
// Set attribute as send only if value exists in the IDM.
attribute.setSendOnlyIfNotNull(true);
systemAttributeMappingService.save(attribute);
}
// Phone attribute
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, this.getPhoneCatalogue());
if (schemaAttribute != null) {
SysSystemAttributeMappingDto attribute = createAttributeMappingBySchemaAttribute(dto, schemaAttribute, IdmIdentity_.phone.getName(), false);
// Set attribute as send only if value exists in the IDM.
attribute.setSendOnlyIfNotNull(true);
systemAttributeMappingService.save(attribute);
}
// PwdLastSet attribute (true only for create new account (force change of password))
schemaAttribute = getSchemaAttributeByCatalogue(schemaAttributes, Sets.newHashSet(PWD_LAST_SET_ATTRIBUTE_KEY));
if (schemaAttribute != null) {
SysSystemAttributeMappingDto attribute = createAttributeMappingByScriptToResource(dto, schemaAttribute, "return true;");
// Set attribute strategy as send only on create (true only for create new account (force change of password)).
attribute.setStrategyType(AttributeMappingStrategyType.CREATE);
systemAttributeMappingService.save(attribute);
}
DefaultEventResult<SysSystemMappingDto> resultEvent = new DefaultEventResult<>(event, this);
// Event will be end now. To prevent start default auto mapping processor.
resultEvent.setSuspended(true);
return resultEvent;
}
Aggregations