Search in sources :

Example 46 with SysSchemaObjectClassDto

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

the class AccountManagementTest method initData.

private SysSystemDto initData() {
    // create test system
    SysSystemDto system = helper.createSystem(TestRoleResource.TABLE_NAME);
    Assert.assertNotNull(system);
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // Create mapping
    SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
    syncSystemMapping.setName("default_" + System.currentTimeMillis());
    syncSystemMapping.setEntityType(SystemEntityType.ROLE);
    syncSystemMapping.setOperationType(SystemOperationType.PROVISIONING);
    syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
    final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
    createMapping(system, syncMapping);
    this.getBean().initRoleData();
    return system;
}
Also used : SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 47 with SysSchemaObjectClassDto

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

the class IdentityRoleValidRequestSchedulerTest method createAndSaveSystemWithMapping.

private SysSystemDto createAndSaveSystemWithMapping() {
    system = null;
    systemMapping = null;
    SysSystemAttributeMappingDto nameAttributeMapping = null;
    SysSystemAttributeMappingDto firstNameAttributeMapping = null;
    SysSystemAttributeMappingDto lastNameAttributeMapping = null;
    SysSystemAttributeMappingDto passwordAttributeMapping = null;
    // prepare test system
    system = helper.createSystem(TestResource.TABLE_NAME);
    // generate schema
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // create test mapping
    systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClasses.get(0).getId());
    systemMapping = mappingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
        if ("__NAME__".equals(schemaAttr.getName())) {
            nameAttributeMapping = new SysSystemAttributeMappingDto();
            nameAttributeMapping.setUid(true);
            nameAttributeMapping.setEntityAttribute(true);
            nameAttributeMapping.setIdmPropertyName("username");
            nameAttributeMapping.setName(schemaAttr.getName());
            nameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            nameAttributeMapping.setSystemMapping(systemMapping.getId());
            nameAttributeMapping = attributeMappingService.save(nameAttributeMapping);
        } else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
            firstNameAttributeMapping = new SysSystemAttributeMappingDto();
            firstNameAttributeMapping.setIdmPropertyName("firstName");
            firstNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            firstNameAttributeMapping.setName(schemaAttr.getName());
            firstNameAttributeMapping.setSystemMapping(systemMapping.getId());
            firstNameAttributeMapping = attributeMappingService.save(firstNameAttributeMapping);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            lastNameAttributeMapping = new SysSystemAttributeMappingDto();
            lastNameAttributeMapping.setIdmPropertyName("lastName");
            lastNameAttributeMapping.setName(schemaAttr.getName());
            lastNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            lastNameAttributeMapping.setSystemMapping(systemMapping.getId());
            lastNameAttributeMapping = attributeMappingService.save(lastNameAttributeMapping);
        } else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
            passwordAttributeMapping = new SysSystemAttributeMappingDto();
            passwordAttributeMapping.setIdmPropertyName("password");
            passwordAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            passwordAttributeMapping.setName(schemaAttr.getName());
            passwordAttributeMapping.setSystemMapping(systemMapping.getId());
            passwordAttributeMapping = attributeMappingService.save(passwordAttributeMapping);
        }
    }
    assertNotNull(system);
    assertNotNull(nameAttributeMapping);
    assertNotNull(firstNameAttributeMapping);
    assertNotNull(lastNameAttributeMapping);
    assertNotNull(passwordAttributeMapping);
    return system;
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 48 with SysSchemaObjectClassDto

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

the class DefaultRoleCatalogueProvisioningTest method initData.

private void initData() {
    // create test system
    system = helper.createSystem("test_tree_resource");
    system.setName(SYSTEM_NAME);
    system = systemService.save(system);
    // key to EAV
    IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system.getConnectorInstance());
    IdmFormAttributeDto attributeKeyColumn = savedFormDefinition.getMappedAttributeByCode("keyColumn");
    formService.saveValues(system, attributeKeyColumn, ImmutableList.of("ID"));
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // Create synchronization mapping
    SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
    syncSystemMapping.setName("default_" + System.currentTimeMillis());
    syncSystemMapping.setEntityType(SystemEntityType.ROLE_CATALOGUE);
    syncSystemMapping.setOperationType(SystemOperationType.PROVISIONING);
    syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
    final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
    createMapping(system, syncMapping);
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 49 with SysSchemaObjectClassDto

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

the class DefaultRoleSynchronizationServiceTest method initData.

private void initData() {
    // create test system
    system = helper.createSystem("test_role_resource");
    system.setName(SYSTEM_NAME);
    system = systemService.save(system);
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // Create synchronization mapping
    SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
    syncSystemMapping.setName("default_" + System.currentTimeMillis());
    syncSystemMapping.setEntityType(SystemEntityType.ROLE);
    syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
    syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
    final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
    createMapping(system, syncMapping);
    initRoleData();
    syncConfigService.find(null).getContent().forEach(config -> {
        syncConfigService.delete(config);
    });
}
Also used : SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 50 with SysSchemaObjectClassDto

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

the class DefaultSysProvisioningServiceTest method initData.

private void initData() {
    IdmIdentityDto identity;
    AccAccountDto accountOne;
    AccIdentityAccountDto accountIdentityOne;
    // create test system
    SysSystemDto system = helper.createSystem(TestResource.TABLE_NAME, SYSTEM_NAME);
    // set default generate password policy for system
    IdmPasswordPolicyDto passwordPolicy = new IdmPasswordPolicyDto();
    passwordPolicy.setName(PASSWORD_POLICY);
    passwordPolicy.setType(IdmPasswordPolicyType.GENERATE);
    passwordPolicy.setGenerateType(IdmPasswordPolicyGenerateType.RANDOM);
    passwordPolicy.setLowerCharBase("a");
    passwordPolicy.setMinPasswordLength(2);
    passwordPolicy.setMaxPasswordLength(2);
    passwordPolicy.setMinLowerChar(2);
    passwordPolicy = passwordPolicyService.save(passwordPolicy);
    system.setPasswordPolicyGenerate(passwordPolicy.getId());
    system = systemService.save(system);
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // Create test identity for provisioning test
    identity = new IdmIdentityDto();
    identity.setUsername(IDENTITY_USERNAME);
    identity.setFirstName(IDENTITY_USERNAME);
    identity.setLastName(IDENTITY_USERNAME);
    identity = idmIdentityService.save(identity);
    accountOne = new AccAccountDto();
    accountOne.setSystem(system.getId());
    accountOne.setUid("x" + IDENTITY_USERNAME);
    accountOne.setAccountType(AccountType.PERSONAL);
    accountOne.setEntityType(SystemEntityType.IDENTITY);
    accountOne = accountService.save(accountOne);
    accountIdentityOne = new AccIdentityAccountDto();
    accountIdentityOne.setIdentity(identity.getId());
    accountIdentityOne.setOwnership(true);
    accountIdentityOne.setAccount(accountOne.getId());
    accountIdentityOne = identityAccoutnService.save(accountIdentityOne);
    IdmIdentityDto identityTwo = new IdmIdentityDto();
    identityTwo.setUsername(IDENTITY_USERNAME_TWO);
    identityTwo.setFirstName(IDENTITY_USERNAME_TWO);
    identityTwo.setLastName(IDENTITY_USERNAME_TWO);
    identityTwo = idmIdentityService.save(identityTwo);
    AccAccountDto accountTwo = new AccAccountDto();
    accountTwo.setSystem(system.getId());
    accountTwo.setUid("x" + IDENTITY_USERNAME_TWO);
    accountTwo.setAccountType(AccountType.PERSONAL);
    accountTwo.setEntityType(SystemEntityType.IDENTITY);
    accountTwo = accountService.save(accountTwo);
    AccIdentityAccountDto accountIdentityTwo = new AccIdentityAccountDto();
    accountIdentityTwo.setIdentity(identityTwo.getId());
    accountIdentityTwo.setOwnership(true);
    accountIdentityTwo.setAccount(accountTwo.getId());
    accountIdentityTwo = identityAccoutnService.save(accountIdentityTwo);
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClasses.get(0).getId());
    final SysSystemMappingDto entityHandlingResult = systemEntityHandlingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    schemaAttributesPage.forEach(schemaAttr -> {
        if ("__NAME__".equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
            attributeMapping.setTransformToResourceScript("if(attributeValue){return \"x\"+ attributeValue;}");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            attributeMapping = systemAttributeMappingService.save(attributeMapping);
        } else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.firstName.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setTransformFromResourceScript("if(attributeValue){return attributeValue.substring(1);}");
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            attributeMapping = systemAttributeMappingService.save(attributeMapping);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.lastName.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            attributeMapping = systemAttributeMappingService.save(attributeMapping);
        } else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("password");
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            attributeMapping = systemAttributeMappingService.save(attributeMapping);
        } else if ("email".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.email.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setStrategyType(AttributeMappingStrategyType.CREATE);
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            attributeMapping.setTransformToResourceScript("return \"" + EMAIL_ONE + "\";");
            attributeMapping = systemAttributeMappingService.save(attributeMapping);
        }
    });
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Aggregations

SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)59 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)49 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)45 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)23 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)19 Test (org.junit.Test)19 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)18 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)13 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)12 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)12 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)11 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)10 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)9 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)9 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)8 SynchronizationContext (eu.bcvsolutions.idm.acc.domain.SynchronizationContext)8 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)8 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)8 ArrayList (java.util.ArrayList)8