diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java index 2da734a05f0..01460f1bb58 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.security.api.AuthorizationConstants; import com.evolveum.midpoint.security.api.MidPointPrincipal; import com.evolveum.midpoint.security.api.OwnerResolver; @@ -1347,13 +1348,13 @@ private OperationResult executeResultScriptHook(OperationResult result) { ExpressionFactory factory = getExpressionFactory(); PrismPropertyDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition( ExpressionConstants.OUTPUT_ELEMENT_NAME, OperationResultType.COMPLEX_TYPE); - Expression, PrismPropertyDefinition> expression = factory.makeExpression(expressionType, outputDefinition, contextDesc, task, topResult); + Expression, PrismPropertyDefinition> expression = factory.makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, topResult); ExpressionVariables variables = new ExpressionVariables(); OperationResultType resultType = result.createOperationResultType(); - variables.addVariableDefinition(ExpressionConstants.VAR_INPUT, resultType); + variables.put(ExpressionConstants.VAR_INPUT, resultType, OperationResultType.class); ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task, topResult); PrismValueDeltaSetTriple> outputTriple = expression.evaluate(context); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/model/FlexibleLabelModel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/model/FlexibleLabelModel.java index 5ada17fd371..5465272d03b 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/model/FlexibleLabelModel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/model/FlexibleLabelModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -131,9 +132,9 @@ private String getExpressionValue(ExpressionType expressionType, String contextD PrismContext prismContext = object.asPrismContainerValue().getPrismContext(); PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_STRING); - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition, contextDesc, task, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, result); ExpressionVariables variables = new ExpressionVariables(); - variables.addVariableDefinition(ExpressionConstants.VAR_OBJECT, object); + variables.put(ExpressionConstants.VAR_OBJECT, object, object.asPrismContainerValue().getDefinition()); addAdditionalExpressionVariables(variables); ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task, result); PrismValueDeltaSetTriple> outputTriple = expression.evaluate(context); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/PostInitialDataImport.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/PostInitialDataImport.java index 986fa3d7b36..a78b7c5b265 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/PostInitialDataImport.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/PostInitialDataImport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,21 @@ package com.evolveum.midpoint.init; +import java.io.File; +import java.util.Arrays; + +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.Validate; +import org.springframework.security.core.context.SecurityContext; + import com.evolveum.midpoint.model.api.ScriptExecutionResult; import com.evolveum.midpoint.model.api.ScriptingService; import com.evolveum.midpoint.prism.Item; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ReportTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SystemException; @@ -34,16 +39,8 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionType; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.Validate; -import org.springframework.security.core.context.SecurityContext; - -import java.io.File; -import java.util.*; /** * @author lazyman @@ -170,7 +167,7 @@ private Boolean executeScript(PrismProperty expre Object parsed = expression.getAnyValue().getValue(); ScriptExecutionResult executionResult = parsed instanceof ExecuteScriptType ? - scripting.evaluateExpression((ExecuteScriptType) parsed, Collections.emptyMap(), + scripting.evaluateExpression((ExecuteScriptType) parsed, VariablesMap.emptyMap(), false, task, result) : scripting.evaluateExpression((ScriptingExpressionType) parsed, task, result); result.recordSuccess(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/FocusSummaryPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/FocusSummaryPanel.java index e5ef4fe6f5b..2a5066c64e4 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/FocusSummaryPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/FocusSummaryPanel.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-2017 Evolveum + * Copyright (c) 2015-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -141,7 +141,7 @@ protected IModel getDefaltParentOrgModel() { @Override protected void addAdditionalExpressionVariables(ExpressionVariables variables) { List parentOrgs = getModelObject().getParentOrg(); - variables.addVariableDefinition(ExpressionConstants.VAR_ORGS, parentOrgs); + variables.putList(ExpressionConstants.VAR_ORGS, parentOrgs); } @Override diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/assignment/ApplicablePolicyConfigPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/assignment/ApplicablePolicyConfigPanel.java index b62dfb07a86..2c3f50fe792 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/assignment/ApplicablePolicyConfigPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/assignment/ApplicablePolicyConfigPanel.java @@ -17,10 +17,6 @@ import com.evolveum.midpoint.gui.api.component.BasePanel; import com.evolveum.midpoint.gui.api.model.LoadableModel; -import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; -import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; -import com.evolveum.midpoint.model.api.util.ModelContextUtil; -import com.evolveum.midpoint.model.api.util.ModelUtils; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.util.logging.LoggingUtils; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/form/ValueChoosePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/form/ValueChoosePanel.java index 50d947e974d..e067bfb07e2 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/form/ValueChoosePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/form/ValueChoosePanel.java @@ -192,6 +192,9 @@ public String getObject() { if (ort instanceof PrismReferenceValue) { PrismReferenceValue prv = (PrismReferenceValue) ort; + if (StringUtils.isEmpty(prv.getOid())){ + return createStringResource("ValueChoosePanel.undefined").getString(); + } ObjectReferenceType objectReferenceType = new ObjectReferenceType(); objectReferenceType.setupReferenceValue((PrismReferenceValue) ort); String targetObjectName = WebComponentUtil.getName(objectReferenceType, @@ -201,6 +204,9 @@ public String getObject() { : prv.getOid(); } else if (ort instanceof ObjectReferenceType) { ObjectReferenceType prv = (ObjectReferenceType) ort; + if (StringUtils.isEmpty(prv.getOid())){ + return createStringResource("ValueChoosePanel.undefined").getString(); + } String targetObjectName = WebComponentUtil.getName(prv, ValueChoosePanel.this.getPageBase(), OPERATION_LOAD_REFERENCE_OBJECT_DISPLAY_NAME); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/prism/ContainerWrapper.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/prism/ContainerWrapper.java index e910e07023b..2517903b859 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/prism/ContainerWrapper.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/prism/ContainerWrapper.java @@ -235,6 +235,12 @@ static String getDisplayNameFromItem(Item item) { PrismValue val = item.getParent(); if (val != null && val.getTypeName() != null) { displayName = val.getTypeName().getLocalPart() + "." + displayName; + //try to localize display name with newly built key + //if no localized value if found, just take the name + String localizedDisplayName = localizeName(displayName); + if (StringUtils.isEmpty(localizedDisplayName) || localizedDisplayName.equals(displayName)){ + displayName = name.getLocalPart(); + } } } else { displayName = item.getDefinition().getTypeName().getLocalPart(); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/SchemaHandlingStep.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/SchemaHandlingStep.java index 89a2c601163..ca76db2c840 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/SchemaHandlingStep.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/SchemaHandlingStep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceActivationEditor.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceActivationEditor.java index f4080e387f3..68c5f4d1fd2 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceActivationEditor.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceActivationEditor.java @@ -74,19 +74,19 @@ public class ResourceActivationEditor extends BasePanel> options = distinct ? createCollection(createDistinct()) : null; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/OrgTreePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/OrgTreePanel.java index 06d553372c7..915674de1dd 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/OrgTreePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/orgs/OrgTreePanel.java @@ -279,7 +279,7 @@ protected void onModelChanged() { TreeStateSet> items = (TreeStateSet) getModelObject(); boolean isInverse = getOrgTreeStateStorage() != null ? getOrgTreeStateStorage().isInverse() : items.isInverse(); - if (isInverse) { + if (!isInverse) { OrgTreePanel.this.setExpandedItems(items, getOrgTreeStateStorage()); } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointGuiAuthorizationEvaluator.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointGuiAuthorizationEvaluator.java index 423a155c447..d2fd18f0ddc 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointGuiAuthorizationEvaluator.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/security/MidPointGuiAuthorizationEvaluator.java @@ -23,9 +23,9 @@ import com.evolveum.midpoint.prism.delta.PlusMinusZero; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.schema.AccessDecision; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.security.api.*; -import com.evolveum.midpoint.security.enforcer.api.AccessDecision; import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; import com.evolveum.midpoint.security.enforcer.api.ObjectSecurityConstraints; diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionValidator.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionValidator.java index 6eb022c359a..f1584315ac3 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionValidator.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/util/ExpressionValidator.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2010-2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.evolveum.midpoint.web.util; import java.util.Collection; @@ -18,6 +33,7 @@ import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -130,8 +146,8 @@ public void validate(IValidatable validatable) { Expression, PrismPropertyDefinition> expression; try { expression = expressionFactory - .makeExpression(expressionType, outputDefinition, contextDesc, task, result); - } catch (SchemaException | ObjectNotFoundException e) { + .makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, result); + } catch (SchemaException | ObjectNotFoundException | SecurityViolationException e) { ValidationError error = new ValidationError(); error.setMessage("Cannot make expression: " + e.getMessage()); validatable.error(error); @@ -139,8 +155,8 @@ public void validate(IValidatable validatable) { return; } ExpressionVariables variables = new ExpressionVariables(); - variables.addVariableDefinition(ExpressionConstants.VAR_INPUT, valueToValidate); - variables.addVariableDefinition(ExpressionConstants.VAR_OBJECT, getObjectType()); + variables.put(ExpressionConstants.VAR_INPUT, valueToValidate, valueToValidate.getClass()); + variables.putObject(ExpressionConstants.VAR_OBJECT, (ObjectType)getObjectType(), ObjectType.class); // addAdditionalExpressionVariables(variables); ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task, result); PrismValueDeltaSetTriple> outputTriple; diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Definition.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Definition.java index 996a14395ec..c9f11d5842e 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Definition.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Definition.java @@ -174,7 +174,10 @@ default SchemaRegistry getSchemaRegistry() { // TODO fix this! Class getTypeClassIfKnown(); - // todo suspicious, please investigate and document + /** + * Returns a compile-time class that is used to represent items. + * E.g. returns String, Integer, sublcasses of Objectable and Containerable and so on. + */ Class getTypeClass(); /** diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrimitiveType.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrimitiveType.java new file mode 100644 index 00000000000..7024338e5ed --- /dev/null +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrimitiveType.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.prism; + +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; +import static com.evolveum.midpoint.util.DOMUtil.NS_W3C_XML_SCHEMA_PREFIX; + +import javax.xml.namespace.QName; + +/** + * @author semancik + * + */ +public enum PrimitiveType { + + STRING("string"), + DECIMAL("decimal"), + INTEGER("integer"), + INT("int"), + LONG("long"), + SHORT("short"), + FLOAT("float"), + DOUBLE("double"), + BOOLEAN("boolean"), + BASE64BINARY("base64binary"), + DATETIME("dateTime"), + DURATION("duration"), + BYTE("byte"), + QNAME("qname"), + ANYURI("anyURI"); + + private final String localName; + private final QName qname; + + private PrimitiveType(String localName) { + this.localName = localName; + this.qname = new QName(W3C_XML_SCHEMA_NS_URI, localName, NS_W3C_XML_SCHEMA_PREFIX); + } + + public QName getQname() { + return qname; + } + + public static final QName XSD_STRING = STRING.getQname(); + public static final QName XSD_DECIMAL = DECIMAL.getQname(); + public static final QName XSD_INTEGER = INTEGER.getQname(); + public static final QName XSD_INT = INT.getQname(); + public static final QName XSD_LONG = LONG.getQname(); + public static final QName XSD_SHORT = SHORT.getQname(); + public static final QName XSD_FLOAT = FLOAT.getQname(); + public static final QName XSD_DOUBLE = DOUBLE.getQname(); + public static final QName XSD_BOOLEAN = BOOLEAN.getQname(); + public static final QName XSD_BASE64BINARY = BASE64BINARY.getQname(); + public static final QName XSD_DATETIME = DATETIME.getQname(); + public static final QName XSD_DURATION = DURATION.getQname(); + public static final QName XSD_BYTE = BYTE.getQname(); + public static final QName XSD_QNAME = QNAME.getQname(); + public static final QName XSD_ANYURI = ANYURI.getQname(); + +} diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java index 8841a1ddf59..6812d66fb09 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/PrismContainerDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,4 +62,7 @@ public interface PrismContainerDefinition extends ItemD @Override MutablePrismContainerDefinition toMutable(); + + @Override + Class getTypeClass(); } diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Structured.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Structured.java index ab7fbbdc738..aff9a804f49 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Structured.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/Structured.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,14 @@ import com.evolveum.midpoint.prism.path.ItemPath; /** - * @author semancik - * + * Interface for properties that have inner structur, such as PolyString. + * This was created due to a limitation that we cannot make every structured + * data into a container (yet). + * + * This is a temporary solution in 3.x and 4.x. It should be gone in 5.x. + * Do not realy on this with any new development. + * + * @author Radovan Semancik */ @FunctionalInterface public interface Structured { diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/extensions/AbstractDelegatedPrismValueDeltaSetTriple.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/extensions/AbstractDelegatedPrismValueDeltaSetTriple.java index a14c363b7c7..4e76dd8bfdb 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/extensions/AbstractDelegatedPrismValueDeltaSetTriple.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/extensions/AbstractDelegatedPrismValueDeltaSetTriple.java @@ -307,38 +307,14 @@ public String toHumanReadableString() { return inner.toHumanReadableString(); } - @Override - public String debugDump() { - return inner.debugDump(); - } - @Override public String debugDump(int indent) { return inner.debugDump(indent); } - @Override - public Object debugDumpLazily() { - return inner.debugDumpLazily(); - } - - @Override - public Object debugDumpLazily(int index) { - return inner.debugDumpLazily(index); - } - @Override public void shortDump(StringBuilder sb) { inner.shortDump(sb); } - @Override - public String shortDump() { - return inner.shortDump(); - } - - @Override - public Object shortDumpLazily() { - return inner.shortDumpLazily(); - } } diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ItemDeltaItem.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ItemDeltaItem.java index e4388ffcdf4..13365784d85 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ItemDeltaItem.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ItemDeltaItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,14 @@ public class ItemDeltaItem implem private Item itemOld; private ItemDelta delta; private Item itemNew; + // We need explicit definition, because source may be completely null. + // No item, no delta, nothing. In that case we won't be able to crete properly-typed + // variable from the source. + private D definition; private ItemPath resolvePath = ItemPath.EMPTY_PATH; + + // Residual path is a temporary solution to Structured attriebutes in 3.x and 4.x. + // It should disappear in 5.x. private ItemPath residualPath = null; // The deltas in sub-items. E.g. if this object represents "ContainerDeltaContainer" @@ -52,25 +59,57 @@ public class ItemDeltaItem implem public ItemDeltaItem() { } - public ItemDeltaItem(Item itemOld, ItemDelta delta, Item itemNew) { + public ItemDeltaItem(Item itemOld, ItemDelta delta, Item itemNew, D definition) { super(); + validate(itemOld, "itemOld"); + validate(delta); + validate(itemNew, "itemNew"); this.itemOld = itemOld; this.delta = delta; this.itemNew = itemNew; + if (definition == null) { + // Try to automatically determine definition from content. + this.definition = determineDefinition(); + if (this.definition == null) { + throw new IllegalArgumentException("Cannot determine definition from content in "+this); + } + } else { + this.definition = definition; + } + + } + + private D determineDefinition() { + if (itemNew != null && itemNew.getDefinition() != null) { + return itemNew.getDefinition(); + } + if (itemOld != null && itemOld.getDefinition() != null) { + return itemOld.getDefinition(); + } + if (delta != null && delta.getDefinition() != null) { + return delta.getDefinition(); + } + return null; } public ItemDeltaItem(ItemDeltaItem idi) { super(); this.itemOld = idi.getItemOld(); + validate(itemOld, "itemOld"); this.itemNew = idi.getItemNew(); + validate(itemNew, "itemNew"); this.delta = idi.getDelta(); + validate(delta); + this.definition = idi.getDefinition(); } public ItemDeltaItem(Item item) { super(); this.itemOld = item; this.itemNew = item; + validate(itemOld, "item"); this.delta = null; + this.definition = item.getDefinition(); } public Item getItemOld() { @@ -143,15 +182,12 @@ public QName getElementName() { return null; } - public ItemDefinition getDefinition() { - Item anyItem = getAnyItem(); - if (anyItem != null) { - return anyItem.getDefinition(); - } - if (delta != null) { - return delta.getDefinition(); - } - return null; + public D getDefinition() { + return definition; + } + + public void setDefinition(D definition) { + this.definition = definition; } public void recompute() throws SchemaException { @@ -170,7 +206,7 @@ public void recompute() throws SchemaException { } } - public ItemDeltaItem findIdi(ItemPath path) { + public ItemDeltaItem findIdi(ItemPath path) throws SchemaException { if (path.isEmpty()) { return (ItemDeltaItem) this; } @@ -205,7 +241,15 @@ public ItemDeltaItem f } } } - ItemDeltaItem subIdi = new ItemDeltaItem<>(subItemOld, subDelta, subItemNew); + ID subDefinition = null; + if (definition != null) { + if (definition instanceof PrismContainerDefinition) { + subDefinition = ((PrismContainerDefinition)definition).findItemDefinition(path); + } else { + throw new IllegalArgumentException("Attempt to resolve definition on non-container " + definition); + } + } + ItemDeltaItem subIdi = new ItemDeltaItem<>(subItemOld, subDelta, subItemNew, subDefinition); subIdi.setResidualPath(subResidualPath); subIdi.resolvePath = newResolvePath; @@ -291,7 +335,7 @@ public ItemDeltaItem,PrismPropertyDefinition> resol PrismProperty outputPropertyNew = resolveStructuredPropertyItem((PrismProperty) thisIdi.getItemNew(), resolvePath, outputDefinition); PrismProperty outputPropertyOld = resolveStructuredPropertyItem((PrismProperty) thisIdi.getItemOld(), resolvePath, outputDefinition); PropertyDelta outputDelta = resolveStructuredPropertyDelta((PropertyDelta) thisIdi.getDelta(), resolvePath, outputDefinition, outputPath, prismContext); - return new ItemDeltaItem<>(outputPropertyOld, outputDelta, outputPropertyNew); + return new ItemDeltaItem<>(outputPropertyOld, outputDelta, outputPropertyNew, outputDefinition); } private PrismProperty resolveStructuredPropertyItem(PrismProperty sourceProperty, ItemPath resolvePath, PrismPropertyDefinition outputDefinition) { @@ -371,6 +415,7 @@ protected void copyValues(ItemDeltaItem clone) { if (this.itemOld != null) { clone.itemOld = this.itemOld.clone(); } + clone.definition = this.definition; clone.residualPath = this.residualPath; clone.resolvePath = this.resolvePath; if (this.subItemDeltas != null) { @@ -427,6 +472,7 @@ public String debugDump(int indent) { DebugUtil.debugDumpWithLabelLn(sb, "itemOld", itemOld, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "delta", delta, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "itemNew", itemNew, indent + 1); + DebugUtil.debugDumpWithLabelLn(sb, "definition", definition, indent + 1); DebugUtil.debugDumpWithLabelToStringLn(sb, "resolvePath", resolvePath, indent + 1); DebugUtil.debugDumpWithLabelToString(sb, "residualPath", residualPath, indent + 1); return sb.toString(); @@ -445,4 +491,16 @@ private V getSingleValue(Item item) { public V getSingleValue(boolean evaluateOld) { return getSingleValue(evaluateOld ? itemOld : itemNew); } + + private void validate(Item item, String desc) { + if (item != null && item.getDefinition() == null) { + throw new IllegalArgumentException("Attempt to set "+desc+" without definition"); + } + } + + private void validate(ItemDelta delta) { + if (delta != null && delta.getDefinition() == null) { + throw new IllegalArgumentException("Attempt to set delta without definition"); + } + } } diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ObjectDeltaObject.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ObjectDeltaObject.java index f944bb67ab9..3a5427ed60e 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ObjectDeltaObject.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/ObjectDeltaObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,25 @@ import java.util.Collection; import java.util.List; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; +import org.apache.commons.collections4.CollectionUtils; +import org.jetbrains.annotations.NotNull; + +import com.evolveum.midpoint.prism.Item; +import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.Objectable; +import com.evolveum.midpoint.prism.PartiallyResolvedItem; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerValue; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismValue; +import com.evolveum.midpoint.prism.delta.ChangeType; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import org.apache.commons.collections4.CollectionUtils; /** * A class defining old object state (before change), delta (change) and new object state (after change). @@ -42,12 +54,34 @@ public class ObjectDeltaObject extends ItemDeltaItem oldObject; private ObjectDelta delta; private PrismObject newObject; + // We need explicit definition, because source may be completely null. + // No item, no delta, nothing. In that case we won't be able to crete properly-typed + // variable from the source. + private PrismObjectDefinition definition; - public ObjectDeltaObject(PrismObject oldObject, ObjectDelta delta, PrismObject newObject) { + public ObjectDeltaObject(PrismObject oldObject, ObjectDelta delta, PrismObject newObject, PrismObjectDefinition definition) { super(); this.oldObject = oldObject; this.delta = delta; this.newObject = newObject; + if (definition == null) { + this.definition = determineDefinition(); + if (this.definition == null) { + throw new IllegalArgumentException("Cannot determine definition from content in "+this); + } + } else { + this.definition = definition; + } + } + + private PrismObjectDefinition determineDefinition() { + if (newObject != null && newObject.getDefinition() != null) { + return newObject.getDefinition(); + } + if (oldObject != null && oldObject.getDefinition() != null) { + return oldObject.getDefinition(); + } + return null; } public PrismObject getOldObject() { @@ -84,7 +118,7 @@ public PrismObject getAnyObject() { } return oldObject; } - + @Override public ItemDelta,PrismObjectDefinition> getDelta() { throw new UnsupportedOperationException("You probably wanted to call getObjectDelta()"); @@ -102,6 +136,9 @@ public boolean isContainer() { @Override public PrismObjectDefinition getDefinition() { + if (definition != null) { + return definition; + } PrismObject anyObject = getAnyObject(); if (anyObject != null) { return anyObject.getDefinition(); @@ -111,9 +148,20 @@ public PrismObjectDefinition getDefinition() { } return null; } + + public Class getObjectCompileTimeClass() { + PrismObject anyObject = getAnyObject(); + if (anyObject != null) { + return anyObject.getCompileTimeClass(); + } + if (delta != null) { + return delta.getObjectTypeClass(); + } + return null; + } @Override - public ItemDeltaItem findIdi(ItemPath path) { + public ItemDeltaItem findIdi(@NotNull ItemPath path) throws SchemaException { Item subItemOld = null; ItemPath subResidualPath = null; if (oldObject != null) { @@ -180,7 +228,24 @@ public ItemDeltaItem fi } } } - ItemDeltaItem subIdi = new ItemDeltaItem<>(subItemOld, itemDelta, subItemNew); + ID subDefinition = null; + if (definition != null) { + subDefinition = definition.findItemDefinition(path); + } + if (subDefinition == null) { + // This may be a bit redundant, because IDI constructor does similar logic. + // But we want to know the situation here, so we can provide better error message. + if (subItemNew != null && subItemNew.getDefinition() != null) { + subDefinition = subItemNew.getDefinition(); + } else if (subItemOld != null && subItemOld.getDefinition() != null) { + subDefinition = subItemOld.getDefinition(); + } else if (itemDelta != null && itemDelta.getDefinition() != null) { + subDefinition = itemDelta.getDefinition(); + } else { + throw new SchemaException("Cannot find definition of a subitem "+path+" of "+this); + } + } + ItemDeltaItem subIdi = new ItemDeltaItem<>(subItemOld, itemDelta, subItemNew, subDefinition); subIdi.setSubItemDeltas(subSubItemDeltas); subIdi.setResolvePath(path); subIdi.setResidualPath(subResidualPath); @@ -242,7 +307,7 @@ public void recomputeIfNeeded(boolean deep) throws SchemaException { public static ObjectDeltaObject create(PrismObject oldObject, ObjectDelta delta) throws SchemaException { PrismObject newObject = oldObject.clone(); delta.applyTo(newObject); - return new ObjectDeltaObject<>(oldObject, delta, newObject); + return new ObjectDeltaObject<>(oldObject, delta, newObject, oldObject.getDefinition()); } public static ObjectDeltaObject create(PrismObject oldObject, ItemDelta... itemDeltas) throws SchemaException { @@ -306,6 +371,7 @@ public String debugDump(int indent) { } } dumpObject(sb, newObject, "new", indent +1); + DebugUtil.debugDumpWithLabelLn(sb, "definition", definition, indent + 1); return sb.toString(); } @@ -330,7 +396,8 @@ public ObjectDeltaObject clone() { ObjectDeltaObject clone = new ObjectDeltaObject<>( CloneUtil.clone(oldObject), CloneUtil.clone(delta), - CloneUtil.clone(newObject)); + CloneUtil.clone(newObject), + definition); // TODO what about the internals? return clone; } diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismUtil.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismUtil.java index 2a4e979bf67..29a051a76b8 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismUtil.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.evolveum.midpoint.prism.xml.XsdTypeMapper; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import org.apache.commons.lang.StringUtils; @@ -236,4 +237,8 @@ public static void debugDumpWithLabelLn(StringBuilder sb, String label, Containe debugDumpWithLabel(sb, label, cc, indent); sb.append("\n"); } + + public static boolean isStructuredType(QName typeName) { + return QNameUtil.match(PolyStringType.COMPLEX_TYPE, typeName); + } } diff --git a/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/PolyStringType.java b/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/PolyStringType.java index 0e37116ffc8..8b7f59d8db3 100644 --- a/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/PolyStringType.java +++ b/infra/prism-api/src/main/java/com/evolveum/prism/xml/ns/_public/types_3/PolyStringType.java @@ -546,11 +546,12 @@ private static JAXBElement copyOfStringElement(final JAXBElement return null; } + // !!! Do NOT autogenerate this method without preserving custom changes !!! @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((any == null) ? 0 : any.hashCode()); + result = prime * result + ((any == null || any.isEmpty()) ? 0 : any.hashCode()); result = prime * result + ((lang == null) ? 0 : lang.hashCode()); result = prime * result + ((norm == null) ? 0 : norm.hashCode()); result = prime * result + ((orig == null) ? 0 : orig.hashCode()); @@ -558,6 +559,7 @@ public int hashCode() { return result; } + // !!! Do NOT autogenerate this method without preserving custom changes !!! @Override public boolean equals(Object obj) { if (this == obj) { @@ -570,8 +572,8 @@ public boolean equals(Object obj) { return false; } PolyStringType other = (PolyStringType) obj; - if (any == null) { - if (other.any != null) { + if (any == null || any.isEmpty()) { // because any is instantiated on get (so null and empty should be considered equivalent) + if (other.any != null && !other.any.isEmpty()) { return false; } } else if (!any.equals(other.any)) { diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemDefinitionImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemDefinitionImpl.java index d667fc6d605..b556c0dbda5 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemDefinitionImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/ItemDefinitionImpl.java @@ -322,7 +322,7 @@ public T findItemDefinition(@NotNull ItemPath path, @ throw new IllegalArgumentException("Looking for definition of class " + clazz + " but found " + this); } } else { - throw new IllegalArgumentException("No definition for path " + path + " in " + this); + return null; } } diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContainerDefinitionImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContainerDefinitionImpl.java index e51a09a2fef..27cca19563c 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContainerDefinitionImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismContainerDefinitionImpl.java @@ -112,6 +112,11 @@ public Class getCompileTimeClass() { public void setCompileTimeClass(Class compileTimeClass) { this.compileTimeClass = compileTimeClass; } + + @Override + public Class getTypeClass() { + return compileTimeClass; + } protected String getSchemaNamespace() { return getName().getNamespaceURI(); diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismReferenceDefinitionImpl.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismReferenceDefinitionImpl.java index 6d4a83074f7..dbd0823530a 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismReferenceDefinitionImpl.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/PrismReferenceDefinitionImpl.java @@ -24,6 +24,8 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.DefinitionUtil; import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.prism.xml.ns._public.types_3.ObjectReferenceType; + import org.jetbrains.annotations.NotNull; /** @@ -149,6 +151,11 @@ public boolean canBeDefinitionOf(PrismValue pvalue) { return true; } } + + @Override + public Class getTypeClass() { + return ObjectReferenceType.class; + } @Override public MutablePrismReferenceDefinition toMutable() { diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/xjc/PrismForJAXBUtil.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/xjc/PrismForJAXBUtil.java index 6ba1cb99491..22310a4ad03 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/xjc/PrismForJAXBUtil.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/xjc/PrismForJAXBUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,10 +38,13 @@ /** * @author lazyman + * @author semancik */ public final class PrismForJAXBUtil { - private PrismForJAXBUtil() { + private static final Object JAXB_CLASS_MANGLED = "clazz"; + + private PrismForJAXBUtil() { } public static T getPropertyValue(PrismContainerValue container, QName name, Class clazz) { @@ -163,6 +166,11 @@ public static T getFieldSingleContainerable(PrismConta public static > T getContainer(PrismContainerValue parentValue, QName name) { Validate.notNull(parentValue, "Parent container value must not be null."); Validate.notNull(name, "QName must not be null."); + + // This is how JAXB compiler handles elements of name "class". + if (JAXB_CLASS_MANGLED.equals(name.getLocalPart())) { + name = new QName(name.getNamespaceURI(), "class"); + } try { PrismContainer container = parentValue.findContainer(name); diff --git a/repo/security-enforcer-api/src/main/java/com/evolveum/midpoint/security/enforcer/api/AccessDecision.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/AccessDecision.java similarity index 72% rename from repo/security-enforcer-api/src/main/java/com/evolveum/midpoint/security/enforcer/api/AccessDecision.java rename to infra/schema/src/main/java/com/evolveum/midpoint/schema/AccessDecision.java index f8e4e457683..e24f0ecc1f8 100644 --- a/repo/security-enforcer-api/src/main/java/com/evolveum/midpoint/security/enforcer/api/AccessDecision.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/AccessDecision.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 Evolveum + * Copyright (c) 2017-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,29 +13,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.evolveum.midpoint.security.enforcer.api; +package com.evolveum.midpoint.schema; import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationDecisionType; /** - * @author semancik - * + * Decision about access to something. Used as an output of authorization processing code. But may be also used + * for other things, such as decisions to access classes and methods in sandboxes. + * + * @author Radovan Semancik */ public enum AccessDecision { + /** * Access explicitly allowed. */ - ALLOW, + ALLOW(AuthorizationDecisionType.ALLOW), /** * Access explicitly denied. */ - DENY, + DENY(AuthorizationDecisionType.DENY), /** * Means "no decision" or "not allowed yet". */ - DEFAULT; + DEFAULT(null); + + private final AuthorizationDecisionType authorizationDecisionType; + + private AccessDecision(AuthorizationDecisionType authorizationDecisionType) { + this.authorizationDecisionType = authorizationDecisionType; + } + + public AuthorizationDecisionType getAuthorizationDecisionType() { + return authorizationDecisionType; + } public static AccessDecision combine(AccessDecision oldDecision, AccessDecision newDecision) { if (oldDecision == null && newDecision == null) { @@ -72,4 +85,5 @@ public static AccessDecision translate(AuthorizationDecisionType authorizationDe throw new IllegalStateException("Unknown AuthorizationDecisionType "+authorizationDecisionType); } } + } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/ExpressionConstants.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/ExpressionConstants.java index cffd3c8f5d1..9641da94f90 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/ExpressionConstants.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/ExpressionConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,112 +17,152 @@ import com.evolveum.midpoint.prism.path.ItemName; -import javax.xml.namespace.QName; - /** - * @author semancik - * + * Constants for all names of the variables in the system. + * + * It is good to have all the names gathered in one place. It is better when a new + * variable is introduced. If all the names are in the same place, it is better to + * see if the variable is redundant (already used eslewhere). Or if new variable is + * really needed, seeing all the other names will make it easier to keep the same + * convention through the system. + * + * @author Radovan Semancik */ public class ExpressionConstants { // Generic variables - public static final QName VAR_INPUT = new QName(SchemaConstants.NS_C, "input"); - public static final QName VAR_OBJECT = new QName(SchemaConstants.NS_C, "object"); + public static final String VAR_INPUT = "input"; + public static final ItemName VAR_INPUT_QNAME = new ItemName(SchemaConstants.NS_C, VAR_INPUT); + public static final String VAR_OBJECT = "object"; // Variables used in various mappings - public static final QName VAR_FOCUS = new QName(SchemaConstants.NS_C, "focus"); - public static final QName VAR_PROJECTION = new QName(SchemaConstants.NS_C, "projection"); - public static final QName VAR_SOURCE = new QName(SchemaConstants.NS_C, "source"); - public static final QName VAR_ASSIGNMENT = new QName(SchemaConstants.NS_C, "assignment"); - public static final QName VAR_EVALUATED_ASSIGNMENT = new QName(SchemaConstants.NS_C, "evaluatedAssignment"); - public static final QName VAR_ASSIGNMENT_PATH = new QName(SchemaConstants.NS_C, "assignmentPath"); - public static final QName VAR_IMMEDIATE_ASSIGNMENT = new QName(SchemaConstants.NS_C, "immediateAssignment"); - public static final QName VAR_THIS_ASSIGNMENT = new QName(SchemaConstants.NS_C, "thisAssignment"); - public static final QName VAR_FOCUS_ASSIGNMENT = new QName(SchemaConstants.NS_C, "focusAssignment"); - public static final QName VAR_IMMEDIATE_ROLE = new QName(SchemaConstants.NS_C, "immediateRole"); - public static final QName VAR_CONTAINING_OBJECT = new QName(SchemaConstants.NS_C, "containingObject"); - public static final QName VAR_ORDER_ONE_OBJECT = new QName(SchemaConstants.NS_C, "thisObject"); - public static final QName VAR_OPERATION = new QName(SchemaConstants.NS_C, "operation"); - public static final QName VAR_RESOURCE = new QName(SchemaConstants.NS_C, "resource"); - public static final QName VAR_DELTA = new QName(SchemaConstants.NS_C, "delta"); - public static final QName VAR_MODEL_CONTEXT = new QName(SchemaConstants.NS_C, "modelContext"); - public static final QName VAR_PRISM_CONTEXT = new QName(SchemaConstants.NS_C, "prismContext"); - public static final QName VAR_CONFIGURATION = new QName(SchemaConstants.NS_C, "configuration"); - public static final QName VAR_ENTITLEMENT = new QName(SchemaConstants.NS_C, "entitlement"); - public static final QName VAR_FILE = new QName(SchemaConstants.NS_C, "file"); + public static final String VAR_FOCUS = "focus"; + public static final String VAR_PROJECTION = "projection"; + public static final String VAR_SOURCE = "source"; + public static final String VAR_ASSIGNMENT = "assignment"; + public static final String VAR_EVALUATED_ASSIGNMENT = "evaluatedAssignment"; + public static final String VAR_ASSIGNMENT_PATH = "assignmentPath"; + public static final String VAR_IMMEDIATE_ASSIGNMENT = "immediateAssignment"; + public static final String VAR_THIS_ASSIGNMENT = "thisAssignment"; + public static final String VAR_FOCUS_ASSIGNMENT = "focusAssignment"; + public static final String VAR_IMMEDIATE_ROLE = "immediateRole"; + public static final String VAR_CONTAINING_OBJECT = "containingObject"; + public static final String VAR_ORDER_ONE_OBJECT = "thisObject"; + public static final String VAR_OPERATION = "operation"; + public static final String VAR_RESOURCE = "resource"; + public static final String VAR_DELTA = "delta"; + public static final String VAR_MODEL_CONTEXT = "modelContext"; + public static final String VAR_PRISM_CONTEXT = "prismContext"; + public static final String VAR_CONFIGURATION = "configuration"; + public static final String VAR_ENTITLEMENT = "entitlement"; + public static final String VAR_FILE = "file"; /** * User that is currently executing the operation. */ - public static final QName VAR_ACTOR = new QName(SchemaConstants.NS_C, "actor"); + public static final String VAR_ACTOR = "actor"; /** * Subject of an authorization. This is usually the same as actor. But it may be different * in some exotic use cases (e.g. if administrator needs to evaluate authorizations of * a different user. */ - public static final QName VAR_SUBJECT = new QName(SchemaConstants.NS_C, "subject"); + public static final String VAR_SUBJECT = "subject"; - public static final QName VAR_VALUE = new QName(SchemaConstants.NS_C, "value"); - public static final QName VAR_ORGS = new QName(SchemaConstants.NS_C, "orgs"); + public static final String VAR_VALUE = "value"; + public static final String VAR_ORGS = "orgs"; - public static final QName VAR_TARGET = new QName(SchemaConstants.NS_C, "target"); + public static final String VAR_TARGET = "target"; // DEPRECATED variables, just for compatibility - public static final QName VAR_USER = new QName(SchemaConstants.NS_C, "user"); - public static final QName VAR_ACCOUNT = new QName(SchemaConstants.NS_C, "account"); - public static final QName VAR_SHADOW = new QName(SchemaConstants.NS_C, "shadow"); + public static final String VAR_USER = "user"; + public static final String VAR_ACCOUNT = "account"; + public static final String VAR_SHADOW = "shadow"; // existence mapping variables - public static final QName VAR_LEGAL = new QName(SchemaConstants.NS_C, "legal"); - public static final QName VAR_ASSIGNED = new QName(SchemaConstants.NS_C, "assigned"); - public static final QName VAR_FOCUS_EXISTS = new QName(SchemaConstants.NS_C, "focusExists"); - public static final QName VAR_ADMINISTRATIVE_STATUS = new QName(SchemaConstants.NS_C, "administrativeStatus"); + public static final String VAR_LEGAL = "legal"; + public static final ItemName VAR_LEGAL_QNAME = new ItemName(SchemaConstants.NS_C, VAR_LEGAL); + + public static final String VAR_ASSIGNED = "assigned"; + public static final ItemName VAR_ASSIGNED_QNAME = new ItemName(SchemaConstants.NS_C, VAR_ASSIGNED); + + public static final String VAR_FOCUS_EXISTS = "focusExists"; + public static final ItemName VAR_FOCUS_EXISTS_QNAME = new ItemName(SchemaConstants.NS_C, VAR_FOCUS_EXISTS); + + public static final String VAR_ADMINISTRATIVE_STATUS = "administrativeStatus"; + public static final ItemName VAR_ADMINISTRATIVE_STATUS_QNAME = new ItemName(SchemaConstants.NS_C, VAR_ADMINISTRATIVE_STATUS); - public static final QName VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION = new QName(SchemaConstants.NS_C, "associationTargetObjectClassDefinition"); + public static final String VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION = "associationTargetObjectClassDefinition"; /** * Numeric value describing the current iteration. It starts with 0 and increments on every iteration. * Iterations are used to find unique values for an account, to resolve naming conflicts, etc. */ - public static final ItemName VAR_ITERATION = new ItemName(SchemaConstants.NS_C, "iteration"); + public static final String VAR_ITERATION = "iteration"; + public static final ItemName VAR_ITERATION_QNAME = new ItemName(SchemaConstants.NS_C, VAR_ITERATION); /** * String value describing the current iteration. It is usually suffix that is appended to the username * or a similar "extension" of the value. It should have different value for every iteration. The actual * value is determined by the iteration settings. */ - public static final ItemName VAR_ITERATION_TOKEN = new ItemName(SchemaConstants.NS_C, "iterationToken"); + public static final String VAR_ITERATION_TOKEN = "iterationToken"; + public static final ItemName VAR_ITERATION_TOKEN_QNAME = new ItemName(SchemaConstants.NS_C, VAR_ITERATION_TOKEN); // Variables used in object merging expressions - public static final QName VAR_SIDE = new QName(SchemaConstants.NS_C, "side"); - public static final QName VAR_OBJECT_LEFT = new QName(SchemaConstants.NS_C, "objectLeft"); - public static final QName VAR_OBJECT_RIGHT = new QName(SchemaConstants.NS_C, "objectRight"); + public static final String VAR_SIDE = "side"; + public static final String VAR_OBJECT_LEFT = "objectLeft"; + public static final String VAR_OBJECT_RIGHT = "objectRight"; - public static final QName OUTPUT_ELEMENT_NAME = new QName(SchemaConstants.NS_C, "output"); + public static final ItemName OUTPUT_ELEMENT_NAME = new ItemName(SchemaConstants.NS_C, "output"); // "case" would collide with java keyword - public static final QName VAR_WORK_ITEM = new QName(SchemaConstants.NS_C, "workItem"); - public static final QName VAR_CERTIFICATION_CASE = new QName(SchemaConstants.NS_C, "certificationCase"); - public static final QName VAR_CAMPAIGN = new QName(SchemaConstants.NS_C, "campaign"); - public static final QName VAR_REVIEWER_SPECIFICATION = new QName(SchemaConstants.NS_C, "reviewerSpecification"); - - public static final QName VAR_CHANNEL = new QName(SchemaConstants.NS_C, "channel"); - public static final QName VAR_WORKFLOW_CONTEXT = new QName(SchemaConstants.NS_C, "workflowContext"); - public static final QName VAR_TASK = new QName(SchemaConstants.NS_C, "task"); - public static final QName VAR_RULE_EVALUATION_CONTEXT = new QName(SchemaConstants.NS_C, "ruleEvaluationContext"); - public static final QName VAR_STAGE_DEFINITION = new QName(SchemaConstants.NS_C, "stageDefinition"); - - public static final QName VAR_OBJECT_DISPLAY_INFORMATION = new QName(SchemaConstants.NS_C, "objectDisplayInformation"); - public static final QName VAR_TARGET_DISPLAY_INFORMATION = new QName(SchemaConstants.NS_C, "targetDisplayInformation"); - - public static final QName VAR_PERFORMER = new QName(SchemaConstants.NS_C, "performer"); - public static final QName VAR_OUTPUT = new QName(SchemaConstants.NS_C, "output"); - public static final QName VAR_EVENT = new QName(SchemaConstants.NS_C, "event"); - - public static final QName VAR_POLICY_RULE = new QName(SchemaConstants.NS_C, "policyRule"); - public static final QName VAR_POLICY_ACTION = new QName(SchemaConstants.NS_C, "policyAction"); - public static final QName VAR_LOGIN_MODE = new QName(SchemaConstants.NS_C, "loginMode"); - - public static final QName VAR_MESSAGE = new QName(SchemaConstants.NS_C, "message"); + public static final String VAR_WORK_ITEM = "workItem"; + public static final String VAR_CERTIFICATION_CASE = "certificationCase"; + public static final String VAR_CAMPAIGN = "campaign"; + public static final String VAR_REVIEWER_SPECIFICATION = "reviewerSpecification"; + + public static final String VAR_CHANNEL = "channel"; + public static final String VAR_WORKFLOW_CONTEXT = "workflowContext"; + public static final String VAR_TASK = "task"; + public static final String VAR_RULE_EVALUATION_CONTEXT = "ruleEvaluationContext"; + public static final String VAR_STAGE_DEFINITION = "stageDefinition"; + public static final String VAR_ITEM_TO_APPROVE = "itemToApprove"; + + public static final String VAR_OBJECT_DISPLAY_INFORMATION = "objectDisplayInformation"; + public static final String VAR_TARGET_DISPLAY_INFORMATION = "targetDisplayInformation"; + + public static final String VAR_PERFORMER = "performer"; + public static final String VAR_OUTPUT = "output"; + public static final String VAR_EVENT = "event"; + public static final String VAR_REQUESTER = "requester"; + public static final String VAR_REQUESTEE = "requestee"; + public static final String VAR_ASSIGNEE = "assignee"; + public static final String VAR_ASSOCIATION = "association"; + public static final String VAR_SHADOW_DISCRIMINATOR = "shadowDiscriminator"; + + public static final String VAR_POLICY_RULE = "policyRule"; + public static final String VAR_POLICY_ACTION = "policyAction"; + public static final String VAR_LOGIN_MODE = "loginMode"; + + // Notification variables + public static final String VAR_TRANSPORT_NAME = "transportName"; + public static final String VAR_FROM = "from"; + public static final String VAR_ENCODED_FROM = "encodedFrom"; + public static final String VAR_TO = "to"; + public static final String VAR_TO_LIST = "toList"; + public static final String VAR_ENCODED_TO = "encodedTo"; + public static final String VAR_ENCODED_TO_LIST = "encodedToList"; + public static final String VAR_MESSAGE_TEXT = "messageText"; + public static final String VAR_ENCODED_MESSAGE_TEXT = "encodedMessageText"; + public static final String VAR_MESSAGE = "message"; + public static final String VAR_TEXT_FORMATTER = "textFormatter"; + public static final String VAR_NOTIFICATION_FUNCTIONS = "notificationFunctions"; + + // Do we need those? + public static final String VAR_OBJECT_DELTA = "objectDelta"; + + // Too vague. modelContext or prismConext should be used instead. + @Deprecated + public static final String VAR_CONTEXT = "context"; } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/SchemaConstants.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/SchemaConstants.java index 203c6b2cc8d..0820b7b4a44 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/SchemaConstants.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/constants/SchemaConstants.java @@ -87,9 +87,6 @@ public abstract class SchemaConstants { public static final ItemName C_RESOURCE = new ItemName(NS_C, "resource"); public static final ItemName C_RESULT = new ItemName(NS_C, "result"); public static final ItemName C_USER = new ItemName(NS_C, "user"); - public static final ItemName C_REQUESTER = new ItemName(NS_C, "requester"); - public static final ItemName C_REQUESTEE = new ItemName(NS_C, "requestee"); - public static final ItemName C_ASSIGNEE = new ItemName(NS_C, "assignee"); public static final ItemName C_OBJECT_TEMPLATE = new ItemName(NS_C, "objectTemplate"); public static final ItemName C_OBJECT_TEMPLATE_REF = new ItemName(NS_C, "objectTemplateRef"); public static final QName C_OBJECT_TEMPLATE_TYPE = new QName(NS_C, "ObjectTemplateType"); @@ -470,24 +467,6 @@ public abstract class SchemaConstants { public static final ItemName S_PIPELINE_DATA = new ItemName(NS_SCRIPTING, "pipelineData"); - public static final ItemName C_EVENT = new ItemName(NS_C, "event"); - public static final ItemName C_EVENT_HANDLER = new ItemName(NS_C, "eventHandler"); // TODO: no such element in common-3 - is it OK? - public static final ItemName C_TEXT_FORMATTER = new ItemName(NS_C, "textFormatter"); - public static final ItemName C_NOTIFICATION_FUNCTIONS = new ItemName(NS_C, "notificationFunctions"); - - public static final ItemName C_TRANSPORT_NAME = new ItemName(NS_C, "transportName"); - public static final ItemName C_FROM = new ItemName(NS_C, "from"); - public static final ItemName C_ENCODED_FROM = new ItemName(NS_C, "encodedFrom"); - public static final ItemName C_TO = new ItemName(NS_C, "to"); - public static final ItemName C_TO_LIST = new ItemName(NS_C, "toList"); - public static final ItemName C_ENCODED_TO = new ItemName(NS_C, "encodedTo"); - public static final ItemName C_ENCODED_TO_LIST = new ItemName(NS_C, "encodedToList"); - public static final ItemName C_MESSAGE_TEXT = new ItemName(NS_C, "messageText"); - public static final ItemName C_ENCODED_MESSAGE_TEXT = new ItemName(NS_C, "encodedMessageText"); - public static final ItemName C_MESSAGE = new ItemName(NS_C, "message"); - public static final ItemName C_WORK_ITEM = new ItemName(NS_C, "workItem"); - public static final ItemName C_WF_PROCESS_INSTANCE = new ItemName(NS_C, "wfProcessInstance"); - public static final ItemName APIT_ITEM_LIST = new ItemName(SchemaConstants.NS_API_TYPES, "itemList"); public static final ItemName C_ASSIGNMENT = new ItemName(SchemaConstants.NS_C, "assignment"); @@ -495,8 +474,6 @@ public abstract class SchemaConstants { public static final ItemName FAULT_MESSAGE_ELEMENT_NAME = new ItemName(NS_FAULT, "fault"); public static final ItemName C_MODEL_CONTEXT = new ItemName(NS_C, "modelContext"); - public static final ItemName C_ITEM_TO_APPROVE = new ItemName(NS_C, "itemToApprove"); - public static final ItemName C_SHADOW_DISCRIMINATOR = new ItemName(NS_C, "shadowDiscriminator"); // Lifecycle diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionEvaluatorProfile.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionEvaluatorProfile.java new file mode 100644 index 00000000000..0942c7d9181 --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionEvaluatorProfile.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.schema.AccessDecision; + +/** + * @author Radovan Semancik + * + */ +public class ExpressionEvaluatorProfile { + + private final QName type; + private AccessDecision decision; + private final List scritpProfiles = new ArrayList<>(); + + public ExpressionEvaluatorProfile(QName type) { + this.type = type; + } + + public QName getType() { + return type; + } + + public AccessDecision getDecision() { + return decision; + } + + public void setDecision(AccessDecision decision) { + this.decision = decision; + } + + public void add(ScriptExpressionProfile scriptProfile) { + scritpProfiles.add(scriptProfile); + } + + public ScriptExpressionProfile getScriptExpressionProfile(String language) { + for(ScriptExpressionProfile scritpProfile : scritpProfiles) { + if (language.equals(scritpProfile.getLanguage())) { + return scritpProfile; + } + } + return null; + } + + +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionPermissionProfile.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionPermissionProfile.java new file mode 100644 index 00000000000..ff002e810d7 --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionPermissionProfile.java @@ -0,0 +1,164 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import java.util.ArrayList; +import java.util.List; + +import com.evolveum.midpoint.schema.AccessDecision; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionPermissionClassProfileType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionPermissionMethodProfileType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionPermissionPackageProfileType; + +/** + * Compiled expression permission profile. + * Compiled from ExpressionPermissionProfileType. + * + * @author Radovan Semancik + */ +public class ExpressionPermissionProfile { + + private final String identifier; + private AccessDecision decision; + private final List packageProfiles = new ArrayList<>(); + private final List classProfiles = new ArrayList<>(); + + public ExpressionPermissionProfile(String identifier) { + super(); + this.identifier = identifier; + } + + public String getIdentifier() { + return identifier; + } + + public AccessDecision getDecision() { + return decision; + } + + public void setDecision(AccessDecision decision) { + this.decision = decision; + } + + public List getPackageProfiles() { + return packageProfiles; + } + + public List getClassProfiles() { + return classProfiles; + } + + public boolean hasRestrictions() { + return !classProfiles.isEmpty() || !packageProfiles.isEmpty() || decision != AccessDecision.ALLOW; + } + + public AccessDecision decideClassAccess(String className, String methodName) { + ExpressionPermissionClassProfileType classProfile = getClassProfile(className); + if (classProfile == null) { + ExpressionPermissionPackageProfileType packageProfile = getPackageProfileByClassName(className); + if (packageProfile == null) { + return decision; + } else { + return AccessDecision.translate(packageProfile.getDecision()); + } + } + ExpressionPermissionMethodProfileType methodProfile = getMethodProfile(classProfile, methodName); + if (methodProfile == null) { + return AccessDecision.translate(classProfile.getDecision()); + } else { + return AccessDecision.translate(methodProfile.getDecision()); + } + } + + private ExpressionPermissionPackageProfileType getPackageProfileByClassName(String className) { + for (ExpressionPermissionPackageProfileType packageProfile : packageProfiles) { + if (isMemeberClass(packageProfile, className)) { + return packageProfile; + } + } + return null; + } + + + + private boolean isMemeberClass(ExpressionPermissionPackageProfileType packageProfile, String className) { + // TODO Maybe too simple. But this will do for now. + return className.startsWith(packageProfile.getName()); + } + + private ExpressionPermissionClassProfileType getClassProfile(String className) { + for (ExpressionPermissionClassProfileType classProfile : classProfiles) { + if (className.equals(classProfile.getName())) { + return classProfile; + } + } + return null; + } + + private void add(ExpressionPermissionClassProfileType classProfile) { + classProfiles.add(classProfile); + } + + private ExpressionPermissionMethodProfileType getMethodProfile(ExpressionPermissionClassProfileType classProfile, String methodName) { + if (methodName == null) { + return null; + } + for (ExpressionPermissionMethodProfileType methodProfile : classProfile.getMethod()) { + if (methodName.equals(methodProfile.getName())) { + return methodProfile; + } + } + return null; + } + + /** + * Used to easily set up access for built-in class access rules. + */ + public void addClassAccessRule(String className, String methodName, AccessDecision decision) { + ExpressionPermissionClassProfileType classProfile = getClassProfile(className); + if (classProfile == null) { + classProfile = new ExpressionPermissionClassProfileType(); + classProfile.setName(className); + add(classProfile); + } + if (methodName == null) { + classProfile.setDecision(decision.getAuthorizationDecisionType()); + } else { + ExpressionPermissionMethodProfileType methodProfile = getMethodProfile(classProfile, methodName); + if (methodProfile == null) { + methodProfile = new ExpressionPermissionMethodProfileType(); + methodProfile.setName(methodName); + methodProfile.setDecision(decision.getAuthorizationDecisionType()); + classProfile.getMethod().add(methodProfile); + } else { + methodProfile.setDecision(decision.getAuthorizationDecisionType()); + } + } + + } + + + /** + * Used to easily set up access for built-in class access rules (convenience). + */ + public void addClassAccessRule(Class clazz, String methodName, AccessDecision decision) { + addClassAccessRule(clazz.getName(), methodName, decision); + } + + public void addClassAccessRule(Class clazz, AccessDecision decision) { + addClassAccessRule(clazz.getName(), null, decision); + } +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionProfile.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionProfile.java new file mode 100644 index 00000000000..b4080ca526d --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionProfile.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; + +import com.evolveum.midpoint.schema.AccessDecision; +import com.evolveum.midpoint.util.QNameUtil; + +/** + * NOTE: This is pretty much throw-away implementation. Just the interface is important now. + * + * @author Radovan Semancik + * + */ +public class ExpressionProfile { // TODO: DebugDumpable + + private final String identifier; + private AccessDecision decision; + private final List evaluatorProfiles = new ArrayList<>(); + + public ExpressionProfile(String identifier) { + super(); + this.identifier = identifier; + } + + public String getIdentifier() { + return identifier; + } + + public AccessDecision getDecision() { + return decision; + } + + public void setDecision(AccessDecision defaultDecision) { + this.decision = defaultDecision; + } + + public void add(ExpressionEvaluatorProfile evaluatorProfile) { + evaluatorProfiles.add(evaluatorProfile); + } + + public ExpressionEvaluatorProfile getEvaluatorProfile(QName type) { + for (ExpressionEvaluatorProfile evaluatorProfile : evaluatorProfiles) { + if (QNameUtil.match(evaluatorProfile.getType(), type)) { + return evaluatorProfile; + } + } + return null; + } + + @Override + public String toString() { + return "ExpressionProfile(" + identifier + ")"; + } + + + +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionProfiles.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionProfiles.java new file mode 100644 index 00000000000..7b730e8d2c9 --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ExpressionProfiles.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author semancik + * + */ +public class ExpressionProfiles { + + private Map profiles = new HashMap<>(); + + public ExpressionProfile getProfile(String identifier) { + return profiles.get(identifier); + } + + public void add(ExpressionProfile profile) { + profiles.put(profile.getIdentifier(), profile); + } +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ScriptExpressionProfile.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ScriptExpressionProfile.java new file mode 100644 index 00000000000..33ad114bc61 --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/ScriptExpressionProfile.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import com.evolveum.midpoint.schema.AccessDecision; + +/** + * @author semancik + * + */ +public class ScriptExpressionProfile { + + private final String language; + private AccessDecision decision; + private Boolean typeChecking; + private ExpressionPermissionProfile permissionProfile; + + public ScriptExpressionProfile(String language) { + super(); + this.language = language; + } + + public String getLanguage() { + return language; + } + + public AccessDecision getDecision() { + return decision; + } + + public void setDecision(AccessDecision decision) { + this.decision = decision; + } + + public Boolean isTypeChecking() { + return typeChecking; + } + + public void setTypeChecking(Boolean typeChecking) { + this.typeChecking = typeChecking; + } + + public ExpressionPermissionProfile getPermissionProfile() { + return permissionProfile; + } + + public void setPermissionProfile(ExpressionPermissionProfile permissionProfile) { + this.permissionProfile = permissionProfile; + } + + public boolean hasRestrictions() { + if (permissionProfile == null) { + return false; + } + return permissionProfile.hasRestrictions(); + } + + public AccessDecision decideClassAccess(String className, String methodName) { + if (permissionProfile == null) { + return decision; + } + AccessDecision permissionDecision = permissionProfile.decideClassAccess(className, methodName); + if (permissionDecision == null || permissionDecision == AccessDecision.DEFAULT) { + return decision; + } + return permissionDecision; + } + + +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/TypedValue.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/TypedValue.java new file mode 100644 index 00000000000..40d87c8dc5a --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/TypedValue.java @@ -0,0 +1,238 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import com.evolveum.midpoint.prism.Item; +import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismReferenceDefinition; +import com.evolveum.midpoint.util.ShortDumpable; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; + +/** + * Value and definition pair. E.g. used in expression variable maps. + * We need to have explicit type here. It may happen that there will be + * variables without any value. But we need to know the type of the + * variable to compile the scripts properly. + * + * The definition, typeClass and the T parameter of this class refer to the + * type of the value as it should appear in the expression. The actual + * value may be different when TypedValue is created. The value may + * get converted as it is passing down the stack. + * + * E.g. if we want script variable to contain a user, the type should be + * declared as UserType, not as object reference - even though the value + * is object reference when the TypedValue is created. But the reference + * is resolved down the way to place user in the value. + * + * @author Radovan Semancik + */ +public class TypedValue implements ShortDumpable { + + /** + * Value may be null. This means variable without a value. + * But even in that case definition should be provided. + * The value is not T, it is Object. The value may not be in its + * final form yet. It may get converted later. + */ + private Object value; + + /** + * Definition should be filled in for all value that can be described using Prism definitions. + */ + private ItemDefinition definition; + + /** + * Type class. Should be filled in for values that are not prism values. + */ + private Class typeClass; + + public TypedValue() { + super(); + } + + public TypedValue(Item prismItem) { + super(); + this.value = (T) prismItem; + this.definition = prismItem.getDefinition(); + if (definition == null) { + throw new IllegalArgumentException("No definition when setting variable value to "+prismItem); + } + } + + public TypedValue(Object value, ItemDefinition definition) { + super(); + validateValue(value); + this.value = value; + this.definition = definition; + } + + public TypedValue(Object value, Class typeClass) { + super(); + validateValue(value); + this.value = value; + this.typeClass = typeClass; + } + + public TypedValue(Object value, ItemDefinition definition, Class typeClass) { + super(); + validateValue(value); + this.value = value; + this.definition = definition; + this.typeClass = typeClass; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + validateValue(value); + this.value = value; + } + + private void validateValue(Object value) { + if (value == null) { + return; + } + if (value instanceof TypedValue) { + throw new IllegalArgumentException("TypedValue in TypedValue in "+this); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public D getDefinition() { + return (D) definition; + } + + public void setDefinition(ItemDefinition definition) { + this.definition = definition; + } + + public Class getTypeClass() { + return typeClass; + } + + public void setTypeClass(Class typeClass) { + this.typeClass = typeClass; + } + + public boolean canDetermineType() { + return definition != null || typeClass != null; + } + + public Class determineClass() throws SchemaException { + if (definition == null) { + if (typeClass == null) { + throw new SchemaException("Cannot determine class for variable, neither definition nor class specified"); + } else { + return typeClass; + } + } else { + Class determinedClass; + if (definition instanceof PrismReferenceDefinition) { + // Stock prism reference would return ObjectReferenceType from prism schema. + // But we have exteded type for this. + // TODO: how to make this more elegant? + determinedClass = ObjectReferenceType.class; + } else { + determinedClass = definition.getTypeClass(); + } + if (determinedClass == null) { + throw new SchemaException("Cannot determine class from definition "+definition); + } + return determinedClass; + } + } + + /** + * Returns new TypedValue that has a new (transformed) value, but has the same definition. + */ + public TypedValue createTransformed(Object newValue) { + return new TypedValue(newValue, definition, typeClass); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((definition == null) ? 0 : definition.hashCode()); + result = prime * result + ((typeClass == null) ? 0 : typeClass.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TypedValue other = (TypedValue) obj; + if (definition == null) { + if (other.definition != null) { + return false; + } + } else if (!definition.equals(other.definition)) { + return false; + } + if (typeClass == null) { + if (other.typeClass != null) { + return false; + } + } else if (!typeClass.equals(other.typeClass)) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equals(other.value)) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TypedValue("); + shortDump(sb); + sb.append(")"); + return sb.toString(); + } + + @Override + public void shortDump(StringBuilder sb) { + sb.append(value); + if (definition != null) { + sb.append(", definition="); + definition.debugDumpShortToString(sb); + } + if (typeClass != null) { + sb.append(", class=").append(typeClass.getSimpleName()); + } + if (definition == null && typeClass == null) { + sb.append(", definition/class=null"); + } + } + + +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/VariablesMap.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/VariablesMap.java new file mode 100644 index 00000000000..4ce41594dbe --- /dev/null +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/expression/VariablesMap.java @@ -0,0 +1,289 @@ +/** + * Copyright (c) 2019 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.schema.expression; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.namespace.QName; + +import org.w3c.dom.Element; + +import com.evolveum.midpoint.prism.Definition; +import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrimitiveType; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.DebugDumpable; +import com.evolveum.midpoint.util.DebugUtil; +import com.evolveum.midpoint.util.PrettyPrinter; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; + +/** + * @author semancik + * + */ +public class VariablesMap implements Map, DebugDumpable { + + private Map variables; + + public VariablesMap() { + variables = new HashMap<>(); + } + + private VariablesMap(Map variablesMap) { + super(); + this.variables = variablesMap; + } + + public int size() { + return variables.size(); + } + + public boolean isEmpty() { + return variables.isEmpty(); + } + + public boolean containsKey(Object key) { + return variables.containsKey(key); + } + + public boolean containsValue(Object value) { + return variables.containsValue(value); + } + + public TypedValue get(Object key) { + return variables.get(key); + } + + public TypedValue put(String key, TypedValue typedValue) { + if (typedValue == null) { + throw new IllegalArgumentException("Attempt to set variable '"+key+"' with null typed value: "+typedValue); + } + if (!typedValue.canDetermineType()) { + throw new IllegalArgumentException("Attempt to set variable '"+key+"' without determinable type: "+typedValue); + } + return variables.put(key, typedValue); + } + + @SuppressWarnings("rawtypes") + public TypedValue put(String key, Object value, D definition) { + if (definition == null) { + throw new IllegalArgumentException("Attempt to set variable '"+key+"' without definition: " + value); + } + return variables.put(key, new TypedValue<>(value, definition)); + } + + /** + * Note: Type of the value should really be Object and not T. The value may be quite complicated, + * e.g. it may be ItemDeltaItem of the actual real value. However, the class defines the real type + * of the value precisely. + */ + public TypedValue put(String key, Object value, Class typeClass) { + if (typeClass == null) { + throw new IllegalArgumentException("Attempt to set variable '"+key+"' without class specification: " + value); + } + return variables.put(key, new TypedValue<>(value, typeClass)); + } + + /** + * Convenience method to put objects with definition. + * Maybe later improve by looking up full definition. + */ + @SuppressWarnings("unchecked") + public TypedValue putObject(String key, O objectType, Class expectedClass) { + if (objectType == null) { + return put(key, null, expectedClass); + } else { + return put(key, objectType, objectType.asPrismObject().getDefinition()); + } + } + + /** + * Convenience method to put objects with definition. + * Maybe later improve by looking up full definition. + */ + @SuppressWarnings("unchecked") + public TypedValue putObject(String key, PrismObject object, Class expectedClass) { + if (object == null) { + return put(key, null, expectedClass); + } else { + return put(key, object, object.getDefinition()); + } + } + + /** + * Convenience method to put multivalue variables (lists). + * This is very simple now. But later on we may need to declare generics. + * Therefore dedicated method would be easier to find all usages and fix them. + */ + @SuppressWarnings("unchecked") + public TypedValue> putList(String key, List list) { + return put(key, list, List.class); + } + + public TypedValue remove(Object key) { + return variables.remove(key); + } + + public void putAll(Map m) { + variables.putAll(m); + } + + public void clear() { + variables.clear(); + } + + public Set keySet() { + return variables.keySet(); + } + + public Collection values() { + return variables.values(); + } + + public Set> entrySet() { + return variables.entrySet(); + } + + + /** + * Expects name-value-definition triples. + * Definition can be just a type QName. + * + * E.g. + * create(var1name, var1value, var1type, var2name, var2value, var2type, ...) + * + * Mostly for testing. Use at your own risk. + */ + public static VariablesMap create(PrismContext prismContext, Object... parameters) { + VariablesMap vars = new VariablesMap(); + vars.fillIn(prismContext, parameters); + return vars; + } + + /** + * Expects name-value-definition triples. + * Definition can be just a type QName. + * + * E.g. + * create(var1name, var1value, var1type, var2name, var2value, var2type, ...) + * + * Mostly for testing. Use at your own risk. + */ + protected void fillIn(PrismContext prismContext, Object... parameters) { + for (int i = 0; i < parameters.length; i += 3) { + Object nameObj = parameters[i]; + String name = null; + if (nameObj instanceof String) { + name = (String)nameObj; + } else if (nameObj instanceof QName) { + name = ((QName)nameObj).getLocalPart(); + } + Object value = parameters[i+1]; + Object defObj = parameters[i+2]; + ItemDefinition def = null; + if (defObj instanceof QName) { + def = prismContext.definitionFactory().createPropertyDefinition( + new QName(SchemaConstants.NS_C, name), (QName)defObj, null, null); + put(name, value, def); + } else if (defObj instanceof PrimitiveType) { + def = prismContext.definitionFactory().createPropertyDefinition( + new QName(SchemaConstants.NS_C, name), ((PrimitiveType)defObj).getQname(), null, null); + put(name, value, def); + } else if (defObj instanceof ItemDefinition) { + def = (ItemDefinition)defObj; + put(name, value, def); + } else if (defObj instanceof Class) { + put(name, value, (Class)defObj); + } else { + throw new IllegalArgumentException("Unexpected def "+defObj); + } + + } + } + + public static VariablesMap emptyMap() { + return new VariablesMap(Collections.emptyMap()); + } + + public boolean equals(Object o) { + return variables.equals(o); + } + + public int hashCode() { + return variables.hashCode(); + } + + @Override + public String toString() { + return variables.toString(); + } + + public String formatVariables() { + StringBuilder sb = new StringBuilder(); + Iterator> i = entrySet().iterator(); + while (i.hasNext()) { + Entry entry = i.next(); + SchemaDebugUtil.indentDebugDump(sb, 1); + sb.append(entry.getKey()).append(": "); + TypedValue valueDef = entry.getValue(); + Object value = valueDef.getValue(); + // TODO: dump definitions? + if (value instanceof DebugDumpable) { + sb.append("\n"); + sb.append(((DebugDumpable)value).debugDump(2)); + } else if (value instanceof Element) { + sb.append("\n"); + sb.append(DOMUtil.serializeDOMToString(((Element)value))); + } else { + sb.append(SchemaDebugUtil.prettyPrint(value)); + } + if (i.hasNext()) { + sb.append("\n"); + } + } + return sb.toString(); + } + + public String dumpSingleLine() { + StringBuilder sb = new StringBuilder(); + for (Entry entry: variables.entrySet()) { + sb.append(entry.getKey()); + sb.append("="); + sb.append(PrettyPrinter.prettyPrint(entry.getValue().getValue())); + sb.append("; "); + } + return sb.toString(); + } + + // TODO: dump definitions? + @Override + public String debugDump(int indent) { + StringBuilder sb = new StringBuilder(); + DebugUtil.debugDumpMapMultiLine(sb, variables, 1); + return sb.toString(); + } + +} diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java index f337e0d37af..03a3878992f 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java @@ -24,6 +24,7 @@ import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.expression.ExpressionProfile; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; @@ -488,6 +489,14 @@ public static boolean canBeAssignedFrom(QName requiredTyp Class requiredTypeClass = ObjectTypes.getObjectTypeFromTypeQName(requiredTypeQName).getClassDefinition(); return requiredTypeClass.isAssignableFrom(providedTypeClass); } + + /** + * This is NOT A REAL METHOD. It just returns null. It is here to mark all the places + * where proper handling of expression profiles should be later added. + */ + public static ExpressionProfile getExpressionProfile() { + return null; + } public static void mergeDisplay(DisplayType viewDisplay, DisplayType archetypeDisplay) { if (viewDisplay.getLabel() == null) { diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java index 2174fc25381..cca49b1e7d9 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ReportTypeUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,18 +22,8 @@ import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JRTemplate; -import net.sf.jasperreports.engine.JasperCompileManager; -import net.sf.jasperreports.engine.JasperReport; -import net.sf.jasperreports.engine.design.JRDesignExpression; -import net.sf.jasperreports.engine.design.JRDesignParameter; -import net.sf.jasperreports.engine.design.JRDesignReportTemplate; -import net.sf.jasperreports.engine.design.JasperDesign; -import net.sf.jasperreports.engine.xml.JRXmlLoader; - import org.apache.commons.codec.binary.Base64; +import org.jfree.data.gantt.Task; import org.w3c.dom.Element; import com.evolveum.midpoint.prism.ItemDefinition; @@ -43,11 +33,25 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.schema.PrismSchema; +import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRTemplate; +import net.sf.jasperreports.engine.JasperCompileManager; +import net.sf.jasperreports.engine.JasperReport; +import net.sf.jasperreports.engine.design.JRDesignExpression; +import net.sf.jasperreports.engine.design.JRDesignParameter; +import net.sf.jasperreports.engine.design.JRDesignReportTemplate; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.xml.JRXmlLoader; + /** * @author lazyman */ @@ -57,10 +61,18 @@ public class ReportTypeUtil { public static final String HEADER_USERAGENT = "mp-cluster-peer-client"; public static String URLENCODING = "UTF-8"; + public static final String REPORT_LANGUAGE = "midPoint"; + + + public static final String PARAMETER_TEMPLATE_STYLES = "baseTemplateStyles"; + public static final String PARAMETER_REPORT_OID = "midpointReportOid"; + public static final String PARAMETER_REPORT_OBJECT = "midpointReportObject"; + public static final String PARAMETER_TASK = "midpointTask"; + public static final String PARAMETER_OPERATION_RESULT = "midpointOperationResult"; + + private static final Trace LOGGER = TraceManager.getTrace(ReportTypeUtil.class); + - private static String PARAMETER_TEMPLATE_STYLES = "baseTemplateStyles"; - - public static JasperDesign loadJasperDesign(byte[] template) throws SchemaException{ try { byte[] reportTemplate = Base64.decodeBase64(template); @@ -74,46 +86,6 @@ public static JasperDesign loadJasperDesign(byte[] template) throws SchemaExcept } } - - public static JasperReport loadJasperReport(ReportType reportType) throws SchemaException{ - - if (reportType.getTemplate() == null) { - throw new IllegalStateException("Could not create report. No jasper template defined."); - } - try { -// byte[] reportTemplate = Base64.decodeBase64(reportType.getTemplate()); -// -// InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate); - JasperDesign jasperDesign = loadJasperDesign(reportType.getTemplate());//JRXmlLoader.load(inputStreamJRXML); -// LOGGER.trace("load jasper design : {}", jasperDesign); - - if (reportType.getTemplateStyle() != null){ - JRDesignReportTemplate templateStyle = new JRDesignReportTemplate(new JRDesignExpression("$P{" + PARAMETER_TEMPLATE_STYLES + "}")); - jasperDesign.addTemplate(templateStyle); - JRDesignParameter parameter = new JRDesignParameter(); - parameter.setName(PARAMETER_TEMPLATE_STYLES); - parameter.setValueClass(JRTemplate.class); - parameter.setForPrompting(false); - jasperDesign.addParameter(parameter); - } - -// if (StringUtils.isNotEmpty(finalQuery)){ - JRDesignParameter parameter = new JRDesignParameter(); - parameter.setName("finalQuery"); - parameter.setValueClass(Object.class); - parameter.setForPrompting(false); - jasperDesign.addParameter(parameter); -// } - JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); - return jasperReport; - } catch (JRException ex){ -// LOGGER.error("Couldn't create jasper report design {}", ex.getMessage()); - throw new SchemaException(ex.getMessage(), ex.getCause()); - } - - -} - public static PrismSchema parseReportConfigurationSchema(PrismObject report, PrismContext context) throws SchemaException { diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 5e443c7dbe0..868522216f3 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -14304,12 +14304,13 @@ - +

- Specifies restrictions for execution of expressions and scripts. This applies - to expressions in archetyped objects. + Specifies a profile for expression execution. + The profile mostly specifies restrictions for execution of expressions + and scripts. This applies to expressions in archetyped objects. Please note that no expression execution restriction means that all evaluators and scripting langages are allowed and there are no restrictions for evaluation of expressions. @@ -14323,173 +14324,13 @@ 4.0 - ArchetypePolicyType.expressionExecutionRestriction + ArchetypePolicyType.expressionProfile - - - - Specifies restrictions for execution of expressions and scripts. - Please note that no expression execution restriction means that all evaluators - and scripting langages are allowed and there are no restrictions for evaluation - of expressions. - - - - 4.0 - - - - - - - Strategy to evaluate allowed expression evaluators. - - - ExpressionExecutionRestrictionType.expressionEvaluatorStrategy - - - - - - - List of expression evaluators that are allowed. It is only applied if evaluator strategy is - set to manual. - Empty lists means that no evaluators are allowed. - - - ExpressionExecutionRestrictionType.allowedEvaluator - - - - - - - Strategy to evaluate allowed script languages. - - - ExpressionExecutionRestrictionType.expressionEvaluatorStrategy - - - - - - - List of script languages that are allowed. It is only applied if script language strategy is - set to manual. - Empty lists means that no script languages are allowed. - - - ExpressionExecutionRestrictionType.allowedScriptLanguage - - - - - - - Strategy to evaluate allowed classes that script evaluators are allowed to access. - - - ExpressionExecutionRestrictionType.scriptClassesStrategy - - - - - - - List of script classes that are allowed. It is only applied if script classes strategy is - set to manual. - Empty lists means that no script classes are allowed. - - - ExpressionExecutionRestrictionType.allowedScriptClasses - - - - - - - - - - - - TODO - - - - 4.0 - - - - - - -

- Nothing is allowed. - E.g. no expression evaluators or scripting languages are allowed. - However, other definitions can still allow this. -

-
- - - -
- - - - -

- Only "safe" options are allowed. This is similar to "automatic" protection mode. - E.g. only those expression evaluators or scripting languages that are considered - "safe" are allowed. The definition of safe is quite vague here. Anything that has - low risk of being abused for unintended action is considered "safe". However, this - is still expression evaluation and some evaluators and scripting languages may be - Turing-complete. The behaviour also depeds on midPoint configuration and customization. - Therefore it is very hard to safeguard execution without completely sandboxing it. - Appropriate care should be applied when using this option. It may be useful for - a common case. But in some cases it may be needed to avoid this option and set up - the restrictions manually. -

-
- - - -
-
- - - -

- Manual whitelist should be apllied. - E.g. only those evaluators or scripting languages that are explicitly enumerated - are allowed. -

-
- - - -
-
- - - -

- Everything is allowed. - E.g. all expression evaluators or scripting languages are allowed. -

-
- - - -
-
- - @@ -15469,6 +15310,19 @@
+ + + + Specifies profile for expression evaluations, execution, restrictions, etc. + + + SystemConfigurationType.expressions + 4.0 + true + + + + @@ -15476,6 +15330,8 @@ + + @@ -15544,6 +15400,462 @@ + + + + Specifies profile for expression evaluations, execution, restrictions, etc. + + + + 4.0 + true + + + + + + + Free-form description (comment). + + + SystemConfigurationExpressionsType.name + + + + + + + TODO + + + SystemConfigurationExpressionsType.expressionProfile + + + + + + + TODO + + + SystemConfigurationExpressionsType.permissionProfile + + + + + + + + + + Specifies restrictions for execution of expressions and scripts. + + + + 4.0 + true + + + + + + + Profile identifier. Usually short string, essentialy a simple profile name. + Custom profiles should consider using URIs instead of simple names to avoid + conflicts with built-in profiles that may be provided in later versions. + + + ExpressionProfileType.identifier + + + + + + + Free-form description (comment). + + + ExpressionProfileType.name + + + + + + + Default decision for the profile. I.e. decision of those evaluators that are not explicitly enumerated. + + + ExpressionProfileType.decision + + + + + + + Detailed specification of expression evaluator profile. + + + ExpressionProfileType.evaluator + + + + + + + + + + Specifies restrictions for execution of specific expression evaluators. + + + + 4.0 + true + + + + + + + Evaluator type. This should correspond to the name of evaluator element. + + + ExpressionEvaluatorProfileType.type + + + + + + + Free-form description (comment). + + + ExpressionEvaluatorProfileType.name + + + + + + + Default decision for the evaluator. I.e. decision of those aspects of the evaluator use + (e.g. script languages) that are not explicitly enumerated. + + + ExpressionEvaluatorProfileType.decision + + + + + + + Detailed specification for script expressions. + + + ExpressionEvaluatorProfileType.script + + + + + + + + + + + Specifies restrictions for execution of script expressions. + + + + 4.0 + true + + + + + + + Language of the expression. + + + ScriptExpressionProfileType.language + + + + + + + Free-form description (comment). + + + ScriptExpressionProfileType.name + + + + + + + Default decision for the scripting language. I.e. decision whether the language can + be used at all. + + + ScriptExpressionProfileType.decision + + + + + + + Switch controlling whether strict type checking is enabled. + There is no global default for this. Each language may default to + a different value. Some languages may not support this switch at all. + + + ScriptExpressionProfileType.typeChecking + + + + + + + Identifier of a permission profile that should be applied to this + script language. If no profile is specified, then no profile will be + applied and all language features will be allowed. + + + ScriptExpressionProfileType.permissionProfile + + + + + + + + + + Specifies restrictions and permissions for various evaluators, especially for + scripting expressions. + The permission profile configuration is a separate container with its own identifier + as it is expected that the same setting will be applied to many evaluators and/or + scripting languages. And the definition of a profile can be quite long and extensive. + + + + 4.0 + true + + + + + + + Profile identifier. Usually short string, essentialy a simple profile name. + Custom profiles should consider using URIs instead of simple names to avoid + conflicts with built-in profiles that may be provided in later versions. + + + ExpressionPermissionProfileType.identifier + + + + + + + Free-form description (comment). + + + ExpressionPermissionProfileType.name + + + + + + + Default decision for the profile. I.e. decision of those aspects of the profile + (e.g. classes, permissions) that are not explicitly enumerated. + + + ExpressionPermissionProfileType.decision + + + + + + + Detailed specification for access to a class. + + + ExpressionPermissionProfileType.class + + + + + + + Detailed specification for access to a class. + + + ExpressionPermissionProfileType.class + + + + + + + + + + + Specifies restrictions and permissions for a package. + For now package definitions MUST NOT OVERLAP. Therefore there must not be + a definiton of a superpackage and subpackage at the same time. + + + + 4.0 + true + + + + + + + Full name of the class (including package). + + + ExpressionPermissionPackageProfileType.name + + + + + + + Free-form description (comment). + + + ExpressionPermissionPackageProfileType.name + + + + + + + Default decision for the profile. I.e. decision of those aspects of the profile + (e.g. classes, permissions) that are not explicitly enumerated. + + + ExpressionPermissionPackageProfileType.decision + + + + + + + + + + + Specifies restrictions and permissions for a specific class. + + + + 4.0 + true + + + + + + + Full name of the class (including package). + + + ExpressionPermissionClassProfileType.name + + + + + + + Free-form description (comment). + + + ExpressionPermissionClassProfileType.name + + + + + + + Default decision for the profile. I.e. decision of those aspects of the profile + (e.g. classes, permissions) that are not explicitly enumerated. + + + ExpressionPermissionClassProfileType.decision + + + + + + + Detailed specification for access to a method. + + + ExpressionPermissionClassProfileType.method + + + + + + + + + + Specifies restrictions and permissions for a specific method. + + + + 4.0 + true + + + + + + + Name of the method. + + + ExpressionPermissionClassProfileType.name + + + + + + + Free-form description (comment). + + + "ExpressionPermissionMethodProfileType".name + + + + + + + Default decision for the profile. I.e. decision of those aspects of the profile + (e.g. classes, permissions) that are not explicitly enumerated. + + + ExpressionPermissionClassProfileType.decision + + + + + + + + + diff --git a/infra/schema/src/main/resources/xml/ns/public/report/report-3.wsdl b/infra/schema/src/main/resources/xml/ns/public/report/report-3.wsdl index 86b463feb98..1a58e7ba925 100644 --- a/infra/schema/src/main/resources/xml/ns/public/report/report-3.wsdl +++ b/infra/schema/src/main/resources/xml/ns/public/report/report-3.wsdl @@ -1,6 +1,6 @@ + + + SystemConfiguration + + + + safe + deny + + asIs + allow + + + path + allow + + + value + allow + + + + script + deny + + + + + script-safe + deny + + com.evolveum.midpoint.xml.ns._public.common.common_3 + MidPoint common schema - generated bean classes + allow + + + com.evolveum.prism.xml.ns._public.types_3 + Prism schema - bean classes + allow + + + java.lang.String + String operations are generally safe. But Groovy is adding execute() method which is very dangerous. + allow + + execute + deny + + + + java.lang.CharSequence + allow + + + java.util.List + List operations are generally safe. But Groovy is adding execute() method which is very dangerous. + allow + + execute + deny + + + + java.lang.System + Just a few methods of System are safe enough. + deny + + currentTimeMillis + allow + + + + java.lang.IllegalStateException + Basic Java exception. Also used in test. + allow + + + java.lang.IllegalArgumentException + Basic Java exception. + allow + + + com.evolveum.midpoint.model.common.expression.functions.LogExpressionFunctions + MidPoint logging functions library + allow + + + + diff --git a/model/model-common/src/test/resources/expression/expression/account-jack-dummy.xml b/model/model-common/src/test/resources/expression/expression/account-jack-dummy.xml index 03d44f915a2..773455bcedc 100644 --- a/model/model-common/src/test/resources/expression/expression/account-jack-dummy.xml +++ b/model/model-common/src/test/resources/expression/expression/account-jack-dummy.xml @@ -20,7 +20,7 @@ xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" - xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004" + xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> diff --git a/model/model-common/src/test/resources/expression/expression/expression-asis.xml b/model/model-common/src/test/resources/expression/expression/expression-asis.xml new file mode 100644 index 00000000000..23283a9419c --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-asis.xml @@ -0,0 +1,28 @@ + + + + + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/expression-const.xml b/model/model-common/src/test/resources/expression/expression/expression-const.xml new file mode 100644 index 00000000000..7d4679ef04d --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-const.xml @@ -0,0 +1,28 @@ + + + + foo + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/iteration-condition.xml b/model/model-common/src/test/resources/expression/expression/expression-iteration-condition.xml similarity index 84% rename from model/model-common/src/test/resources/expression/expression/iteration-condition.xml rename to model/model-common/src/test/resources/expression/expression/expression-iteration-condition.xml index e816d4cc212..48bc5648aaa 100644 --- a/model/model-common/src/test/resources/expression/expression/iteration-condition.xml +++ b/model/model-common/src/test/resources/expression/expression/expression-iteration-condition.xml @@ -1,6 +1,6 @@ + + $focus/name + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/expression-script-groovy-simple.xml b/model/model-common/src/test/resources/expression/expression/expression-script-groovy-simple.xml new file mode 100644 index 00000000000..bfedcbb7150 --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-script-groovy-simple.xml @@ -0,0 +1,32 @@ + + + + + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/expression-script-groovy-system-allow.xml b/model/model-common/src/test/resources/expression/expression/expression-script-groovy-system-allow.xml new file mode 100644 index 00000000000..ca740e40de3 --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-script-groovy-system-allow.xml @@ -0,0 +1,36 @@ + + + + + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/expression-script-groovy-system-deny.xml b/model/model-common/src/test/resources/expression/expression/expression-script-groovy-system-deny.xml new file mode 100644 index 00000000000..b3acb3cce1a --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-script-groovy-system-deny.xml @@ -0,0 +1,34 @@ + + + + + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/expression-script-javascript.xml b/model/model-common/src/test/resources/expression/expression/expression-script-javascript.xml new file mode 100644 index 00000000000..059ecf3ce8c --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-script-javascript.xml @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/expression/expression-value.xml b/model/model-common/src/test/resources/expression/expression/expression-value.xml new file mode 100644 index 00000000000..25797e6f93f --- /dev/null +++ b/model/model-common/src/test/resources/expression/expression/expression-value.xml @@ -0,0 +1,28 @@ + + + + GARBAGE OUT + \ No newline at end of file diff --git a/model/model-common/src/test/resources/expression/groovy/expression-list-exec.xml b/model/model-common/src/test/resources/expression/groovy/expression-list-exec.xml new file mode 100644 index 00000000000..11b5a617aa4 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-list-exec.xml @@ -0,0 +1,25 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-drink.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-drink.xml new file mode 100644 index 00000000000..5aa41ae1894 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-drink.xml @@ -0,0 +1,24 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-look.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-look.xml new file mode 100644 index 00000000000..0e2e0bac853 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-look.xml @@ -0,0 +1,24 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-dynamic.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-dynamic.xml new file mode 100644 index 00000000000..61bc8a61513 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-dynamic.xml @@ -0,0 +1,24 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-reflection.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-reflection.xml new file mode 100644 index 00000000000..94815a1d312 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-reflection.xml @@ -0,0 +1,26 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-tricky.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-tricky.xml new file mode 100644 index 00000000000..10b2924222a --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-tricky.xml @@ -0,0 +1,26 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-very-dynamic.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-very-dynamic.xml new file mode 100644 index 00000000000..0f66639f3d0 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell-very-dynamic.xml @@ -0,0 +1,25 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell.xml b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell.xml new file mode 100644 index 00000000000..7b1b5e5bec7 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-poinson-smell.xml @@ -0,0 +1,24 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-string-exec.xml b/model/model-common/src/test/resources/expression/groovy/expression-string-exec.xml new file mode 100644 index 00000000000..d4176ac8891 --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-string-exec.xml @@ -0,0 +1,25 @@ + + + + diff --git a/model/model-common/src/test/resources/expression/groovy/expression-syntax-error.xml b/model/model-common/src/test/resources/expression/groovy/expression-syntax-error.xml new file mode 100644 index 00000000000..eb0765cbccd --- /dev/null +++ b/model/model-common/src/test/resources/expression/groovy/expression-syntax-error.xml @@ -0,0 +1,23 @@ + + + + diff --git a/model/model-common/src/test/resources/logback-test.xml b/model/model-common/src/test/resources/logback-test.xml index c9d3466d570..8a4313aee43 100644 --- a/model/model-common/src/test/resources/logback-test.xml +++ b/model/model-common/src/test/resources/logback-test.xml @@ -25,7 +25,8 @@ - + + diff --git a/model/model-common/src/test/resources/mapping/account-inbound-mapping.xml b/model/model-common/src/test/resources/mapping/account-inbound-mapping.xml index 01fd766bc40..5076b48d48a 100644 --- a/model/model-common/src/test/resources/mapping/account-inbound-mapping.xml +++ b/model/model-common/src/test/resources/mapping/account-inbound-mapping.xml @@ -1,6 +1,6 @@ diff --git a/model/model-common/testng-unit.xml b/model/model-common/testng-unit.xml index b3eb36e6bb8..403372df714 100644 --- a/model/model-common/testng-unit.xml +++ b/model/model-common/testng-unit.xml @@ -1,6 +1,6 @@ + UserType account @@ -73,7 +79,7 @@ diff --git a/model/model-intest/src/test/resources/iterative-tasks/task-buckets-multithreaded.xml b/model/model-intest/src/test/resources/iterative-tasks/task-buckets-multithreaded.xml new file mode 100644 index 00000000000..a9606e2f797 --- /dev/null +++ b/model/model-intest/src/test/resources/iterative-tasks/task-buckets-multithreaded.xml @@ -0,0 +1,68 @@ + + + + Buckets, multiple threads + + 4 + UserType + + + + subtype + test + + + + + + execute-script + + script + + + log.info('Found user {}', input) + com.evolveum.midpoint.model.intest.TestIterativeTasks.checkLightweightSubtasks(task) + + + + + + + 4ccd0cde-c506-49eb-9718-f85ba3438515 + + runnable + BulkActions + http://midpoint.evolveum.com/xml/ns/public/model/iterative-scripting/handler-3 + + standalone + + + name + 0 + 0-9 + + + + single + loose + diff --git a/model/model-intest/src/test/resources/schema/piracy.xsd b/model/model-intest/src/test/resources/schema/piracy.xsd index bf67bad924c..c2d7dad61bb 100644 --- a/model/model-intest/src/test/resources/schema/piracy.xsd +++ b/model/model-intest/src/test/resources/schema/piracy.xsd @@ -209,5 +209,18 @@ + + + + + + + + + + + + + diff --git a/model/model-intest/src/test/resources/sync/resource-dummy-steelgrey.xml b/model/model-intest/src/test/resources/sync/resource-dummy-steelgrey.xml new file mode 100644 index 00000000000..42bc7653705 --- /dev/null +++ b/model/model-intest/src/test/resources/sync/resource-dummy-steelgrey.xml @@ -0,0 +1,190 @@ + + + + + + + + Dummy Resource SteelGrey + + + + + connectorType + com.evolveum.icf.dummy.connector.DummyConnector + + + connectorVersion + 2.0 + + + + + + + + steelgrey + + + false + + + + + + + + account + default + Default Account + true + ri:AccountObjectClass + + icfs:name + + + name + + + + + icfs:uid + UID + + + ri:group + entitlement + group + objectToSubject + ri:members + icfs:name + + + + + entitlement + group + true + ri:GroupObjectClass + + icfs:name + + + name + + + + + ri:members + minimal + + + + + + + + true + ri:AccountObjectClass + account + default + + + c:name + + + + + + + linked + true + + + deleted + true + + http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlink + + + + unlinked + true + + http://midpoint.evolveum.com/xml/ns/public/model/action-3#link + + + + unmatched + + + + true + ri:GroupObjectClass + entitlement + group + RoleType + + + c:name + + + + + + + linked + true + + + deleted + true + + http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlink + + + + unlinked + true + + http://midpoint.evolveum.com/xml/ns/public/model/action-3#link + + + + unmatched + + + + diff --git a/model/model-intest/src/test/resources/sync/role-steelgrey.xml b/model/model-intest/src/test/resources/sync/role-steelgrey.xml new file mode 100644 index 00000000000..c13fdfe680b --- /dev/null +++ b/model/model-intest/src/test/resources/sync/role-steelgrey.xml @@ -0,0 +1,27 @@ + + + SteelGrey + + + + account + default + + + diff --git a/model/model-intest/src/test/resources/sync/user-template-steelgrey.xml b/model/model-intest/src/test/resources/sync/user-template-steelgrey.xml new file mode 100644 index 00000000000..2139e235348 --- /dev/null +++ b/model/model-intest/src/test/resources/sync/user-template-steelgrey.xml @@ -0,0 +1,40 @@ + + + + + + User template for SteelGrey + + + SteelGrey Role assignment + + + c:RoleType + 3ada6d1a-13a3-495b-943f-5b541a764bf1 + + + + assignment + + + + diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index e90f07b5ffc..b2c0bc26016 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -107,7 +107,6 @@ import com.evolveum.midpoint.model.api.context.ModelProjectionContext; import com.evolveum.midpoint.model.api.expr.MidpointFunctions; import com.evolveum.midpoint.model.api.hooks.HookRegistry; -import com.evolveum.midpoint.model.api.util.ModelUtils; import com.evolveum.midpoint.model.common.SystemObjectCache; import com.evolveum.midpoint.model.common.stringpolicy.UserValuePolicyOriginResolver; import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor; @@ -130,6 +129,7 @@ import com.evolveum.midpoint.provisioning.api.ProvisioningService; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.repo.common.ObjectResolver; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalsConfig; @@ -6325,5 +6325,9 @@ protected AssignmentCandidatesSpecificationAsserter asserter.display(); return asserter; } + + protected ExpressionVariables createVariables(Object... params) { + return ExpressionVariables.create(prismContext, params); + } } diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/BaseEvent.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/BaseEvent.java index 9b00fbac5e5..43ac74665ce 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/BaseEvent.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/BaseEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.*; -import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; +import com.evolveum.midpoint.schema.expression.TypedValue; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifier; import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; @@ -34,10 +36,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.xml.namespace.QName; import java.util.Collection; import java.util.List; -import java.util.Map; /** * @author mederly @@ -54,6 +54,7 @@ public abstract class BaseEvent implements Event, DebugDumpable, ShortDumpable { protected final EventHandlerType adHocHandler; private transient NotificationFunctions notificationFunctions; // needs not be set when creating an event ... it is set in NotificationManager + private transient PrismContext prismContext; // about who is this operation (null if unknown); // - for model notifications, this is the focus, (usually a user but may be e.g. role or other kind of object) @@ -240,13 +241,23 @@ boolean changeTypeMatchesOperationType(ChangeType changeType, EventOperationType } } - public void createExpressionVariables(Map variables, OperationResult result) { - variables.put(SchemaConstants.C_EVENT, this); - variables.put(SchemaConstants.C_REQUESTER, requester != null ? requester.resolveObjectType(result, false) : null); - variables.put(SchemaConstants.C_REQUESTEE, requestee != null ? requestee.resolveObjectType(result, true) : null); + public void createExpressionVariables(VariablesMap variables, OperationResult result) { + variables.put(ExpressionConstants.VAR_EVENT, this, Event.class); + variables.put(ExpressionConstants.VAR_REQUESTER, resolveTypedObject(requester, false, result)); + variables.put(ExpressionConstants.VAR_REQUESTEE, resolveTypedObject(requestee, true, result)); } - // Finding items in deltas/objects + protected TypedValue resolveTypedObject(SimpleObjectRef ref, boolean allowNotFound, OperationResult result) { + if (ref == null) { + PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ObjectType.class); + return new TypedValue<>(null, def); + } else { + ObjectType resolveObjectType = ref.resolveObjectType(result, allowNotFound); + return new TypedValue<>(resolveObjectType, resolveObjectType.asPrismObject().getDefinition()); + } + } + + // Finding items in deltas/objects // this is similar to delta.hasItemDelta but much, much more relaxed (we completely ignore ID path segments and we take subpaths into account) // // Very experimental implementation. Needs a bit of time to clean up and test adequately. @@ -374,6 +385,14 @@ public void setNotificationFunctions(NotificationFunctions notificationFunctions this.notificationFunctions = notificationFunctions; } + public PrismContext getPrismContext() { + return prismContext; + } + + public void setPrismContext(PrismContext prismContext) { + this.prismContext = prismContext; + } + public String getStatusAsText() { if (isSuccess()) { return "SUCCESS"; diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/CaseWorkItemEvent.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/CaseWorkItemEvent.java index f299e9647a5..c9e00c8dfa3 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/CaseWorkItemEvent.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/CaseWorkItemEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ import com.evolveum.midpoint.prism.delta.ChangeType; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; import com.evolveum.midpoint.util.DebugUtil; @@ -64,10 +66,10 @@ public SimpleObjectRef getAssignee() { } @Override - public void createExpressionVariables(Map variables, OperationResult result) { + public void createExpressionVariables(VariablesMap variables, OperationResult result) { super.createExpressionVariables(variables, result); - variables.put(SchemaConstants.C_ASSIGNEE, assignee.resolveObjectType(result, false)); - variables.put(SchemaConstants.C_WORK_ITEM, workItem); + variables.put(ExpressionConstants.VAR_ASSIGNEE, resolveTypedObject(assignee, false, result)); + variables.put(ExpressionConstants.VAR_WORK_ITEM, workItem, CaseWorkItemType.class); } @Override diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/Event.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/Event.java index 0a5c502577f..2c60f513f4c 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/Event.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/Event.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,16 +17,13 @@ package com.evolveum.midpoint.notifications.api.events; import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifier; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.ShortDumpable; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import javax.xml.namespace.QName; - -import java.util.Map; - /** * @author mederly */ @@ -82,7 +79,7 @@ public interface Event extends DebugDumpable, ShortDumpable { void setRequestee(SimpleObjectRef requestee); - void createExpressionVariables(Map variables, OperationResult result); + void createExpressionVariables(VariablesMap variables, OperationResult result); /** * Checks if the event is related to an item with a given path. diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemAllocationEvent.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemAllocationEvent.java index 11a8fccfcfc..3eb5d057ee1 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemAllocationEvent.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemAllocationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.evolveum.midpoint.notifications.api.events; import com.evolveum.midpoint.prism.delta.ChangeType; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; import com.evolveum.midpoint.wf.api.WorkItemOperationInfo; @@ -26,8 +27,6 @@ import org.jetbrains.annotations.Nullable; import javax.xml.datatype.Duration; -import javax.xml.namespace.QName; -import java.util.Map; /** * @author mederly @@ -52,7 +51,7 @@ public boolean isCategoryType(EventCategoryType eventCategoryType) { } @Override - public void createExpressionVariables(Map variables, OperationResult result) { + public void createExpressionVariables(VariablesMap variables, OperationResult result) { super.createExpressionVariables(variables, result); } diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemCustomEvent.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemCustomEvent.java index 10114624762..c1f0219b3e2 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemCustomEvent.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemCustomEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.evolveum.midpoint.notifications.api.events; import com.evolveum.midpoint.prism.delta.ChangeType; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; import com.evolveum.midpoint.wf.api.WorkItemOperationSourceInfo; @@ -24,9 +25,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.xml.namespace.QName; -import java.util.Map; - /** * @author mederly */ @@ -50,7 +48,7 @@ public boolean isCategoryType(EventCategoryType eventCategoryType) { } @Override - public void createExpressionVariables(Map variables, OperationResult result) { + public void createExpressionVariables(VariablesMap variables, OperationResult result) { super.createExpressionVariables(variables, result); } diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemEvent.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemEvent.java index 9a78ce6b4c7..492af28fe1c 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemEvent.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,8 @@ package com.evolveum.midpoint.notifications.api.events; import com.evolveum.midpoint.prism.delta.ChangeType; -import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; import com.evolveum.midpoint.util.DebugUtil; @@ -29,9 +30,6 @@ import org.jetbrains.annotations.Nullable; import javax.xml.datatype.Duration; -import javax.xml.namespace.QName; - -import java.util.Map; /** * @author mederly @@ -115,10 +113,10 @@ public WorkItemOperationSourceInfo getSourceInfo() { } @Override - public void createExpressionVariables(Map variables, OperationResult result) { + public void createExpressionVariables(VariablesMap variables, OperationResult result) { super.createExpressionVariables(variables, result); - variables.put(SchemaConstants.C_ASSIGNEE, assignee != null ? assignee.resolveObjectType(result, false) : null); - variables.put(SchemaConstants.C_WORK_ITEM, workItem); + variables.put(ExpressionConstants.VAR_ASSIGNEE, resolveTypedObject(assignee, false, result)); + variables.put(ExpressionConstants.VAR_WORK_ITEM, workItem, WorkItemType.class); } public AbstractWorkItemOutputType getOutput() { diff --git a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemLifecycleEvent.java b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemLifecycleEvent.java index 806006812b5..d7e6e819c7c 100644 --- a/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemLifecycleEvent.java +++ b/model/notifications-api/src/main/java/com/evolveum/midpoint/notifications/api/events/WorkItemLifecycleEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.evolveum.midpoint.notifications.api.events; import com.evolveum.midpoint.prism.delta.ChangeType; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.LightweightIdentifierGenerator; import com.evolveum.midpoint.wf.api.WorkItemOperationInfo; @@ -25,9 +26,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.xml.namespace.QName; -import java.util.Map; - /** * @author mederly */ @@ -50,7 +48,7 @@ public boolean isCategoryType(EventCategoryType eventCategoryType) { } @Override - public void createExpressionVariables(Map variables, OperationResult result) { + public void createExpressionVariables(VariablesMap variables, OperationResult result) { super.createExpressionVariables(variables, result); } diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/NotificationManagerImpl.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/NotificationManagerImpl.java index 2eee894fe28..012c51e06a3 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/NotificationManagerImpl.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/NotificationManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.evolveum.midpoint.notifications.api.events.BaseEvent; import com.evolveum.midpoint.notifications.api.events.Event; import com.evolveum.midpoint.notifications.api.transports.Transport; +import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -55,11 +56,9 @@ public class NotificationManagerImpl implements NotificationManager { @Qualifier("cacheRepositoryService") private transient RepositoryService cacheRepositoryService; - @Autowired - private NotificationFunctions notificationFunctions; - - @Autowired - private TaskManager taskManager; + @Autowired private PrismContext prismContext; + @Autowired private NotificationFunctions notificationFunctions; + @Autowired private TaskManager taskManager; private boolean disabled = false; // for testing purposes (in order for model-intest to run more quickly) @@ -110,6 +109,7 @@ public void processEvent(@Nullable Event event, Task task, OperationResult resul if (event instanceof BaseEvent) { ((BaseEvent) event).setNotificationFunctions(notificationFunctions); + ((BaseEvent) event).setPrismContext(prismContext); } LOGGER.trace("NotificationManager processing event:\n{}", event.debugDumpLazily(1)); diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/CustomTransport.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/CustomTransport.java index 8645ab73c76..b3639530382 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/CustomTransport.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/CustomTransport.java @@ -30,8 +30,10 @@ import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -159,15 +161,15 @@ private void evaluateExpression(ExpressionType expressionType, ExpressionVariabl QName resultName = new QName(SchemaConstants.NS_C, "result"); PrismPropertyDefinition resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_STRING); - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result); } protected ExpressionVariables getDefaultVariables(Message message, Event event) throws UnsupportedEncodingException { ExpressionVariables variables = new ExpressionVariables(); - variables.addVariableDefinition(SchemaConstants.C_MESSAGE, message); - variables.addVariableDefinition(SchemaConstants.C_EVENT, event); + variables.put(ExpressionConstants.VAR_MESSAGE, message, Message.class); + variables.put(ExpressionConstants.VAR_EVENT, event, Event.class); return variables; } diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/MailTransport.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/MailTransport.java index 28d79275e04..0468bdd38df 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/MailTransport.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/MailTransport.java @@ -16,7 +16,8 @@ package com.evolveum.midpoint.notifications.impl.api.transports; -import java.io.File; +import static com.evolveum.midpoint.notifications.impl.api.transports.TransportUtil.formatToFileOld; + import java.nio.file.Files; import java.nio.file.Paths; import java.util.Date; @@ -25,10 +26,6 @@ import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; -import javax.activation.FileTypeMap; -import javax.activation.MimeType; -import javax.activation.MimeTypeParseException; -import javax.activation.MimetypesFileTypeMap; import javax.annotation.PostConstruct; import javax.mail.BodyPart; import javax.mail.MessagingException; @@ -38,18 +35,14 @@ import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; -import javax.mail.internet.MimeUtility; -import com.evolveum.midpoint.notifications.api.events.Event; import org.apache.commons.lang.StringUtils; -import org.bouncycastle.asn1.dvcs.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import org.springframework.util.MimeTypeUtils; -import com.evolveum.midpoint.model.api.util.ModelUtils; import com.evolveum.midpoint.notifications.api.NotificationManager; +import com.evolveum.midpoint.notifications.api.events.Event; import com.evolveum.midpoint.notifications.api.transports.Message; import com.evolveum.midpoint.notifications.api.transports.Transport; import com.evolveum.midpoint.notifications.impl.NotificationFunctionsImpl; @@ -72,8 +65,6 @@ import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import static com.evolveum.midpoint.notifications.impl.api.transports.TransportUtil.formatToFileOld; - /** * @author mederly */ diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java index d4feb13f7a8..b0e30845530 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/api/transports/SimpleSmsTransport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,10 @@ import com.evolveum.midpoint.notifications.impl.NotificationFunctionsImpl; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -320,7 +322,7 @@ private List evaluateExpression(ExpressionType expressionType, Expressio } Expression,PrismPropertyDefinition> expression = - expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); + expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResult = ModelExpressionThreadLocalHolder .evaluateExpressionInContext(expression, params, task, result); @@ -339,19 +341,19 @@ private List evaluateExpression(ExpressionType expressionType, Expressio protected ExpressionVariables getDefaultVariables(String from, List to, Message message) throws UnsupportedEncodingException { ExpressionVariables variables = new ExpressionVariables(); - variables.addVariableDefinition(SchemaConstants.C_FROM, from); - variables.addVariableDefinition(SchemaConstants.C_ENCODED_FROM, URLEncoder.encode(from, "US-ASCII")); - variables.addVariableDefinition(SchemaConstants.C_TO, to.get(0)); - variables.addVariableDefinition(SchemaConstants.C_TO_LIST, to); + variables.put(ExpressionConstants.VAR_FROM, from, String.class); + variables.put(ExpressionConstants.VAR_ENCODED_FROM, URLEncoder.encode(from, "US-ASCII"), String.class); + variables.put(ExpressionConstants.VAR_TO, to.get(0), String.class); + variables.put(ExpressionConstants.VAR_TO_LIST, to, List.class); List encodedTo = new ArrayList<>(); for (String s : to) { encodedTo.add(URLEncoder.encode(s, "US-ASCII")); } - variables.addVariableDefinition(SchemaConstants.C_ENCODED_TO, encodedTo.get(0)); - variables.addVariableDefinition(SchemaConstants.C_ENCODED_TO_LIST, encodedTo); - variables.addVariableDefinition(SchemaConstants.C_MESSAGE_TEXT, message.getBody()); - variables.addVariableDefinition(SchemaConstants.C_ENCODED_MESSAGE_TEXT, URLEncoder.encode(message.getBody(), "US-ASCII")); - variables.addVariableDefinition(SchemaConstants.C_MESSAGE, message); + variables.put(ExpressionConstants.VAR_ENCODED_TO, encodedTo.get(0), String.class); + variables.put(ExpressionConstants.VAR_ENCODED_TO_LIST, encodedTo, List.class); + variables.put(ExpressionConstants.VAR_MESSAGE_TEXT, message.getBody(), String.class); + variables.put(ExpressionConstants.VAR_ENCODED_MESSAGE_TEXT, URLEncoder.encode(message.getBody(), "US-ASCII"), String.class); + variables.put(ExpressionConstants.VAR_MESSAGE, message, Message.class); return variables; } diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/NotificationExpressionHelper.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/NotificationExpressionHelper.java index 85a7549d484..44173fedfae 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/NotificationExpressionHelper.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/helpers/NotificationExpressionHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import com.evolveum.midpoint.model.common.SystemObjectCache; import com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder; +import com.evolveum.midpoint.notifications.api.NotificationFunctions; import com.evolveum.midpoint.notifications.api.events.Event; import com.evolveum.midpoint.notifications.impl.NotificationFunctionsImpl; import com.evolveum.midpoint.notifications.impl.formatters.TextFormatter; @@ -29,7 +30,9 @@ import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.expression.VariablesMap; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.*; @@ -81,7 +84,7 @@ public boolean evaluateBooleanExpression(ExpressionType expressionType, Expressi QName resultName = new QName(SchemaConstants.NS_C, "result"); PrismPropertyDefinition resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_BOOLEAN); - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResultTriple = ModelExpressionThreadLocalHolder @@ -119,7 +122,7 @@ private List evaluateExpression(ExpressionType expressionType, Expressio MutablePrismPropertyDefinition resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_STRING); resultDef.setMaxOccurs(-1); - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResult = ModelExpressionThreadLocalHolder .evaluateExpressionInContext(expression, params, task, result); @@ -151,7 +154,7 @@ public List evaluateNotificationMessageAttach QName resultName = new QName(SchemaConstants.NS_C, "result"); PrismPropertyDefinition resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, NotificationMessageAttachmentType.COMPLEX_TYPE); - Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); + Expression,PrismPropertyDefinition> expression = expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResultTriple = ModelExpressionThreadLocalHolder @@ -171,11 +174,12 @@ public List evaluateNotificationMessageAttach public ExpressionVariables getDefaultVariables(Event event, OperationResult result) { ExpressionVariables expressionVariables = new ExpressionVariables(); - Map variables = new HashMap<>(); + VariablesMap variables = new VariablesMap(); event.createExpressionVariables(variables, result); - variables.put(SchemaConstants.C_TEXT_FORMATTER, textFormatter); - variables.put(SchemaConstants.C_NOTIFICATION_FUNCTIONS, notificationsUtil); - variables.put(ExpressionConstants.VAR_CONFIGURATION, getSystemConfiguration(result)); + variables.put(ExpressionConstants.VAR_TEXT_FORMATTER, textFormatter, TextFormatter.class); + variables.put(ExpressionConstants.VAR_NOTIFICATION_FUNCTIONS, notificationsUtil, NotificationFunctions.class); + PrismObject systemConfiguration = getSystemConfiguration(result); + variables.put(ExpressionConstants.VAR_CONFIGURATION, systemConfiguration, systemConfiguration.getDefinition()); expressionVariables.addVariableDefinitions(variables); return expressionVariables; } diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/CustomNotifier.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/CustomNotifier.java index 68fe25de639..6cf1f6164d7 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/CustomNotifier.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/CustomNotifier.java @@ -34,8 +34,10 @@ import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -115,7 +117,7 @@ public boolean processEvent(Event event, EventHandlerType eventHandlerType, Noti try { for (String transportName : config.getTransport()) { - variables.addVariableDefinition(SchemaConstants.C_TRANSPORT_NAME, transportName); + variables.put(ExpressionConstants.VAR_TRANSPORT_NAME, transportName, String.class); Transport transport = notificationManager.getTransport(transportName); Message message = getMessageFromExpression(config, variables, task, result); @@ -171,7 +173,7 @@ private List evaluateExpression(ExpressionType expressi prismContext.definitionFactory().createPropertyDefinition(resultName, NotificationMessageType.COMPLEX_TYPE); Expression,PrismPropertyDefinition> expression = - expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); + expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple> exprResult = ModelExpressionThreadLocalHolder .evaluateExpressionInContext(expression, params, task, result); diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java index 917f56127a8..e631d55dcbc 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/notifiers/GeneralNotifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -112,7 +113,7 @@ public boolean processEvent(Event event, EventHandlerType eventHandlerType, Noti try { for (String transportName : generalNotifierType.getTransport()) { - variables.replaceVariableDefinition(SchemaConstants.C_TRANSPORT_NAME, transportName); + variables.put(ExpressionConstants.VAR_TRANSPORT_NAME, transportName, String.class); Transport transport = notificationManager.getTransport(transportName); List recipientsAddresses = getRecipientsAddresses(event, generalNotifierType, variables, diff --git a/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportManager.java b/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportManager.java index 4b27eb35665..cdde8dcbc8a 100644 --- a/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportManager.java +++ b/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportManager.java @@ -35,10 +35,6 @@ import java.io.InputStream; /** - * todo comments [lazyman] - * - * WORK IN PROGRESS - * * @author lazyman * @author katkav */ diff --git a/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportService.java b/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportService.java index 7db3b4fc761..9976029c6d2 100644 --- a/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportService.java +++ b/model/report-api/src/main/java/com/evolveum/midpoint/report/api/ReportService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 Evolveum + * Copyright (c) 2010-2019 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,6 @@ package com.evolveum.midpoint.report.api; import java.util.Collection; -import java.util.Map; - -import javax.xml.namespace.QName; import com.evolveum.midpoint.audit.api.AuditEventRecord; import com.evolveum.midpoint.prism.Containerable; @@ -28,6 +25,9 @@ import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.expression.VariablesMap; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -35,20 +35,29 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; public interface ReportService { String PARAMETER_REPORT_SERVICE = "reportService"; - ObjectQuery parseQuery(String query, Map parameters) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException; + PrismObject getReportDefinition(String reportOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException; + + ObjectQuery parseQuery(PrismObject report, String query, VariablesMap parameters, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException; - Collection> searchObjects(ObjectQuery query, - Collection> options) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException; + Collection> searchObjects(ObjectQuery query, Collection> options, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException; - Collection> evaluateScript(String script, Map parameters) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException; - Object evaluate(String script, Map parameters) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException; + Collection> evaluateScript(PrismObject report, String script, VariablesMap parameters, Task task, OperationResult result) + throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException; + + Object evaluate(PrismObject report, String script, VariablesMap parameters, Task task, OperationResult result) + throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException; - Collection evaluateAuditScript(String script, Map parameters) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException; + Collection evaluateAuditScript(PrismObject report, String script, VariablesMap parameters, Task task, OperationResult result) + throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException; // hack todo fixme PrismContext getPrismContext(); diff --git a/model/report-impl/pom.xml b/model/report-impl/pom.xml index 808d1fdfc26..ab9557e3025 100644 --- a/model/report-impl/pom.xml +++ b/model/report-impl/pom.xml @@ -1,6 +1,6 @@ + + + + + SystemConfiguration + + File Appender + INFO + + TRACE + com.evolveum.midpoint.common.LoggingConfigurationManager + + + TRACE + com.evolveum.midpoint.notifications + + + %date [%thread] %-5level \(%logger{46}\): %message%n + target/test.log + true + + + + + ReportType + safe + + + + + safe + deny + + asIs + allow + + + path + allow + + + value + allow + + + + script + deny + + + + + script-safe + deny + + com.evolveum.midpoint.xml.ns._public.common.common_3 + MidPoint common schema - generated bean classes + allow + + + com.evolveum.prism.xml.ns._public.types_3 + Prism schema - bean classes + allow + + + java.lang.Integer + allow + + + java.lang.String + String operations are generally safe. But Groovy is adding execute() method which is very dangerous. + allow + + execute + deny + + + + java.lang.CharSequence + allow + + + java.util.List + List operations are generally safe. But Groovy is adding execute() method which is very dangerous. + allow + + execute + deny + + + + java.util.Map + allow + + + java.util.HashMap + allow + + + java.util.Date + allow + + + java.lang.System + Just a few methods of System are safe enough. + deny + + currentTimeMillis + allow + + + + java.lang.IllegalStateException + Basic Java exception. Also used in test. + allow + + + java.lang.IllegalArgumentException + Basic Java exception. + allow + + + com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions + MidPoint basic functions library + allow + + + com.evolveum.midpoint.model.common.expression.functions.LogExpressionFunctions + MidPoint logging functions library + allow + + + com.evolveum.midpoint.report.impl.ReportFunctions + MidPoint report functions library + allow + + + + + diff --git a/model/report-impl/src/test/resources/common/system-configuration.xml b/model/report-impl/src/test/resources/common/system-configuration.xml index 9b7f1dba4e4..4bf97b8d569 100644 --- a/model/report-impl/src/test/resources/common/system-configuration.xml +++ b/model/report-impl/src/test/resources/common/system-configuration.xml @@ -1,6 +1,6 @@ + + + + + F0001 + The office of the most respectful Governor. + Governor Office + 0001 + functional + CC0 + The Governor's Mansion + + + + F0002 + Defending the scum since the ancient times. + + + + true + Ministry of Defense + 0002 + functional + The towers, bastions and bars + + + + F0003 + Offending. Anyone. Anywhere. + + + + true + Ministry of Offense + 0003 + functional + CC666 + + + + F0004 + Why is the rum always gone? + + + + true + Ministry of Rum + 0004 + functional + CCRUM + + + + F0005 + Swashing, buckling and insulting. Hard. + + + + true + Swashbuckler Section + 0005 + functional + + + + F0006 + Hosting the worst scumm of the Caribbean. + + + + + + + true + Scumm Bar + 0006 + functional + Mêlée Island + + + + + guybrush + + + + Guybrush Threepwood + Guybrush + Threepwood + Melee Island + + + + xM4rksTh3Sp0t + + + + + + + elaine + + + + Elaine Marley + Elaine + Marley + Melee Island + + + + P1ranhaD0GZ + + + + + + + herman + + + + + 1700-05-30T11:00:00Z + 2233-03-23T18:30:00Z + + Herman Toothrot + Herman + Toothrot + Monkey Island + + + + m0nk3y + + + + + + + largo + + + + Largo LaGrande + Largo + LaGrande + + 1777-05-30T14:15:00Z + 2222-02-22T08:30:42Z + + + + + dead123 + + + + + + + rapp + + + + Rapp Scallion + Rapp + Scallion + D3ADB33F + + + + capsize + + + + + disabled + + Kate Capsize + Kate + Capsize + Captain + + + + noTrespaSSing + + + + + + diff --git a/model/report-impl/src/test/resources/logback-test.xml b/model/report-impl/src/test/resources/logback-test.xml index 90996845962..51da356823a 100644 --- a/model/report-impl/src/test/resources/logback-test.xml +++ b/model/report-impl/src/test/resources/logback-test.xml @@ -26,6 +26,8 @@ + + diff --git a/model/report-impl/src/test/resources/reports/report-user-list-expressions-csv.xml b/model/report-impl/src/test/resources/reports/report-user-list-expressions-csv.xml new file mode 100644 index 00000000000..208d8c11cd4 --- /dev/null +++ b/model/report-impl/src/test/resources/reports/report-user-list-expressions-csv.xml @@ -0,0 +1,34 @@ + + + Users in MidPoint - report with expressions + Users listed in MidPoint. + + + + true + + UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQWdJQ0FnQ1R4emRIbHNaU0JtYjI1MFRtRnRaVDBpUkdWcVlWWjFJRk5oYm5NaUlHWnZiblJUYVhwbFBTSXhNQ0lnYUVGc2FXZHVQU0pNWldaMElpQnBjMFJsWm1GMWJIUTlJblJ5ZFdVaUlHbHpVR1JtUlcxaVpXUmtaV1E5SW5SeWRXVWlJQTBLQ1FrSkNTQWdJRzVoYldVOUlrSmhjMlVpSUhCa1prVnVZMjlrYVc1blBTSkpaR1Z1ZEdsMGVTMUlJaUJ3WkdaR2IyNTBUbUZ0WlQwaVJHVnFZVloxVTJGdWN5NTBkR1lpSUhaQmJHbG5iajBpVFdsa1pHeGxJajROQ2drSkNUd3ZjM1I1YkdVK0RRb0pDUWs4YzNSNWJHVWdZbUZqYTJOdmJHOXlQU0lqTWpZM09UazBJaUJtYjI1MFUybDZaVDBpTWpZaUlHWnZjbVZqYjJ4dmNqMGlJMFpHUmtaR1JpSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0J0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWxScGRHeGxJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBpQU5DZ2tKQ1R4emRIbHNaU0JtYjI1MFUybDZaVDBpTVRJaUlHWnZjbVZqYjJ4dmNqMGlJekF3TURBd01DSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSWdibUZ0WlQwaVVHRm5aU0JvWldGa1pYSWlEUW9nSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnYzNSNWJHVTlJa0poYzJVaUx6NE5DZ2tKQ1R4emRIbHNaU0JpWVdOclkyOXNiM0k5SWlNek16TXpNek1pSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqUmtaR1JrWkdJaUJvUVd4cFoyNDlJa05sYm5SbGNpSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0JwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWtOdmJIVnRiaUJvWldGa1pYSWlJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdhWE5DYjJ4a1BTSm1ZV3h6WlNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpUkdWMFlXbHNJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBnMEtJQ0FnSUNBZ0lDQWdJQ0FnUEhOMGVXeGxJR2x6UW05c1pEMGlabUZzYzJVaUlHbHpSR1ZtWVhWc2REMGlabUZzYzJVaUlHNWhiV1U5SWtOdlpHVWlJSE4wZVd4bFBTSkNZWE5sSWlCbWIyNTBVMmw2WlQwaU9TSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJNUlpQm1iM0psWTI5c2IzSTlJaU13TURBd01EQWlJR2x6UkdWbVlYVnNkRDBpWm1Gc2MyVWlJRzVoYldVOUlsQmhaMlVnWm05dmRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUhOMGVXeGxQU0pDWVhObElpOCtEUW9KQ1R3dmFtRnpjR1Z5VkdWdGNHeGhkR1Ur + csv + JRSwapFileVirtualizer + 300 + 10000 + 300000 + diff --git a/model/report-impl/src/test/resources/reports/report-user-list-expressions-poisonous-field-csv.xml b/model/report-impl/src/test/resources/reports/report-user-list-expressions-poisonous-field-csv.xml new file mode 100644 index 00000000000..07704c11892 --- /dev/null +++ b/model/report-impl/src/test/resources/reports/report-user-list-expressions-poisonous-field-csv.xml @@ -0,0 +1,34 @@ + + + Users in MidPoint - report with poisonous field expressions + Users listed in MidPoint. + + + + true + + UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQWdJQ0FnQ1R4emRIbHNaU0JtYjI1MFRtRnRaVDBpUkdWcVlWWjFJRk5oYm5NaUlHWnZiblJUYVhwbFBTSXhNQ0lnYUVGc2FXZHVQU0pNWldaMElpQnBjMFJsWm1GMWJIUTlJblJ5ZFdVaUlHbHpVR1JtUlcxaVpXUmtaV1E5SW5SeWRXVWlJQTBLQ1FrSkNTQWdJRzVoYldVOUlrSmhjMlVpSUhCa1prVnVZMjlrYVc1blBTSkpaR1Z1ZEdsMGVTMUlJaUJ3WkdaR2IyNTBUbUZ0WlQwaVJHVnFZVloxVTJGdWN5NTBkR1lpSUhaQmJHbG5iajBpVFdsa1pHeGxJajROQ2drSkNUd3ZjM1I1YkdVK0RRb0pDUWs4YzNSNWJHVWdZbUZqYTJOdmJHOXlQU0lqTWpZM09UazBJaUJtYjI1MFUybDZaVDBpTWpZaUlHWnZjbVZqYjJ4dmNqMGlJMFpHUmtaR1JpSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0J0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWxScGRHeGxJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBpQU5DZ2tKQ1R4emRIbHNaU0JtYjI1MFUybDZaVDBpTVRJaUlHWnZjbVZqYjJ4dmNqMGlJekF3TURBd01DSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSWdibUZ0WlQwaVVHRm5aU0JvWldGa1pYSWlEUW9nSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnYzNSNWJHVTlJa0poYzJVaUx6NE5DZ2tKQ1R4emRIbHNaU0JpWVdOclkyOXNiM0k5SWlNek16TXpNek1pSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqUmtaR1JrWkdJaUJvUVd4cFoyNDlJa05sYm5SbGNpSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0JwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWtOdmJIVnRiaUJvWldGa1pYSWlJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdhWE5DYjJ4a1BTSm1ZV3h6WlNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpUkdWMFlXbHNJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBnMEtJQ0FnSUNBZ0lDQWdJQ0FnUEhOMGVXeGxJR2x6UW05c1pEMGlabUZzYzJVaUlHbHpSR1ZtWVhWc2REMGlabUZzYzJVaUlHNWhiV1U5SWtOdlpHVWlJSE4wZVd4bFBTSkNZWE5sSWlCbWIyNTBVMmw2WlQwaU9TSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJNUlpQm1iM0psWTI5c2IzSTlJaU13TURBd01EQWlJR2x6UkdWbVlYVnNkRDBpWm1Gc2MyVWlJRzVoYldVOUlsQmhaMlVnWm05dmRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUhOMGVXeGxQU0pDWVhObElpOCtEUW9KQ1R3dmFtRnpjR1Z5VkdWdGNHeGhkR1Ur + csv + JRSwapFileVirtualizer + 300 + 10000 + 300000 + diff --git a/model/report-impl/src/test/resources/reports/report-user-list-expressions-poisonous-query-csv.xml b/model/report-impl/src/test/resources/reports/report-user-list-expressions-poisonous-query-csv.xml new file mode 100644 index 00000000000..65e174146b5 --- /dev/null +++ b/model/report-impl/src/test/resources/reports/report-user-list-expressions-poisonous-query-csv.xml @@ -0,0 +1,35 @@ + + + Users in MidPoint - report with poisonous query expressions + Users listed in MidPoint. + + + + true + + + UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQWdJQ0FnQ1R4emRIbHNaU0JtYjI1MFRtRnRaVDBpUkdWcVlWWjFJRk5oYm5NaUlHWnZiblJUYVhwbFBTSXhNQ0lnYUVGc2FXZHVQU0pNWldaMElpQnBjMFJsWm1GMWJIUTlJblJ5ZFdVaUlHbHpVR1JtUlcxaVpXUmtaV1E5SW5SeWRXVWlJQTBLQ1FrSkNTQWdJRzVoYldVOUlrSmhjMlVpSUhCa1prVnVZMjlrYVc1blBTSkpaR1Z1ZEdsMGVTMUlJaUJ3WkdaR2IyNTBUbUZ0WlQwaVJHVnFZVloxVTJGdWN5NTBkR1lpSUhaQmJHbG5iajBpVFdsa1pHeGxJajROQ2drSkNUd3ZjM1I1YkdVK0RRb0pDUWs4YzNSNWJHVWdZbUZqYTJOdmJHOXlQU0lqTWpZM09UazBJaUJtYjI1MFUybDZaVDBpTWpZaUlHWnZjbVZqYjJ4dmNqMGlJMFpHUmtaR1JpSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0J0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWxScGRHeGxJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBpQU5DZ2tKQ1R4emRIbHNaU0JtYjI1MFUybDZaVDBpTVRJaUlHWnZjbVZqYjJ4dmNqMGlJekF3TURBd01DSWdhWE5FWldaaGRXeDBQU0ptWVd4elpTSWdibUZ0WlQwaVVHRm5aU0JvWldGa1pYSWlEUW9nSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnYzNSNWJHVTlJa0poYzJVaUx6NE5DZ2tKQ1R4emRIbHNaU0JpWVdOclkyOXNiM0k5SWlNek16TXpNek1pSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqUmtaR1JrWkdJaUJvUVd4cFoyNDlJa05sYm5SbGNpSU5DaUFnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0JwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ0YjJSbFBTSlBjR0Z4ZFdVaUlHNWhiV1U5SWtOdmJIVnRiaUJvWldGa1pYSWlJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdhWE5DYjJ4a1BTSm1ZV3h6WlNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpUkdWMFlXbHNJaUJ6ZEhsc1pUMGlRbUZ6WlNJdlBnMEtJQ0FnSUNBZ0lDQWdJQ0FnUEhOMGVXeGxJR2x6UW05c1pEMGlabUZzYzJVaUlHbHpSR1ZtWVhWc2REMGlabUZzYzJVaUlHNWhiV1U5SWtOdlpHVWlJSE4wZVd4bFBTSkNZWE5sSWlCbWIyNTBVMmw2WlQwaU9TSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJNUlpQm1iM0psWTI5c2IzSTlJaU13TURBd01EQWlJR2x6UkdWbVlYVnNkRDBpWm1Gc2MyVWlJRzVoYldVOUlsQmhaMlVnWm05dmRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUhOMGVXeGxQU0pDWVhObElpOCtEUW9KQ1R3dmFtRnpjR1Z5VkdWdGNHeGhkR1Ur + csv + JRSwapFileVirtualizer + 300 + 10000 + 300000 + diff --git a/model/report-impl/src/test/resources/reports/reportAuditLogs-with-datasource.xml b/model/report-impl/src/test/resources/reports/reportAuditLogs-with-datasource.xml deleted file mode 100644 index 1e634828192..00000000000 --- a/model/report-impl/src/test/resources/reports/reportAuditLogs-with-datasource.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - Audit logs report with datasource - Audit logs report with datasource - - Report made from audit records. With special datasource - landscape - - - timestamp - Timestamp - c:timestamp - 1 - ascending - 12 - xsd:dateTime - - - initiatorName - Initiator - c:initiatorName - 10 - xsd:string - - - eventType - Event Type - c:eventType - 12 - c:AuditEventType - - - eventStage - Event Stage - c:eventStage - 12 - c:AuditEventStage - - - targetName - Target - c:targetName - 10 - xsd:string - - - outcome - Outcome - c:outcome - 12 - c:OperationResultStatusType - - - message - Message - c:message - 20 - xsd:string - - - delta - Delta - c:delta - 12 - xsd:string - - - LOGO_PATH - src/test/resources/reports/logo.jpg - xsd:string - - - BaseTemplateStyles - src/test/resources/styles/midpoint_base_styles.jrtx - xsd:string - - - DATA_FROM - 2000-01-01 - xsd:dateTime - - - DATA_TO - 2020-12-31 - xsd:dateTime - - - EVENT_TYPE - "ALL" - xsd:string - - - - diff --git a/model/report-impl/src/test/resources/reports/reportAuditLogs.jrxml b/model/report-impl/src/test/resources/reports/reportAuditLogs.jrxml deleted file mode 100644 index b56afb45639..00000000000 --- a/model/report-impl/src/test/resources/reports/reportAuditLogs.jrxml +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <band height="168" splitType="Stretch"> - <frame> - <reportElement uuid="44bedacc-fa23-4fe1-b71f-e5afa943f553" style="Title" mode="Opaque" x="0" y="0" width="800" height="67" backcolor="#267994"/> - <staticText> - <reportElement uuid="f2d99cad-9d84-4f50-b455-453c87f62c4c" style="Title" x="10" y="13" width="266" height="38"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[Audit Log Report]]></text> - </staticText> - <image> - <reportElement uuid="b0a76e6a-8f61-4d60-8dcd-3e51adb4cd4c" style="Title" x="589" y="13" width="203" height="45"/> - <imageExpression><![CDATA[$P{LOGO_PATH}]]></imageExpression> - </image> - </frame> - <staticText> - <reportElement uuid="e035dbd5-dc2f-45cb-936c-a08e9c011e43" style="Page header" x="2" y="85" width="100" height="20"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[From:]]></text> - </staticText> - <textField pattern="EEEEE dd MMMMM yyyy, HH:mm:ss"> - <reportElement uuid="28bb9b47-a69c-48e1-9073-d54d926242e8" style="Page header" isPrintRepeatedValues="false" x="110" y="85" width="644" height="20"/> - <textElement verticalAlignment="Middle"> - <font isBold="false"/> - </textElement> - <textFieldExpression><![CDATA[$P{DATE_FROM}]]></textFieldExpression> - </textField> - <staticText> - <reportElement uuid="e035dbd5-dc2f-45cb-936c-a08e9c011e43" style="Page header" x="2" y="115" width="100" height="20"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[To:]]></text> - </staticText> - <textField pattern="EEEEE dd MMMMM yyyy, HH:mm:ss"> - <reportElement uuid="28bb9b47-a69c-48e1-9073-d54d926242e8" style="Page header" isPrintRepeatedValues="false" x="110" y="115" width="644" height="20"/> - <textElement verticalAlignment="Middle"> - <font isBold="false"/> - </textElement> - <textFieldExpression><![CDATA[$P{DATE_TO}]]></textFieldExpression> - </textField> - <staticText> - <reportElement uuid="e035dbd5-dc2f-45cb-936c-a08e9c011e43" style="Page header" x="2" y="145" width="100" height="20"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[Event Type:]]></text> - </staticText> - <textField> - <reportElement uuid="28bb9b47-a69c-48e1-9073-d54d926242e8" style="Page header" isPrintRepeatedValues="false" x="110" y="145" width="644" height="20"/> - <textElement verticalAlignment="Middle"> - <font isBold="false"/> - </textElement> - <textFieldExpression><![CDATA[$P{EVENT_TYPE_DESC}]]></textFieldExpression> - </textField> - </band> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/report-impl/src/test/resources/reports/reportAuditLogs.xml b/model/report-impl/src/test/resources/reports/reportAuditLogs.xml deleted file mode 100644 index ca2279332c0..00000000000 --- a/model/report-impl/src/test/resources/reports/reportAuditLogs.xml +++ /dev/null @@ -1,233 +0,0 @@ - - - Audit logs report - Report made from audit records. - - true - - UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQUpDVHh6ZEhsc1pTQm1iMjUwVG1GdFpUMGlSR1ZxWVZaMUlGTmhibk1pSUdadmJuUlRhWHBsUFNJeE1DSWdhRUZzYVdkdVBTSk1aV1owSWlCcGMwUmxabUYxYkhROUluUnlkV1VpSUdselVHUm1SVzFpWldSa1pXUTlJblJ5ZFdVaUlBMEtDUWtKQ1NBZ0lHNWhiV1U5SWtKaGMyVWlJSEJrWmtWdVkyOWthVzVuUFNKSlpHVnVkR2wwZVMxSUlpQndaR1pHYjI1MFRtRnRaVDBpUkdWcVlWWjFVMkZ1Y3k1MGRHWWlJSFpCYkdsbmJqMGlUV2xrWkd4bElqNE5DZ2tKQ1R3dmMzUjViR1UrRFFvSkNRazhjM1I1YkdVZ1ltRmphMk52Ykc5eVBTSWpNalkzT1RrMElpQm1iMjUwVTJsNlpUMGlNallpSUdadmNtVmpiMnh2Y2owaUkwWkdSa1pHUmlJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnRiMlJsUFNKUGNHRnhkV1VpSUc1aGJXVTlJbFJwZEd4bElpQnpkSGxzWlQwaVFtRnpaU0l2UGlBTkNna0pDVHh6ZEhsc1pTQm1iMjUwVTJsNlpUMGlNVElpSUdadmNtVmpiMnh2Y2owaUl6QXdNREF3TUNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpVUdGblpTQm9aV0ZrWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pDVHh6ZEhsc1pTQmlZV05yWTI5c2IzSTlJaU16TXpNek16TWlJR1p2Ym5SVGFYcGxQU0l4TWlJZ1ptOXlaV052Ykc5eVBTSWpSa1pHUmtaR0lpQm9RV3hwWjI0OUlrTmxiblJsY2lJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnBjMFJsWm1GMWJIUTlJbVpoYkhObElpQnRiMlJsUFNKUGNHRnhkV1VpSUc1aGJXVTlJa052YkhWdGJpQm9aV0ZrWlhJaUlITjBlV3hsUFNKQ1lYTmxJaTgrRFFvSkNRazhjM1I1YkdVZ2FYTkNiMnhrUFNKbVlXeHpaU0lnYVhORVpXWmhkV3gwUFNKbVlXeHpaU0lnYm1GdFpUMGlSR1YwWVdsc0lpQnpkSGxzWlQwaVFtRnpaU0l2UGcwS0NRa0pQSE4wZVd4bElHWnZiblJUYVhwbFBTSTVJaUJtYjNKbFkyOXNiM0k5SWlNd01EQXdNREFpSUdselJHVm1ZWFZzZEQwaVptRnNjMlVpSUc1aGJXVTlJbEJoWjJVZ1ptOXZkR1Z5SWcwS0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lITjBlV3hsUFNKQ1lYTmxJaTgrRFFvSkNUd3ZhbUZ6Y0dWeVZHVnRjR3hoZEdVKw== - landscape - pdf - - true - - timestamp - Timestamp - c:timestamp - 1 - ascending - 12 - xsd:dateTime - - - initiatorName - Initiator - c:initiatorName - 10 - xsd:string - - - eventType - Event Type - c:eventType - 12 - c:AuditEventType - - - eventStage - Event Stage - c:eventStage - 12 - c:AuditEventStage - - - targetName - Target - c:targetName - 10 - xsd:string - - - outcome - Outcome - c:outcome - 12 - c:OperationResultStatusType - - - message - Message - c:message - 20 - xsd:string - - - delta - Delta - c:delta - 12 - xsd:string - - - - select aer.timestamp as timestamp, - aer.initiatorName as initiator, - aer.eventType as eventType, - aer.eventStage as eventStage, - aer.targetName as targetName, - aer.targetType as targetType, - aer.targetOwnerName as targetOwnerName, - aer.outcome as outcome, - aer.message as message, - odo.delta as delta - from RObjectDeltaOperation as odo - join odo.record as aer - where ($P{eventType} = null or aer.eventType = $P{eventType}) and aer.timestamp >= $P{from} and aer.timestamp <= $P{to} - order by aer.timestamp - - 2000-01-01T00:00:00 - 2020-12-31T00:00:00 - - - - - - - - - - - - - - - - - - - - - - - - - - From: - - - - - - - - To: - - - - - - - - - Event Type: - - - - - - - - - - - All - - - - - Get object - - - - - Add object - - - - - Modify object - - - - - Delete object - - - - - Execute changes raw - - - - - Synchronization - - - - - Create session - - - - - Terminate session - - - - - Work item - - - - - Workflow process instance - - - - - Reconciliation - - - - - - - - - - diff --git a/model/report-impl/src/test/resources/reports/reportDataSourceTest.jrxml b/model/report-impl/src/test/resources/reports/reportDataSourceTest.jrxml deleted file mode 100644 index d5ba757e1be..00000000000 --- a/model/report-impl/src/test/resources/reports/reportDataSourceTest.jrxml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - <band height="110" splitType="Stretch"> - <frame> - <reportElement style="Title" mode="Opaque" x="1" y="0" width="799" height="67" backcolor="#267994" uuid="44bedacc-fa23-4fe1-b71f-e5afa943f553"/> - <staticText> - <reportElement style="Title" x="10" y="13" width="266" height="38" uuid="f2d99cad-9d84-4f50-b455-453c87f62c4c"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[User Report]]></text> - </staticText> - <image> - <reportElement style="Title" x="589" y="13" width="203" height="45" uuid="b0a76e6a-8f61-4d60-8dcd-3e51adb4cd4c"/> - <imageExpression><![CDATA[$P{logoPath}]]></imageExpression> - </image> - </frame> - <staticText> - <reportElement style="Page header" x="400" y="87" width="150" height="20" uuid="3ff78fbf-8fce-4072-b691-7af047ea92a7"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[Number of records:]]></text> - </staticText> - <textField pattern="EEEEE dd MMMMM yyyy, HH:mm:ss"> - <reportElement style="Page header" x="550" y="67" width="250" height="20" uuid="09a7e272-204e-4078-8a5e-e472757424c1"/> - <textElement textAlignment="Right" verticalAlignment="Middle"> - <font isBold="false"/> - </textElement> - <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> - </textField> - <staticText> - <reportElement style="Page header" x="400" y="67" width="150" height="20" uuid="b0b9714f-96f5-4f58-824b-c81fd4d321f7"/> - <textElement verticalAlignment="Middle"/> - <text><![CDATA[Report generated on:]]></text> - </staticText> - <textField evaluationTime="Report" isBlankWhenNull="true"> - <reportElement style="Page header" x="550" y="87" width="250" height="20" uuid="89251211-3f49-471d-b88d-5564c1bd04d1"/> - <textElement textAlignment="Right" verticalAlignment="Middle"> - <font isBold="false"/> - </textElement> - <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression> - </textField> - </band> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/model/report-impl/src/test/resources/reports/reportReconciliation.xml b/model/report-impl/src/test/resources/reports/reportReconciliation.xml deleted file mode 100644 index f0b757054f6..00000000000 --- a/model/report-impl/src/test/resources/reports/reportReconciliation.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - Reconciliation report - Reconciliation report for selected resource. - - true - - UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQUpDVHh6ZEhsc1pTQm1iMjUwVG1GdFpUMGlSR1ZxWVZaMUlGTmhibk1pSUdadmJuUlRhWHBsUFNJeE1DSWdhRUZzYVdkdVBTSk1aV1owSWlCcGMwUmxabUYxYkhROUluUnlkV1VpSUdselVHUm1SVzFpWldSa1pXUTlJblJ5ZFdVaUlBMEtDUWtKQ1NBZ0lHNWhiV1U5SWtKaGMyVWlJSEJrWmtWdVkyOWthVzVuUFNKSlpHVnVkR2wwZVMxSUlpQndaR1pHYjI1MFRtRnRaVDBpUkdWcVlWWjFVMkZ1Y3k1MGRHWWlJSFpCYkdsbmJqMGlUV2xrWkd4bElqNE5DZ2tKQ1R3dmMzUjViR1UrRFFvSkNRazhjM1I1YkdVZ1ltRmphMk52Ykc5eVBTSWpNalkzT1RrMElpQm1iMjUwVTJsNlpUMGlNallpSUdadmNtVmpiMnh2Y2owaUkwWkdSa1pHUmlJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnRiMlJsUFNKUGNHRnhkV1VpSUc1aGJXVTlJbFJwZEd4bElpQnpkSGxzWlQwaVFtRnpaU0l2UGlBTkNna0pDVHh6ZEhsc1pTQm1iMjUwVTJsNlpUMGlNVElpSUdadmNtVmpiMnh2Y2owaUl6QXdNREF3TUNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpVUdGblpTQm9aV0ZrWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pDVHh6ZEhsc1pTQmlZV05yWTI5c2IzSTlJaU16TXpNek16TWlJR1p2Ym5SVGFYcGxQU0l4TWlJZ1ptOXlaV052Ykc5eVBTSWpSa1pHUmtaR0lpQm9RV3hwWjI0OUlrTmxiblJsY2lJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnBjMFJsWm1GMWJIUTlJbVpoYkhObElpQnRiMlJsUFNKUGNHRnhkV1VpSUc1aGJXVTlJa052YkhWdGJpQm9aV0ZrWlhJaUlITjBlV3hsUFNKQ1lYTmxJaTgrRFFvSkNRazhjM1I1YkdVZ2FYTkNiMnhrUFNKbVlXeHpaU0lnYVhORVpXWmhkV3gwUFNKbVlXeHpaU0lnYm1GdFpUMGlSR1YwWVdsc0lpQnpkSGxzWlQwaVFtRnpaU0l2UGcwS0NRa0pQSE4wZVd4bElHWnZiblJUYVhwbFBTSTVJaUJtYjNKbFkyOXNiM0k5SWlNd01EQXdNREFpSUdselJHVm1ZWFZzZEQwaVptRnNjMlVpSUc1aGJXVTlJbEJoWjJVZ1ptOXZkR1Z5SWcwS0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lITjBlV3hsUFNKQ1lYTmxJaTgrRFFvSkNUd3ZhbUZ6Y0dWeVZHVnRjR3hoZEdVKw== - landscape - pdf - - true - - name - Name - c:name - 2 - ascending - 30 - t:PolyString - - - situation - Situation - c:synchronizationSituation - 1 - ascending - 20 - c:SynchronizationSituationType - - - username - Owner - c:name - 30 - t:PolyString - - - situationTimestamp - Timestamp - c:synchronizationTimestamp - 20 - xsd:dateTime - - - - select - (select u.name.orig from RUser as u join u.linkRef as ref where ref.targetOid = s.oid) as username, - s.name.orig as name, - s.synchronizationSituation as situation, - s.synchronizationTimestamp as situationTimestamp - from RShadow as s join s.resourceRef as resRef - where s.objectClass = $P{objectClass} and resRef.targetOid = $P{resourceOid} and resRef.type = 5 and s.kind = 0 - order by s.synchronizationSituation, s.name.orig - - http://midpoint.evolveum.com/xml/ns/public/resource/instance-3#AccountObjectClass - ef2bc95b-76e0-48e2-86d6-3d4f02d3e1a2 - OpenDJ resource - default - - - - - - - - - - - - - - - - - - - - - - - - - - Object Class: - - - - - - - - - - Resource: - - - - - - - - Intent: - - - - - - - - - - diff --git a/model/report-impl/src/test/resources/reports/reportUserAccounts.xml b/model/report-impl/src/test/resources/reports/reportUserAccounts.xml deleted file mode 100644 index 91b58926c01..00000000000 --- a/model/report-impl/src/test/resources/reports/reportUserAccounts.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - User accounts subreport - User accounts subreport for midpoint users. - - false - - landscape - pdf - - true - - accountName - Name - c:name - 100 - t:PolyStringType - - - - - select r.name.orig as resourceName, - s.name.orig as accountName - from RObjectReference as o, - RShadow as s, - RResource as r - where s.resourceRef.targetOid = r.oid and o.owner.oid = $P{userOid} and o.type = 6 and o.targetOid = s.oid and s.kind = 0 - order by r.name.orig, s.name.orig - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/report-impl/src/test/resources/reports/reportUserList.xml b/model/report-impl/src/test/resources/reports/reportUserList.xml deleted file mode 100644 index cbb65e425b5..00000000000 --- a/model/report-impl/src/test/resources/reports/reportUserList.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - Users in MidPoint - Users listed in MidPoint. - - true - - - role - - - - org - - - - account - - - - UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWo4K0RRbzhJVVJQUTFSWlVFVWdhbUZ6Y0dWeVZHVnRjR3hoZEdVTkNpQWdVRlZDVEVsRElDSXRMeTlLWVhOd1pYSlNaWEJ2Y25Sekx5OUVWRVFnVkdWdGNHeGhkR1V2TDBWT0lnMEtJQ0FpYUhSMGNEb3ZMMnBoYzNCbGNuSmxjRzl5ZEhNdWMyOTFjbU5sWm05eVoyVXVibVYwTDJSMFpITXZhbUZ6Y0dWeWRHVnRjR3hoZEdVdVpIUmtJajROQ2p4cVlYTndaWEpVWlcxd2JHRjBaVDROQ2lBZ0lDQUpDVHh6ZEhsc1pTQm1iMjUwVTJsNlpUMGlNVEFpSUdoQmJHbG5iajBpVEdWbWRDSWdhWE5FWldaaGRXeDBQU0owY25WbElpQnBjMUJrWmtWdFltVmtaR1ZrUFNKbVlXeHpaU0lnYm1GdFpUMGlRbUZ6WlNJTkNna0pDUWtnSUNCd1pHWkZibU52WkdsdVp6MGlRM0F4TWpVeUlnMEtDUWtKQ1NBZ0lIQmtaa1p2Ym5ST1lXMWxQU0pJWld4MlpYUnBZMkVpRFFvZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ2RrRnNhV2R1UFNKTmFXUmtiR1VpTHo0TkNna0pDVHh6ZEhsc1pTQmlZV05yWTI5c2IzSTlJaU15TmpjNU9UUWlJR1p2Ym5SVGFYcGxQU0l5TmlJZ1ptOXlaV052Ykc5eVBTSWpSa1pHUmtaR0lpQnBjMFJsWm1GMWJIUTlJbVpoYkhObElnMEtJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJRzF2WkdVOUlrOXdZWEYxWlNJTkNpQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQnVZVzFsUFNKVWFYUnNaU0lOQ2lBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNCemRIbHNaVDBpUW1GelpTSXZQZzBLQ1FrSlBITjBlV3hsSUdadmJuUlRhWHBsUFNJeE1pSWdabTl5WldOdmJHOXlQU0lqTURBd01EQXdJaUJwYzBSbFptRjFiSFE5SW1aaGJITmxJaUJ1WVcxbFBTSlFZV2RsSUdobFlXUmxjaUlOQ2lBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNCemRIbHNaVDBpUW1GelpTSXZQZzBLQ1FrSlBITjBlV3hsSUdKaFkydGpiMnh2Y2owaUl6TXpNek16TXlJZ1ptOXVkRk5wZW1VOUlqRXlJaUJtYjNKbFkyOXNiM0k5SWlOR1JrWkdSa1lpSUdoQmJHbG5iajBpUTJWdWRHVnlJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUdselJHVm1ZWFZzZEQwaVptRnNjMlVpRFFvZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ2JXOWtaVDBpVDNCaGNYVmxJZzBLSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdJQ0FnSUc1aGJXVTlJa052YkhWdGJpQm9aV0ZrWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pDVHh6ZEhsc1pTQnBjMEp2YkdROUltWmhiSE5sSWlCcGMwUmxabUYxYkhROUltWmhiSE5sSWlCdVlXMWxQU0pFWlhSaGFXd2lJSE4wZVd4bFBTSkNZWE5sSWk4K0RRb0pDUWs4YzNSNWJHVWdabTl1ZEZOcGVtVTlJamtpSUdadmNtVmpiMnh2Y2owaUl6QXdNREF3TUNJZ2FYTkVaV1poZFd4MFBTSm1ZV3h6WlNJZ2JtRnRaVDBpVUdGblpTQm1iMjkwWlhJaURRb2dJQ0FnSUNBZ0lDQWdJQ0FnSUNBZ0lDQWdjM1I1YkdVOUlrSmhjMlVpTHo0TkNna0pQQzlxWVhOd1pYSlVaVzF3YkdGMFpUND0= - landscape - pdf - - - Name - Name - c:name - 1 - ascending - 10 - t:PolyStringType - - - FirstName - First Name - c:givenName - 10 - t:PolyStringType - - - LastName - Last Name - c:familyName - 10 - t:PolyStringType - - - Activation - Activation - c:activation/c:administrativeStatus - 10 - c:ActivationStatusType - - - role - Role - c:Name - 10 - t:PolyString - - - organization - Organization - c:Name - 10 - t:PolyString - - - accounts - Accounts - c:Name - 20 - t:PolyString - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/report-impl/src/test/resources/reports/reportUserOrgs.xml b/model/report-impl/src/test/resources/reports/reportUserOrgs.xml deleted file mode 100644 index e7725be3ca3..00000000000 --- a/model/report-impl/src/test/resources/reports/reportUserOrgs.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - User orgs subreport - User orgs subreport for midpoint users. - - false - - landscape - pdf - - true - - orgName - Name - c:name - 100 - t:PolyStringType - - - - - select o.displayName.orig as orgName - from RAssignment as a, - ROrg as o - where a.targetRef.type = 15 and a.targetRef.targetOid = o.oid and a.owner.oid = $P{userOid} - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/report-impl/src/test/resources/reports/reportUserRoles.xml b/model/report-impl/src/test/resources/reports/reportUserRoles.xml deleted file mode 100644 index 13481a9d3ab..00000000000 --- a/model/report-impl/src/test/resources/reports/reportUserRoles.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - User roles subreport - User roles subreport for midpoint users. - - false - - landscape - pdf - - true - - roleName - Name - c:name - 100 - t:PolyStringType - - - - - select r.name.orig as roleName - from RAssignment as a, RRole as r - where a.targetRef.type = 7 and a.targetRef.targetOid = r.oid and a.owner.oid = $P{userOid} - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/report-impl/testng-integration.xml b/model/report-impl/testng-integration.xml index 2cf3b85d5fd..054209cc004 100644 --- a/model/report-impl/testng-integration.xml +++ b/model/report-impl/testng-integration.xml @@ -1,7 +1,7 @@ + 1 + + + mr:polyStringStrict + + + + extension/titleMap + + + + + + diff --git a/testing/story/src/test/resources/schema/ldap.xsd b/testing/story/src/test/resources/schema/ldap.xsd new file mode 100644 index 00000000000..f1247792283 --- /dev/null +++ b/testing/story/src/test/resources/schema/ldap.xsd @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + Container that somehow simulates polystring. But it is quasi-map form. + Key is language code, value is translated text. + MID-5264 + + + + + + + + + + true + + + + + + + + +