Search in sources :

Example 91 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class ValuePolicyProcessor method checkProhibitedValues.

private <O extends ObjectType, R extends ObjectType> boolean checkProhibitedValues(String newPassword, ProhibitedValuesType prohibitedValuesType, ObjectBasedValuePolicyOriginResolver<O> originResolver, Consumer<ProhibitedValueItemType> failAction, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
    if (prohibitedValuesType == null || originResolver == null) {
        return true;
    }
    MutableBoolean isAcceptable = new MutableBoolean(true);
    for (ProhibitedValueItemType prohibitedItemType : prohibitedValuesType.getItem()) {
        ItemPathType itemPathType = prohibitedItemType.getPath();
        if (itemPathType == null) {
            throw new SchemaException("No item path defined in prohibited item in " + shortDesc);
        }
        ItemPath itemPath = itemPathType.getItemPath();
        ResultHandler<R> handler = (object, objectResult) -> {
            PrismProperty<Object> objectProperty = object.findProperty(itemPath);
            if (objectProperty == null) {
                return true;
            }
            if (isMatching(newPassword, objectProperty)) {
                if (failAction != null) {
                    failAction.accept(prohibitedItemType);
                }
                isAcceptable.setValue(false);
                return false;
            }
            return true;
        };
        originResolver.resolve(prohibitedItemType, handler, shortDesc, task, result);
    }
    return isAcceptable.booleanValue();
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionConstants(com.evolveum.midpoint.schema.constants.ExpressionConstants) StringLimitType(com.evolveum.midpoint.xml.ns._public.common.common_3.StringLimitType) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) LimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.LimitationsType) MiscSchemaUtil(com.evolveum.midpoint.schema.util.MiscSchemaUtil) LocalizableMessageList(com.evolveum.midpoint.util.LocalizableMessageList) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) LocalizationUtil(com.evolveum.midpoint.schema.util.LocalizationUtil) StringPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.StringPolicyType) Task(com.evolveum.midpoint.task.api.Task) MutablePrismPropertyDefinition(com.evolveum.midpoint.prism.MutablePrismPropertyDefinition) CheckExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CheckExpressionType) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SystemException(com.evolveum.midpoint.util.exception.SystemException) ExpressionUtil(com.evolveum.midpoint.repo.common.expression.ExpressionUtil) ExpressionProfile(com.evolveum.midpoint.schema.expression.ExpressionProfile) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) BooleanUtils.isTrue(org.apache.commons.lang3.BooleanUtils.isTrue) NotNull(org.jetbrains.annotations.NotNull) Validate(org.apache.commons.lang.Validate) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) StrBuilder(org.apache.commons.lang.text.StrBuilder) java.util(java.util) CharacterClassType(com.evolveum.midpoint.xml.ns._public.common.common_3.CharacterClassType) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Trace(com.evolveum.midpoint.util.logging.Trace) ObjectUtils.defaultIfNull(org.apache.commons.lang3.ObjectUtils.defaultIfNull) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) CollectionUtils(org.apache.commons.collections4.CollectionUtils) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ProhibitedValueItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProhibitedValueItemType) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) StringLimitationResult(com.evolveum.midpoint.model.api.validator.StringLimitationResult) PrismContext(com.evolveum.midpoint.prism.PrismContext) PrimitiveType(com.evolveum.midpoint.prism.PrimitiveType) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) RandomStringUtils(org.apache.commons.lang.RandomStringUtils) PrismObject(com.evolveum.midpoint.prism.PrismObject) LocalizableMessageBuilder(com.evolveum.midpoint.util.LocalizableMessageBuilder) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Consumer(java.util.function.Consumer) LocalizableMessageListBuilder(com.evolveum.midpoint.util.LocalizableMessageListBuilder) Component(org.springframework.stereotype.Component) ItemName(com.evolveum.midpoint.prism.path.ItemName) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) Protector(com.evolveum.midpoint.prism.crypto.Protector) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) ProhibitedValuesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProhibitedValuesType) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) ProhibitedValueItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProhibitedValueItemType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 92 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class DefaultColumnUtils method createColumns.

private static <C extends Containerable> void createColumns(GuiObjectListViewType view, Class<? extends C> type) {
    view.createColumnList();
    List<GuiObjectColumnType> columns = view.getColumn();
    List<ColumnWrapper> defaultColumns = getColumnsForType(type);
    String previousColumn = null;
    for (ColumnWrapper defaultColumn : defaultColumns) {
        String localPathPath = defaultColumn.getPath().lastName().getLocalPart();
        String columnName = localPathPath + "Column";
        GuiObjectColumnType column = new GuiObjectColumnType();
        column.setName(columnName);
        column.setPreviousColumn(previousColumn);
        ItemPathType itemPathType = new ItemPathType();
        itemPathType.setItemPath(defaultColumn.getPath());
        column.setPath(itemPathType);
        column.setDisplayValue(defaultColumn.getDisplayValue());
        if (defaultColumn.isSortable()) {
            column.setSortProperty(localPathPath);
        }
        if (!StringUtils.isEmpty(defaultColumn.getLabel())) {
            DisplayType display = new DisplayType();
            PolyStringType label = new PolyStringType(defaultColumn.getLabel());
            label.setTranslation(new PolyStringTranslationType().key(defaultColumn.getLabel()));
            display.setLabel(label);
            column.setDisplay(display);
        }
        columns.add(column);
        previousColumn = columnName;
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType)

Example 93 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class FocusValidityScanPartialRun method createFilterForValidityChecking.

private ObjectFilter createFilterForValidityChecking(TimeValidityPolicyConstraintType validityConstraint) {
    ItemPathType itemPathType = validityConstraint.getItem();
    ItemPath path = java.util.Objects.requireNonNull(itemPathType.getItemPath(), "No path defined in the validity constraint");
    XMLGregorianCalendar lowerBound = CloneUtil.clone(lastScanTimestamp);
    XMLGregorianCalendar upperBound = CloneUtil.clone(thisScanTimestamp);
    Duration negativeOffset = getNegativeActivationOffset(validityConstraint);
    if (lowerBound != null) {
        lowerBound.add(negativeOffset);
    }
    upperBound.add(negativeOffset);
    return createFilterForItemTimestamp(path, lowerBound, upperBound);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) Duration(javax.xml.datatype.Duration) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 94 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class SearchTest method initSystem.

@Override
public void initSystem() throws Exception {
    OperationResult result = new OperationResult("add objects");
    PrismObject<UserType> beforeConfig = prismContext.createObjectable(UserType.class).name("before-config").description(DESCRIPTION_TO_FIND).asPrismObject();
    beforeConfigOid = repositoryService.addObject(beforeConfig, null, result);
    FullTextSearchConfigurationType fullTextConfig = new FullTextSearchConfigurationType();
    FullTextSearchIndexedItemsConfigurationType entry = new FullTextSearchIndexedItemsConfigurationType();
    entry.getItem().add(new ItemPathType(ObjectType.F_NAME));
    entry.getItem().add(new ItemPathType(ObjectType.F_DESCRIPTION));
    fullTextConfig.getIndexed().add(entry);
    repositoryService.applyFullTextSearchConfiguration(fullTextConfig);
    logger.info("Applying full text search configuration: {}", fullTextConfig);
    List<PrismObject<? extends Objectable>> objects = prismContext.parserFor(new File(FOLDER_BASIC, "objects.xml")).parseObjects();
    objects.addAll(prismContext.parserFor(new File(FOLDER_BASIC, "objects-2.xml")).parseObjects());
    // noinspection rawtypes
    for (PrismObject object : objects) {
        // noinspection unchecked
        repositoryService.addObject(object, null, result);
        if (object.getName().getOrig().equals("atestuserX00002")) {
            x00002Oid = object.getOid();
        }
    }
    result.recomputeStatus();
    assertTrue(result.isSuccess());
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File)

Example 95 with ItemPathType

use of com.evolveum.prism.xml.ns._public.types_3.ItemPathType in project midpoint by Evolveum.

the class AutoAssignMappingCollector method collectAutoassignMappings.

<AH extends AssignmentHolderType> void collectAutoassignMappings(LensContext<AH> context, List<FocalMappingEvaluationRequest<?, ?>> mappings, OperationResult result) throws SchemaException {
    if (!autoassignEnabled(context.getSystemConfiguration())) {
        return;
    }
    ObjectQuery query = prismContext.queryFor(AbstractRoleType.class).item(SchemaConstants.PATH_AUTOASSIGN_ENABLED).eq(true).build();
    ResultHandler<AbstractRoleType> handler = (role, objectResult) -> {
        AutoassignSpecificationType autoassign = role.asObjectable().getAutoassign();
        if (autoassign == null) {
            return true;
        }
        if (!isTrue(autoassign.isEnabled())) {
            return true;
        }
        FocalAutoassignSpecificationType focalAutoassignSpec = autoassign.getFocus();
        if (focalAutoassignSpec == null) {
            return true;
        }
        if (!isApplicableFor(focalAutoassignSpec.getSelector(), context.getFocusContext(), objectResult)) {
            return true;
        }
        for (AutoassignMappingType autoMapping : focalAutoassignSpec.getMapping()) {
            AutoassignMappingType mapping = LensUtil.setMappingTarget(autoMapping, new ItemPathType(SchemaConstants.PATH_ASSIGNMENT));
            mappings.add(new AutoassignRoleMappingEvaluationRequest(mapping, role.asObjectable()));
            LOGGER.trace("Collected autoassign mapping {} from {}", mapping.getName(), role);
        }
        return true;
    };
    cacheRepositoryService.searchObjectsIterative(AbstractRoleType.class, query, handler, createReadOnlyCollection(), true, result);
}
Also used : ResultHandler(com.evolveum.midpoint.schema.ResultHandler) GetOperationOptions.createReadOnlyCollection(com.evolveum.midpoint.schema.GetOperationOptions.createReadOnlyCollection) LensUtil(com.evolveum.midpoint.model.impl.lens.LensUtil) AutoassignRoleMappingEvaluationRequest(com.evolveum.midpoint.model.impl.lens.projector.mappings.AutoassignRoleMappingEvaluationRequest) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) Trace(com.evolveum.midpoint.util.logging.Trace) PrismObject(com.evolveum.midpoint.prism.PrismObject) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) BooleanUtils.isTrue(org.apache.commons.lang.BooleanUtils.isTrue) Component(org.springframework.stereotype.Component) List(java.util.List) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) FocalMappingEvaluationRequest(com.evolveum.midpoint.model.impl.lens.projector.mappings.FocalMappingEvaluationRequest) PrismContext(com.evolveum.midpoint.prism.PrismContext) LensFocusContext(com.evolveum.midpoint.model.impl.lens.LensFocusContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AutoassignRoleMappingEvaluationRequest(com.evolveum.midpoint.model.impl.lens.projector.mappings.AutoassignRoleMappingEvaluationRequest)

Aggregations

ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)114 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)58 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)27 Test (org.testng.annotations.Test)27 QName (javax.xml.namespace.QName)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)21 List (java.util.List)18 NotNull (org.jetbrains.annotations.NotNull)18 PrismObject (com.evolveum.midpoint.prism.PrismObject)15 ArrayList (java.util.ArrayList)15 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)13 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)13 Collectors (java.util.stream.Collectors)13 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)12 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)11 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)11 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)11 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)11 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)11