use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingServiceTest method treeTypeIdFilterTest.
@Test
public void treeTypeIdFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
IdmTreeTypeDto treeType = new IdmTreeTypeDto();
treeType.setName("SomeTreeTypeName");
treeType.setCode("CodeCodeCodeCode");
treeType = treeTypeService.save(treeType);
IdmTreeTypeDto treeType2 = new IdmTreeTypeDto();
treeType2.setName("SomeTreeTypeName2");
treeType2.setCode("CodeCodeCodeCode2");
treeType2 = treeTypeService.save(treeType2);
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem1.setTreeType(treeType.getId());
mappingSystem1 = mappingService.save(mappingSystem1);
SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem2.setTreeType(treeType2.getId());
mappingSystem2 = mappingService.save(mappingSystem2);
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setTreeTypeId(mappingSystem1.getTreeType());
Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(mappingSystem1));
assertFalse(result.getContent().contains(mappingSystem2));
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationService method resolveUnlinkedSituation.
@Override
public SysSyncItemLogDto resolveUnlinkedSituation(String uid, SystemEntityType entityType, UUID entityId, UUID configId, String actionType) {
Assert.notNull(uid);
Assert.notNull(entityType);
Assert.notNull(configId);
Assert.notNull(actionType);
Assert.notNull(entityId);
AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto sysSchemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(sysSchemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
SysSystemEntityDto systemEntity = findSystemEntity(uid, system, entityType);
SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
SynchronizationContext context = new SynchronizationContext();
context.addUid(uid).addSystem(system).addConfig(config).addEntityType(entityType).addEntityId(entityId).addSystemEntity(systemEntity);
getSyncExecutor(entityType).resolveUnlinkedSituation(SynchronizationUnlinkedActionType.valueOf(actionType), context);
return itemLog;
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class VsReqeustServiceTest method checkMultivalueInWishObjectTest.
@Test
public void checkMultivalueInWishObjectTest() {
String ldapGroupsName = "ldapGroups";
String changed = "changed";
List<String> attributes = new ArrayList<>(Lists.newArrayList(BasicVirtualConfiguration.DEFAULT_ATTRIBUTES));
attributes.add(ldapGroupsName);
// Create virtual system with extra attribute (ldapGroups)
SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, attributes);
// Search attribute definition for ldapGroups and set him to multivalue
String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", system.getConnectorKey().getFullName(), system.getId().toString());
String type = VsAccount.class.getName();
IdmFormDefinitionDto definition = this.formService.getDefinition(type, virtualSystemKey);
IdmFormAttributeDto ldapGroupsFormAttr = formAttributeService.findAttribute(VsAccount.class.getName(), definition.getCode(), ldapGroupsName);
Assert.assertNotNull("Ldap attribute muste exist!", ldapGroupsFormAttr);
ldapGroupsFormAttr.setMultiple(true);
formService.saveAttribute(ldapGroupsFormAttr);
// Generate schema for system (we need propagate multivalue setting)
SysSchemaObjectClassDto schema = systemService.generateSchema(system).get(0);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
SysSystemMappingFilter systemMappingFilter = new SysSystemMappingFilter();
systemMappingFilter.setSystemId(system.getId());
systemMappingFilter.setObjectClassId(schema.getId());
SysSystemMappingDto mapping = systemMappingService.find(systemMappingFilter, null).getContent().get(0);
for (SysSchemaAttributeDto schemaAttr : schemaAttributes) {
if (ldapGroupsName.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(false);
attributeMapping.setEntityAttribute(false);
attributeMapping.setExtendedAttribute(true);
attributeMapping.setIdmPropertyName(ldapGroupsName);
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(mapping.getId());
systemAttributeMappingService.save(attributeMapping);
}
}
IdmIdentityDto userOne = helper.createIdentity(USER_ONE_NAME);
List<Serializable> initList = ImmutableList.of("TEST1", "TEST2", "TEST3");
formService.saveValues(userOne, ldapGroupsName, initList);
this.assignRoleSystem(system, userOne, ROLE_ONE_NAME);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(USER_ONE_NAME);
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto createRequest = requests.get(0);
Assert.assertEquals(USER_ONE_NAME, createRequest.getUid());
Assert.assertEquals(VsOperationType.CREATE, createRequest.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, createRequest.getState());
VsConnectorObjectDto wish = requestService.getWishConnectorObject(createRequest);
boolean findAttributeWithouChange = wish.getAttributes().stream().filter(attribute -> !attribute.isChanged()).findFirst().isPresent();
Assert.assertTrue(!findAttributeWithouChange);
// Check on exist ldapGroups attribute with three values
VsAttributeDto ldapGroupAttribute = wish.getAttributes().stream().filter(attribute -> ldapGroupsName.equals(attribute.getName())).findFirst().get();
Assert.assertTrue(ldapGroupAttribute.isMultivalue());
Assert.assertEquals(3, ldapGroupAttribute.getValues().size());
// Change multivalue attribute
List<Serializable> changeList = ImmutableList.of("TEST1", changed, "TEST3");
formService.saveValues(userOne, ldapGroupsName, changeList);
// Invoke provisioning
identityService.save(userOne);
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(2, requests.size());
VsRequestDto changeRequest = requests.stream().filter(req -> VsOperationType.UPDATE == req.getOperationType()).findFirst().get();
wish = requestService.getWishConnectorObject(changeRequest);
ldapGroupAttribute = wish.getAttributes().stream().filter(attribute -> ldapGroupsName.equals(attribute.getName())).findFirst().get();
Assert.assertTrue(ldapGroupAttribute.isMultivalue());
// Wish must contains three values (all add) ... because previous create
// request is not realize yet. Wish show changes versus reals state in
// VsAccount.
Assert.assertEquals(3, ldapGroupAttribute.getValues().size());
// We realize the create request
super.logout();
loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
requestService.realize(createRequest);
// Refresh wish
wish = requestService.getWishConnectorObject(changeRequest);
ldapGroupAttribute = wish.getAttributes().stream().filter(attribute -> ldapGroupsName.equals(attribute.getName())).findFirst().get();
Assert.assertTrue(ldapGroupAttribute.isMultivalue());
// Wish must contains four values ... two without change, one delete and
// one add value
Assert.assertEquals(4, ldapGroupAttribute.getValues().size());
// Find unchanged value
boolean findCorrectTest1Value = ldapGroupAttribute.getValues().stream().filter(value -> value.getValue().equals(initList.get(0)) && value.getOldValue().equals(initList.get(0)) && value.getChange() == null).findFirst().isPresent();
Assert.assertTrue(findCorrectTest1Value);
// Find deleted value
boolean findCorrectDeletedTest2Value = ldapGroupAttribute.getValues().stream().filter(value -> value.getValue().equals(initList.get(1)) && value.getOldValue().equals(initList.get(1)) && VsValueChangeType.REMOVED == value.getChange()).findFirst().isPresent();
Assert.assertTrue(findCorrectDeletedTest2Value);
// Find added value
boolean findCorrectCreatedChangedValue = ldapGroupAttribute.getValues().stream().filter(value -> value.getValue().equals(changed) && value.getOldValue() == null && VsValueChangeType.ADDED == value.getChange()).findFirst().isPresent();
Assert.assertTrue(findCorrectCreatedChangedValue);
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorType method load.
@Override
public ConnectorTypeDto load(ConnectorTypeDto connectorType) {
super.load(connectorType);
if (!connectorType.isReopened()) {
connectorType.getMetadata().put(REGENERATE_SCHEMA_SWITCH, Boolean.TRUE.toString());
return connectorType;
}
connectorType.getMetadata().put(REGENERATE_SCHEMA_SWITCH, Boolean.FALSE.toString());
// Load the system.
SysSystemDto systemDto = (SysSystemDto) connectorType.getEmbedded().get(SYSTEM_DTO_KEY);
Assert.notNull(systemDto, "System must exists!");
connectorType.getMetadata().put(SYSTEM_NAME, systemDto.getName());
Map<String, String> metadata = connectorType.getMetadata();
IdmFormDefinitionDto connectorFormDef = this.getSystemService().getConnectorFormDefinition(systemDto);
// Find attribute with port.
metadata.put(PORT, getValueFromConnectorInstance(PORT, systemDto, connectorFormDef));
// Find attribute with host.
metadata.put(HOST, getValueFromConnectorInstance(HOST, systemDto, connectorFormDef));
// Find attribute with user.
metadata.put(USER, getValueFromConnectorInstance(PRINCIPAL, systemDto, connectorFormDef));
// Find attribute with ssl switch.
metadata.put(SSL_SWITCH, getValueFromConnectorInstance(SSL, systemDto, connectorFormDef));
IdmFormDefinitionDto operationOptionsFormDefinition = this.getSystemService().getOperationOptionsConnectorFormDefinition(systemDto);
if (operationOptionsFormDefinition != null) {
// Find attribute with domain.
metadata.put(DOMAIN_KEY, getValueFromConnectorInstance(DOMAIN_KEY, systemDto, operationOptionsFormDefinition));
// Find attribute with container with existed users.
metadata.put(USER_SEARCH_CONTAINER_KEY, getValueFromConnectorInstance(USER_SEARCH_CONTAINER_KEY, systemDto, operationOptionsFormDefinition));
// Find attribute with container with new users.
metadata.put(NEW_USER_CONTAINER_KEY, getValueFromConnectorInstance(NEW_USER_CONTAINER_KEY, systemDto, operationOptionsFormDefinition));
// Find attribute with container with deleted users.
metadata.put(DELETE_USER_CONTAINER_KEY, getValueFromConnectorInstance(DELETE_USER_CONTAINER_KEY, systemDto, operationOptionsFormDefinition));
}
// Load the provisioning mapping.
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
SysSystemMappingDto mappingDto = systemMappingService.find(mappingFilter, null).getContent().stream().min(Comparator.comparing(SysSystemMappingDto::getCreated)).orElse(null);
if (mappingDto != null) {
connectorType.getEmbedded().put(DefaultConnectorType.MAPPING_DTO_KEY, mappingDto);
connectorType.getMetadata().put(MAPPING_ID, mappingDto.getId().toString());
connectorType.getMetadata().put(PROTECTED_MODE_SWITCH_KEY, String.valueOf(mappingDto.isProtectionEnabled()));
}
// Load the sync mapping.
SysSystemMappingFilter syncMappingFilter = new SysSystemMappingFilter();
syncMappingFilter.setSystemId(systemDto.getId());
syncMappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
SysSystemMappingDto syncMappingDto = systemMappingService.find(syncMappingFilter, null).getContent().stream().min(Comparator.comparing(SysSystemMappingDto::getCreated)).orElse(null);
if (syncMappingDto != null) {
connectorType.getMetadata().put(MAPPING_SYNC_ID, syncMappingDto.getId().toString());
}
// Load the pairing sync (beware by name!).
SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
syncFilter.setSystemId(systemDto.getId());
syncFilter.setName(PAIRING_SYNC_NAME);
AbstractSysSyncConfigDto syncDto = syncConfigService.find(syncFilter, null).getContent().stream().min(Comparator.comparing(AbstractDto::getCreated)).orElse(null);
if (syncDto != null) {
connectorType.getMetadata().put(PAIRING_SYNC_ID, syncDto.getId().toString());
}
IdmEntityStateFilter entityStateFilter = new IdmEntityStateFilter();
entityStateFilter.setOwnerId(systemDto.getId());
entityStateFilter.setOwnerType(entityStateManager.getOwnerType(systemDto.getClass()));
entityStateFilter.setResultCode(AccResultCode.WIZARD_AD_CREATED_TEST_USER_DN.getCode());
IdmEntityStateDto entityStateDto = entityStateManager.findStates(entityStateFilter, null).stream().findFirst().orElse(null);
Object dn = null;
if (entityStateDto != null && entityStateDto.getResult() != null && entityStateDto.getResult().getModel() != null && entityStateDto.getResult().getModel().getParameters() != null) {
dn = entityStateDto.getResult().getModel().getParameters().get(TEST_CREATED_USER_DN_KEY);
}
if (dn instanceof String) {
String testUserDN = (String) dn;
connectorType.getMetadata().put(ENTITY_STATE_WITH_TEST_CREATED_USER_DN_KEY, entityStateDto.getId().toString());
connectorType.getMetadata().put(TEST_CREATED_USER_DN_KEY, testUserDN);
}
// Load a schema.
SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
schemaFilter.setSystemId(systemDto.getId());
schemaFilter.setObjectClassName(getSchemaType());
SysSchemaObjectClassDto schemaDto = schemaObjectClassService.find(schemaFilter, null).getContent().stream().findFirst().orElse(null);
if (schemaDto != null) {
connectorType.getMetadata().put(SCHEMA_ID_KEY, schemaDto.getId().toString());
}
return connectorType;
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class AdUserConnectorType method executeStepFour.
/**
* Step for filling additional information as connector (OU) DNs. Enable protected mode. Add pairing sync.
*/
private void executeStepFour(ConnectorTypeDto connectorType) {
String systemId = connectorType.getMetadata().get(SYSTEM_DTO_KEY);
String pairingSyncId = connectorType.getMetadata().get(PAIRING_SYNC_ID);
Assert.notNull(systemId, "System ID cannot be null!");
SysSystemDto systemDto = this.getSystemService().get(systemId);
connectorType.getEmbedded().put(SYSTEM_DTO_KEY, systemDto);
boolean pairingSyncSwitch = Boolean.parseBoolean(connectorType.getMetadata().get(PAIRING_SYNC_SWITCH_KEY));
String pairingSyncAttributeCode = connectorType.getMetadata().get(PAIRING_SYNC_DN_ATTR_KEY);
if (pairingSyncAttributeCode == null) {
pairingSyncAttributeCode = DN_ATTR_CODE;
}
boolean protectedModeSwitch = Boolean.parseBoolean(connectorType.getMetadata().get(PROTECTED_MODE_SWITCH_KEY));
IdmFormDefinitionDto connectorFormDef = this.getSystemService().getConnectorFormDefinition(systemDto);
String port = getValueFromConnectorInstance(PORT, systemDto, connectorFormDef);
String host = getValueFromConnectorInstance(HOST, systemDto, connectorFormDef);
String user = getValueFromConnectorInstance(PRINCIPAL, systemDto, connectorFormDef);
boolean ssl = Boolean.parseBoolean(getValueFromConnectorInstance(SSL, systemDto, connectorFormDef));
String password = getConfidentialValueFromConnectorInstance(CREDENTIALS, systemDto, connectorFormDef);
String domainContainer = connectorType.getMetadata().get(DOMAIN_KEY);
Assert.notNull(domainContainer, "Domain cannot be null!");
String newUserContainer = connectorType.getMetadata().get(NEW_USER_CONTAINER_KEY);
Assert.notNull(newUserContainer, "Container for new users cannot be null!");
String searchUserContainer = connectorType.getMetadata().get(USER_SEARCH_CONTAINER_KEY);
Assert.notNull(searchUserContainer, "Container for search users cannot be null!");
String deleteUserContainer = null;
// Delete user container should be used only if protected mode is active.
if (protectedModeSwitch) {
deleteUserContainer = connectorType.getMetadata().get(DELETE_USER_CONTAINER_KEY);
}
String newUserContainerAD = this.findDn(MessageFormat.format("(&(distinguishedName={0})(|(objectClass=container)(objectClass=organizationalUnit)))", newUserContainer), port, host, user, password, ssl);
if (Strings.isBlank(newUserContainerAD)) {
throw new ResultCodeException(AccResultCode.WIZARD_AD_CONTAINER_NOT_FOUND, ImmutableMap.of("dn", newUserContainer));
}
String searchUserContainerAD = this.findDn(MessageFormat.format("(&(distinguishedName={0})(|(objectClass=container)(objectClass=organizationalUnit)))", searchUserContainer), port, host, user, password, ssl);
if (Strings.isBlank(searchUserContainerAD)) {
throw new ResultCodeException(AccResultCode.WIZARD_AD_CONTAINER_NOT_FOUND, ImmutableMap.of("dn", searchUserContainer));
}
if (Strings.isNotBlank(deleteUserContainer) && protectedModeSwitch) {
String deleteUserContainerAD = this.findDn(MessageFormat.format("(&(distinguishedName={0})(|(objectClass=container)(objectClass=organizationalUnit)))", deleteUserContainer), port, host, user, password, ssl);
if (Strings.isBlank(deleteUserContainerAD)) {
throw new ResultCodeException(AccResultCode.WIZARD_AD_CONTAINER_NOT_FOUND, ImmutableMap.of("dn", deleteUserContainer));
}
}
IdmFormDefinitionDto operationOptionsFormDefinition = getSystemService().getOperationOptionsConnectorFormDefinition(systemDto);
if (operationOptionsFormDefinition != null) {
// Set domain to system's operation options.
operationOptionsFormDefinition = initFormAttributeDefinition(operationOptionsFormDefinition, DOMAIN_KEY, (short) 3);
setValueToConnectorInstance(DOMAIN_KEY, domainContainer, systemDto, operationOptionsFormDefinition);
// Set container for new users to system's operation options.
operationOptionsFormDefinition = initFormAttributeDefinition(operationOptionsFormDefinition, NEW_USER_CONTAINER_KEY, (short) 4);
setValueToConnectorInstance(NEW_USER_CONTAINER_KEY, newUserContainer, systemDto, operationOptionsFormDefinition);
// Set container for deleted users to system's operation options.
operationOptionsFormDefinition = initFormAttributeDefinition(operationOptionsFormDefinition, DELETE_USER_CONTAINER_KEY, (short) 5);
setValueToConnectorInstance(DELETE_USER_CONTAINER_KEY, deleteUserContainer, systemDto, operationOptionsFormDefinition);
// Set container for exists users to system's operation options.
operationOptionsFormDefinition = initFormAttributeDefinition(operationOptionsFormDefinition, USER_SEARCH_CONTAINER_KEY, (short) 6);
setValueToConnectorInstance(USER_SEARCH_CONTAINER_KEY, searchUserContainer, systemDto, operationOptionsFormDefinition);
}
String mappingSyncId = connectorType.getMetadata().get(MAPPING_SYNC_ID);
String mappingId = connectorType.getMetadata().get(MAPPING_ID);
if (mappingId == null && mappingSyncId == null) {
// This attributes will be updated only if system doesn't have mapping.
// Checking by existing mapping and not by reopen flag solves a problem with reopen wizard for to early closed wizard. For example in the certificate step.
initDefaultConnectorSettings(systemDto, connectorFormDef);
}
// Attributes below will updated everytime (for reopen system too).
// Base context for search users.
// We need to searching in all containers (for new, existed and deleted users). So all three values will be use in the base context.
List<Serializable> values = Lists.newArrayList(Sets.newHashSet(searchUserContainer, newUserContainer, deleteUserContainer));
this.setValueToConnectorInstance(BASE_CONTEXT_USER_KEY, values, systemDto, connectorFormDef);
// Set root suffixes and generate a schema.
SysSchemaObjectClassDto schemaDto = generateSchema(connectorType, systemDto, connectorFormDef, searchUserContainer, values);
// Find sAMAccountName attribute in the schema.
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setObjectClassId(schemaDto.getId());
schemaAttributeFilter.setSystemId(systemDto.getId());
schemaAttributeFilter.setName(SAM_ACCOUNT_NAME_ATTRIBUTE);
SysSchemaAttributeDto sAMAccountNameAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (sAMAccountNameAttribute == null) {
// Attribute missing -> create it now.
sAMAccountNameAttribute = createSchemaAttribute(schemaDto, SAM_ACCOUNT_NAME_ATTRIBUTE, String.class.getName(), true, true, false);
}
// Find __ENABLE__ attribute in the schema.
schemaAttributeFilter.setName(IcAttributeInfo.ENABLE);
SysSchemaAttributeDto enableAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (enableAttribute == null) {
// Attribute missing -> create it now.
createSchemaAttribute(schemaDto, IcAttributeInfo.ENABLE, Boolean.class.getName(), true, true, false);
}
// Find __PASSWORD__ attribute in the schema.
schemaAttributeFilter.setName(IcAttributeInfo.PASSWORD);
SysSchemaAttributeDto passwordAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (passwordAttribute == null) {
// Attribute missing -> create it now.
createSchemaAttribute(schemaDto, IcAttributeInfo.PASSWORD, GuardedString.class.getName(), false, true, false);
} else {
passwordAttribute.setUpdateable(true);
schemaAttributeService.save(passwordAttribute);
}
// Find Ldap groups attribute in the schema.
schemaAttributeFilter.setName(LDAP_GROUPS_ATTRIBUTE);
SysSchemaAttributeDto ldapGroupsAttribute = schemaAttributeService.find(schemaAttributeFilter, null).stream().findFirst().orElse(null);
if (ldapGroupsAttribute == null) {
// Attribute missing -> create it now.
createSchemaAttribute(schemaDto, LDAP_GROUPS_ATTRIBUTE, String.class.getName(), true, true, true);
}
mappingId = connectorType.getMetadata().get(MAPPING_ID);
if (mappingId == null) {
// Create identity mapping for provisioning.
SysSystemMappingDto mappingDto = new SysSystemMappingDto();
mappingDto.setObjectClass(schemaDto.getId());
mappingDto.setOperationType(SystemOperationType.PROVISIONING);
mappingDto.setEntityType(SystemEntityType.IDENTITY);
mappingDto.setName("AD users provisioning mapping.");
mappingDto.setProtectionEnabled(protectedModeSwitch);
mappingDto = systemMappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, mappingDto, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, Boolean.TRUE))).getContent();
mappingDto = systemMappingService.save(mappingDto);
connectorType.getEmbedded().put(DefaultConnectorType.MAPPING_DTO_KEY, mappingDto);
connectorType.getMetadata().put(DefaultConnectorType.MAPPING_ID, mappingDto.getId().toString());
} else {
SysSystemMappingDto mappingDto = systemMappingService.get(UUID.fromString(mappingId));
// If protected mode switch changed, then mapping will be updated.
if (mappingDto.isProtectionEnabled() != protectedModeSwitch) {
mappingDto.setProtectionEnabled(protectedModeSwitch);
mappingDto = systemMappingService.save(mappingDto);
}
connectorType.getEmbedded().put(DefaultConnectorType.MAPPING_DTO_KEY, mappingDto);
}
if (pairingSyncSwitch) {
createPairingSync(connectorType, pairingSyncAttributeCode, schemaDto, schemaAttributeFilter, sAMAccountNameAttribute);
}
if (pairingSyncId != null) {
// If is protected mode activated, then set strategy to LINK_PROTECTED, otherwise set DO_NOT_LINK.
AbstractSysSyncConfigDto pairingSync = syncConfigService.get(UUID.fromString(pairingSyncId));
if (pairingSync instanceof SysSyncIdentityConfigDto) {
SysSyncIdentityConfigDto sync = (SysSyncIdentityConfigDto) pairingSync;
if (protectedModeSwitch) {
sync.setInactiveOwnerBehavior(SynchronizationInactiveOwnerBehaviorType.LINK_PROTECTED);
} else {
sync.setInactiveOwnerBehavior(SynchronizationInactiveOwnerBehaviorType.DO_NOT_LINK);
}
syncConfigService.save(sync);
}
}
}
Aggregations