Search in sources :

Example 76 with SysSchemaAttributeDto

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

the class SysSystemMappingServiceValidationTest method testSystemMappingValidationNotMissingIdentifier.

@Test
public void testSystemMappingValidationNotMissingIdentifier() {
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto schema = createSchema(system.getId());
    SysSystemMappingDto mapping = createMapping(schema.getId(), SystemOperationType.PROVISIONING);
    SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(schema.getId());
    createAttributeMapping(mapping.getId(), schemaAttribute.getId(), true, "");
    mappingService.validate(mapping.getId());
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 77 with SysSchemaAttributeDto

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

the class DefaultAccTestHelper method createMapping.

@Override
public SysSystemMappingDto createMapping(SysSystemDto system) {
    // 
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // 
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClasses.get(0).getId());
    systemMapping = systemMappingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
        if (ATTRIBUTE_MAPPING_NAME.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_ENABLE.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(false);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName("disabled");
            attributeMapping.setTransformToResourceScript("return String.valueOf(!attributeValue);");
            attributeMapping.setTransformFromResourceScript("return String.valueOf(attributeValue);");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_PASSWORD.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("password");
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setPasswordAttribute(true);
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_FIRSTNAME.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.firstName.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_LASTNAME.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.lastName.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.email.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        }
    }
    return systemMapping;
}
Also used : 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) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 78 with SysSchemaAttributeDto

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

the class DefaultLdapTestHelper method createTestResourceSystem.

@Override
public SysSystemDto createTestResourceSystem(boolean withMapping, String systemName) {
    SysSystemDto system = this.createSystem(systemName);
    if (!withMapping) {
        return system;
    }
    // 
    // generate schema for system
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // TODO use constatn
    SysSchemaObjectClassDto objectClass = objectClasses.stream().filter(oc -> oc.getObjectClassName().equals("__ACCOUNT__")).findFirst().orElse(null);
    assertNotNull(objectClass);
    // 
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClass.getId());
    systemMapping = systemMappingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    SysSchemaAttributeDto memberOf = new SysSchemaAttributeDto();
    memberOf.setClassType("java.lang.String");
    memberOf.setCreateable(true);
    memberOf.setMultivalued(true);
    memberOf.setUpdateable(true);
    memberOf.setReturnedByDefault(true);
    memberOf.setReadable(true);
    memberOf.setObjectClass(objectClass.getId());
    memberOf.setNativeName(ATTRIBUTE_MAPPING_MEMBER_OF);
    memberOf.setName(ATTRIBUTE_MAPPING_MEMBER_OF);
    memberOf = schemaAttributeService.save(memberOf);
    // From some reason contains schema object class for account two __NAME__ just skip second
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
        // Test ldap has some duplicates attributes for example __NAME__ and cn
        SysSystemAttributeMappingDto founded = systemAttributeMappingService.findBySystemMappingAndName(systemMapping.getId(), schemaAttr.getName());
        if (founded != null) {
            continue;
        }
        if (ATTRIBUTE_MAPPING_NAME.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_PASSWORD.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("password");
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(systemMapping.getId());
            attributeMapping.setPasswordAttribute(true);
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_FIRSTNAME.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.firstName.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_CN.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            // TODO: map as script (combination last and first name)
            attributeMapping.setIdmPropertyName(IdmIdentity_.description.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(systemMapping.getId());
            attributeMapping.setTransformToResourceScript("" + System.lineSeparator() + "if (attributeValue) {" + System.lineSeparator() + "	return attributeValue;" + System.lineSeparator() + "}" + System.lineSeparator() + "return entity.getFirstName() + ' ' + entity.getLastName();" + // we must compose cn
            System.lineSeparator());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_LASTNAME.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.lastName.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(IdmIdentity_.email.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_MAPPING_MEMBER_OF.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setStrategyType(AttributeMappingStrategyType.MERGE);
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            attributeMapping.setEntityAttribute(false);
            attributeMapping.setExtendedAttribute(false);
            systemAttributeMappingService.save(attributeMapping);
        }
    }
    return system;
}
Also used : 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) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 79 with SysSchemaAttributeDto

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

the class DefaultVsSystemService method createAttributeMapping.

/**
 * Creates attribute mapping for synchronization mapping
 *
 * @author Marek Klement
 *
 * @param foundMapping
 *            created mapping for sync
 * @param schemaId
 *            uuid of schema
 * @return new attribute mapping
 */
private SysSystemAttributeMappingDto createAttributeMapping(UUID foundMapping, UUID schemaId) {
    SysSchemaAttributeFilter filter = new SysSchemaAttributeFilter();
    filter.setObjectClassId(schemaId);
    List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(filter, null).getContent();
    UUID idOfSchemaAttributeName = null;
    for (SysSchemaAttributeDto attribute : schemaAttributes) {
        if (attribute.getName().equals(Name.NAME)) {
            idOfSchemaAttributeName = attribute.getId();
            break;
        }
    }
    // 
    SysSystemAttributeMappingDto attributeMapping = systemAttributeMappingService.findBySystemMappingAndName(foundMapping, IDM_ATTRIBUTE_NAME);
    // 
    if (attributeMapping == null) {
        attributeMapping = new SysSystemAttributeMappingDto();
        attributeMapping.setEntityAttribute(true);
        Assert.notNull(idOfSchemaAttributeName, "Attribute uid name not found!");
        attributeMapping.setSchemaAttribute(idOfSchemaAttributeName);
        attributeMapping.setIdmPropertyName(IDM_ATTRIBUTE_NAME);
        attributeMapping.setSystemMapping(foundMapping);
        attributeMapping.setName(IDM_ATTRIBUTE_NAME);
        attributeMapping.setUid(true);
        attributeMapping = systemAttributeMappingService.save(attributeMapping);
    } else if (!attributeMapping.isUid()) {
        throw new CoreException("Attribute mapping with name was already set and is not IDENTIFIER!");
    }
    return attributeMapping;
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) UUID(java.util.UUID)

Example 80 with SysSchemaAttributeDto

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

the class DefaultVsSystemService method createDefaultMapping.

/**
 * Create default mapping for virtual system by given default attributes
 *
 * @param system
 * @param schema
 * @param vsSystem
 * @return
 */
private SysSystemMappingDto createDefaultMapping(SysSystemDto system, SysSchemaObjectClassDto schema, VsSystemDto vsSystem) {
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("Default provisioning");
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(schema.getId());
    systemMapping = systemMappingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
    ArrayList<String> defaultAttributes = Lists.newArrayList(BasicVirtualConfiguration.DEFAULT_ATTRIBUTES);
    List<String> attributes = vsSystem.getAttributes().isEmpty() ? defaultAttributes : vsSystem.getAttributes();
    for (SysSchemaAttributeDto schemaAttr : schemaAttributes) {
        if (IcAttributeInfo.NAME.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(true);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (IcAttributeInfo.ENABLE.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(false);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName(IdmIdentity_.disabled.getName());
            attributeMapping.setTransformToResourceScript("return !attributeValue;");
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (RIGHTS_ATTRIBUTE.equals(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(false);
            attributeMapping.setEntityAttribute(false);
            attributeMapping.setStrategyType(AttributeMappingStrategyType.MERGE);
            attributeMapping.setExtendedAttribute(false);
            attributeMapping.setName("'Rights' - multivalued merge attribute.");
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        } else if (attributes.contains(schemaAttr.getName()) && defaultAttributes.contains(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setUid(false);
            attributeMapping.setEntityAttribute(true);
            attributeMapping.setIdmPropertyName(schemaAttr.getName());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setName(schemaAttr.getName());
            attributeMapping.setSystemMapping(systemMapping.getId());
            systemAttributeMappingService.save(attributeMapping);
        }
    }
    return systemMapping;
}
Also used : 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)

Aggregations

SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)168 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)119 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)96 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)89 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)86 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)79 Test (org.junit.Test)73 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 UUID (java.util.UUID)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)39 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)36 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)35 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)34 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)28 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)27 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)26 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)26 Serializable (java.io.Serializable)26 List (java.util.List)25