Search in sources :

Example 56 with AccIdentityAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningExtendedAttribute.

@Test
public void doIdentityProvisioningExtendedAttribute() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    // We will use firstName attribute (password attribute is not returned
    // by default)
    SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
    filterSchemaAttr.setIdmPropertyName("firstName");
    filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
    SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
    // Set attribute to extended attribute and modify idmPropety to
    // extPassword
    attributeHandling.setIdmPropertyName(IDENTITY_EXT_PASSWORD);
    attributeHandling.setExtendedAttribute(true);
    attributeHandling.setConfidentialAttribute(true);
    attributeHandling.setEntityAttribute(false);
    attributeHandling.setTransformToResourceScript("return attributeValue");
    // Form attribute definition will be created during save attribute
    // handling
    attributeHandling = systemAttributeMappingService.save(attributeHandling);
    // Create extended attribute value for password
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    List<IdmFormValueDto> values = new ArrayList<>();
    IdmFormValueDto phoneValue = new IdmFormValueDto();
    phoneValue.setFormAttribute(formDefinition.getMappedAttributeByCode(IDENTITY_EXT_PASSWORD).getId());
    phoneValue.setStringValue(IDENTITY_PASSWORD_THREE);
    values.add(phoneValue);
    formService.saveValues(identityRepository.findOne(identity.getId()), formDefinition, values);
    // save account
    provisioningService.doProvisioning(identity);
    TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(IDENTITY_PASSWORD_THREE, resourceAccoutn.getFirstname());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 57 with AccIdentityAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyIfNull.

@Test
public void doIdentityProvisioningStrategyIfNull() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    // Default email strategy is CREATE, we check value
    TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_ONE, resourceAccoutn.getEmail());
    SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
    filterSchemaAttr.setIdmPropertyName("email");
    filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
    SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
    attributeHandling.setEntityAttribute(true);
    attributeHandling.setStrategyType(AttributeMappingStrategyType.WRITE_IF_NULL);
    attributeHandling.setTransformToResourceScript("return \"" + EMAIL_TWO + "\";");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is WRITE_IF_NULL ... email in account must not have new value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotEquals(EMAIL_TWO, resourceAccoutn.getEmail());
    attributeHandling.setEntityAttribute(true);
    attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
    attributeHandling.setTransformToResourceScript("return \"" + EMAIL_TWO + "\";");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is SET ... email in account must have new value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 58 with AccIdentityAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyMergeException.

// Expected PROVISIONING_MERGE_ATTRIBUTE_IS_NOT_MULTIVALUE
@Test(expected = ProvisioningException.class)
public void doIdentityProvisioningStrategyMergeException() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
    filterSchemaAttr.setIdmPropertyName("email");
    filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
    SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
    attributeHandling.setEntityAttribute(true);
    attributeHandling.setStrategyType(AttributeMappingStrategyType.MERGE);
    SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.get(attributeHandling.getSchemaAttribute());
    schemaAttributeDto.setMultivalued(false);
    schemaAttributeService.save(schemaAttributeDto);
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 59 with AccIdentityAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.

the class IdentitySynchronizationExecutor method doUnlink.

/**
 * Operation remove IdentityAccount relations and linked roles
 *
 * @param account
 * @param removeIdentityRole
 * @param log
 * @param logItem
 * @param actionLogs
 */
@Override
protected void doUnlink(AccAccountDto account, boolean removeIdentityRole, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
    EntityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
    identityAccountFilter.setAccountId(account.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccoutnService.find((AccIdentityAccountFilter) identityAccountFilter, null).getContent();
    if (identityAccounts.isEmpty()) {
        addToItemLog(logItem, "Identity account relation was not found!");
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
    addToItemLog(logItem, MessageFormat.format("Identity-account relations to delete {0}", identityAccounts));
    identityAccounts.stream().forEach(identityAccount -> {
        // We will remove identity account, but without delete connected
        // account
        identityAccoutnService.delete(identityAccount, false);
        addToItemLog(logItem, MessageFormat.format("Identity-account relation deleted (without call delete provisioning) (username: {0}, id: {1})", identityAccount.getIdentity(), identityAccount.getId()));
        UUID identityRole = identityAccount.getIdentityRole();
        if (removeIdentityRole && identityRole != null) {
            // We will remove connected identity role
            identityRoleService.deleteById(identityRole);
            addToItemLog(logItem, MessageFormat.format("Identity-role relation deleted (id: {0})", identityRole));
        }
    });
    return;
}
Also used : EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) UUID(java.util.UUID) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Aggregations

AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)59 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)48 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)47 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)43 Test (org.junit.Test)43 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)25 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)22 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)13 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)13 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)12 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)11 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)10 ArrayList (java.util.ArrayList)10 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)9 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)8 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)7 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)6 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)5 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)5