Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 20, 2014
2 parents e5a7990 + d1020e3 commit 942cc7a
Show file tree
Hide file tree
Showing 28 changed files with 244 additions and 159 deletions.
Expand Up @@ -17,7 +17,7 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<input class="form-control input-sm" wicket:id="password1" type="password"/>
<input class="form-control input-sm" wicket:id="password1" type="password" autocomplete="off"/>
<input class="form-control input-sm" wicket:id="password2" type="password" style="margin-top: 5px;"/>
</wicket:panel>
</html>
Expand Up @@ -98,7 +98,8 @@ <h3>
</label>

<div class="col-lg-4">
<input type="text" class="form-control input-sm" placeholder="Default from" wicket:id="defaultFrom">
<input type="text" class="form-control input-sm" wicket:id="defaultFrom"
wicket:message="placeholder:SystemConfigPanel.mail.defaultFrom">
</div>
</div>
<div class="form-group">
Expand Down Expand Up @@ -142,7 +143,7 @@ <h3>
</label>

<div class="col-lg-4">
<input type="text" class="form-control input-sm" wicket:id="username"
<input type="text" class="form-control input-sm" wicket:id="username" autocomplete="off"
wicket:message="placeholder:SystemConfigPanel.mail.username">
</div>
</div>
Expand All @@ -152,7 +153,7 @@ <h3>
</label>

<div class="col-lg-4">
<input type="password" class="form-control input-sm" wicket:id="password"
<input type="password" class="form-control input-sm" wicket:id="password" autocomplete="off"
wicket:message="placeholder:SystemConfigPanel.mail.password">
</div>
</div>
Expand All @@ -172,6 +173,7 @@ <h3>
</div>
</div>

<wicket:remove>
<!-- Connector frameworks configuration commented out for now
<h3>
<wicket:message key="SystemConfigPanel.title.connectorFramework"/>
Expand All @@ -185,7 +187,7 @@ <h3>
</div>
</div>
-->

</wicket:remove>
</div>
</div>
</wicket:panel>
Expand Down
Expand Up @@ -41,6 +41,7 @@ public class ExpressionConstants {
public static final QName VAR_RESOURCE = new QName(SchemaConstants.NS_C, "resource");
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_LEGAL = new QName(SchemaConstants.NS_C, "legal");
public static final QName VAR_FOCUS_EXISTS = new QName(SchemaConstants.NS_C, "focusExists");
Expand Down
Expand Up @@ -61,6 +61,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType;

/**
Expand All @@ -81,6 +82,7 @@ public class AssignmentEvaluator<F extends FocusType> {
private ActivationComputer activationComputer;
XMLGregorianCalendar now;
private boolean evaluateConstructions = true;
private PrismObject<SystemConfigurationType> systemConfiguration;

public RepositoryService getRepository() {
return repository;
Expand Down Expand Up @@ -162,6 +164,14 @@ public void setEvaluateConstructions(boolean evaluateConstructions) {
this.evaluateConstructions = evaluateConstructions;
}

public PrismObject<SystemConfigurationType> getSystemConfiguration() {
return systemConfiguration;
}

public void setSystemConfiguration(PrismObject<SystemConfigurationType> systemConfiguration) {
this.systemConfiguration = systemConfiguration;
}

public SimpleDelta<EvaluatedAssignment> evaluate(SimpleDelta<AssignmentType> assignmentTypeDelta, ObjectType source, String sourceDescription,
Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException {
SimpleDelta<EvaluatedAssignment> delta = new SimpleDelta<EvaluatedAssignment>();
Expand Down Expand Up @@ -303,7 +313,7 @@ private void evaluateFocusMappings(EvaluatedAssignment evaluatedAssignment, Assi

for (MappingType mappingType: mappingsType.getMapping()) {
Mapping mapping = LensUtil.createFocusMapping(mappingFactory, lensContext, mappingType, source, userOdo,
assignmentPathVariables, now, sourceDescription, result);
assignmentPathVariables, systemConfiguration, now, sourceDescription, result);
if (mapping == null) {
continue;
}
Expand Down
Expand Up @@ -973,7 +973,7 @@ private <F extends ObjectType, T extends ObjectType> OperationProvisioningScript

ResourceShadowDiscriminator discr = ((LensProjectionContext) objectContext).getResourceShadowDiscriminator();

ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, resourceObject, discr, resource.asPrismObject());
ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, resourceObject, discr, resource.asPrismObject(), context.getSystemConfiguration());
return evaluateScript(resourceScripts, discr, operation, null, variables, task, result);

}
Expand Down Expand Up @@ -1096,7 +1096,7 @@ void executeReconciliationScript(LensProjectionContext projContext, LensContext<
}

ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, shadow,
projContext.getResourceShadowDiscriminator(), resource.asPrismObject());
projContext.getResourceShadowDiscriminator(), resource.asPrismObject(), context.getSystemConfiguration());
OperationProvisioningScriptsType evaluatedScript = evaluateScript(resourceScripts,
projContext.getResourceShadowDiscriminator(),
ProvisioningOperationTypeType.RECONCILE, order, variables, task, parentResult);
Expand Down
Expand Up @@ -776,20 +776,7 @@ public static <T extends ObjectType, F extends ObjectType> void setContextOid(Le
public static PrismObject<SystemConfigurationType> getSystemConfiguration(LensContext context, RepositoryService repositoryService, OperationResult result) throws ObjectNotFoundException, SchemaException {
PrismObject<SystemConfigurationType> systemConfiguration = context.getSystemConfiguration();
if (systemConfiguration == null) {
try {
systemConfiguration =
repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, result);
} catch (ObjectNotFoundException e) {
// just go on ... we will return and continue
// This is needed e.g. to set up new system configuration is the old one gets deleted
}
if (systemConfiguration == null) {
// throw new SystemException("System configuration object is null (should not happen!)");
// This should not happen, but it happens in tests. And it is a convenient short cut. Tolerate it for now.
LOGGER.warn("System configuration object is null (should not happen!)");
return null;
}
systemConfiguration = Utils.getSystemConfiguration(repositoryService, result);
context.setSystemConfiguration(systemConfiguration);
}
return systemConfiguration;
Expand Down Expand Up @@ -918,7 +905,7 @@ public static boolean isValid(AssignmentType assignmentType, XMLGregorianCalenda

public static <V extends PrismValue, F extends FocusType> Mapping<V> createFocusMapping(final MappingFactory mappingFactory,
final LensContext<F> context, final MappingType mappingType, ObjectType originObject,
ObjectDeltaObject<F> focusOdo, AssignmentPathVariables assignmentPathVariables,
ObjectDeltaObject<F> focusOdo, AssignmentPathVariables assignmentPathVariables, PrismObject<SystemConfigurationType> configuration,
XMLGregorianCalendar now, String contextDesc, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
Integer iteration = null;
String iterationToken = null;
Expand All @@ -932,13 +919,14 @@ public static <V extends PrismValue, F extends FocusType> Mapping<V> createFocus
iterationToken = focusOldType.getIterationToken();
}
return createFocusMapping(mappingFactory, context, mappingType, originObject, focusOdo, assignmentPathVariables,
iteration, iterationToken, now, contextDesc, result);
iteration, iterationToken, configuration, now, contextDesc, result);
}

public static <V extends PrismValue, F extends FocusType> Mapping<V> createFocusMapping(final MappingFactory mappingFactory,
final LensContext<F> context, final MappingType mappingType, ObjectType originObject,
ObjectDeltaObject<F> focusOdo, AssignmentPathVariables assignmentPathVariables,
Integer iteration, String iterationToken, XMLGregorianCalendar now, String contextDesc, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
Integer iteration, String iterationToken, PrismObject<SystemConfigurationType> configuration,
XMLGregorianCalendar now, String contextDesc, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
Mapping<V> mapping = mappingFactory.createMapping(mappingType, contextDesc);

if (!mapping.isApplicableToChannel(context.getChannel())) {
Expand All @@ -952,6 +940,7 @@ public static <V extends PrismValue, F extends FocusType> Mapping<V> createFocus
mapping.addVariableDefinition(ExpressionConstants.VAR_FOCUS, focusOdo);
mapping.addVariableDefinition(ExpressionConstants.VAR_ITERATION, iteration);
mapping.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken);
mapping.addVariableDefinition(ExpressionConstants.VAR_CONFIGURATION, configuration);
addAssignmentPathVariables(mapping, assignmentPathVariables);
mapping.setOriginType(OriginType.USER_POLICY);
mapping.setOriginObject(originObject);
Expand Down
Expand Up @@ -203,6 +203,7 @@ private <F extends FocusType> void processAssignmentsProjectionsWithFocus(LensCo
assignmentEvaluator.setMappingFactory(mappingFactory);
assignmentEvaluator.setActivationComputer(activationComputer);
assignmentEvaluator.setNow(now);
assignmentEvaluator.setSystemConfiguration(context.getSystemConfiguration());

// We will be collecting the evaluated account constructions into these three sets.
// It forms a kind of delta set triple for the account constructions.
Expand Down
Expand Up @@ -206,7 +206,7 @@ private <F extends FocusType> void processFocusFocus(LensContext<F> context, Str

while (true) {

ExpressionVariables variables = Utils.getDefaultExpressionVariables(focusContext.getObjectNew(), null, null, null);
ExpressionVariables variables = Utils.getDefaultExpressionVariables(focusContext.getObjectNew(), null, null, null, context.getSystemConfiguration());
if (iterationToken == null) {
iterationToken = LensUtil.formatIterationToken(context, focusContext,
iterationSpecificationType, iteration, expressionFactory, variables, task, result);
Expand Down
Expand Up @@ -292,7 +292,7 @@ private <V extends PrismValue, F extends FocusType> XMLGregorianCalendar collect
continue;
}
Mapping<V> mapping = LensUtil.createFocusMapping(mappingFactory, context, mappingType, objectTemplateType, userOdo,
null, iteration, iterationToken, now, contextDesc, result);
null, iteration, iterationToken, context.getSystemConfiguration(), now, contextDesc, result);
if (mapping == null) {
continue;
}
Expand Down
Expand Up @@ -36,6 +36,7 @@
import com.evolveum.midpoint.model.impl.lens.LensFocusContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.LensUtil;
import com.evolveum.midpoint.model.impl.util.Utils;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.OriginType;
Expand Down Expand Up @@ -199,6 +200,7 @@ private <F extends FocusType, V extends PrismValue> Mapping<V> evaluateMapping(f
mapping.addVariableDefinition(ExpressionConstants.VAR_FOCUS, focusOdo);
mapping.addVariableDefinition(ExpressionConstants.VAR_ACCOUNT, projectionOdo);
mapping.addVariableDefinition(ExpressionConstants.VAR_PROJECTION, projectionOdo);
mapping.addVariableDefinition(ExpressionConstants.VAR_CONFIGURATION, context.getSystemConfiguration());
mapping.addVariableDefinition(ExpressionConstants.VAR_ITERATION,
LensUtil.getIterationVariableValue(projCtx));
mapping.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN,
Expand Down
Expand Up @@ -337,7 +337,7 @@ private <F extends FocusType> void processProjections(LensContext<F> context,
if (ResourceTypeUtil.isSynchronizationOpportunistic(resourceType)) {
LOGGER.trace("Trying to find owner using correlation expression.");
boolean match = synchronizationService.matchUserCorrelationRule(fullConflictingShadow,
context.getFocusContext().getObjectNew(), resourceType, task, result);
context.getFocusContext().getObjectNew(), resourceType, context.getSystemConfiguration(), task, result);

if (match){
//check if it is add account (primary delta contains add shadow deltu)..
Expand Down Expand Up @@ -534,7 +534,7 @@ private <F extends ObjectType> String formatIterationToken(LensContext<F> contex
private <F extends ObjectType> ExpressionVariables createExpressionVariables(LensContext<F> context,
LensProjectionContext accountContext) {
return Utils.getDefaultExpressionVariables(context.getFocusContext().getObjectNew(), accountContext.getObjectNew(),
accountContext.getResourceShadowDiscriminator(), accountContext.getResource().asPrismObject());
accountContext.getResourceShadowDiscriminator(), accountContext.getResource().asPrismObject(), context.getSystemConfiguration());
}

private <F extends ObjectType> boolean evaluateIterationCondition(LensContext<F> context,
Expand Down
Expand Up @@ -175,7 +175,9 @@ private void addAuthorizations(MidPointPrincipal principal) {
for(AssignmentType assignmentType: userType.getAssignment()) {
try {
EvaluatedAssignment assignment = assignmentEvaluator.evaluate(assignmentType, userType, userType.toString(), null, result);
authorizations.addAll(assignment.getAuthorizations());
if (assignment.isValid()) {
authorizations.addAll(assignment.getAuthorizations());
}
} catch (SchemaException e) {
LOGGER.error("Schema violation while processing assignment of {}: {}; assignment: {}",
new Object[]{userType, e.getMessage(), assignmentType, e});
Expand Down

0 comments on commit 942cc7a

Please sign in to comment.