use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class SystemConfigPanel method initLayout.
protected void initLayout() {
ChooseTypePanel<ValuePolicyType> passPolicyChoosePanel = new ChooseTypePanel<ValuePolicyType>(ID_GLOBAL_PASSWORD_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<ValuePolicyType>>(getModel(), SystemConfigurationDto.F_PASSWORD_POLICY));
ChooseTypePanel<SecurityPolicyType> securityPolicyChoosePanel = new ChooseTypePanel<SecurityPolicyType>(ID_GLOBAL_SECURITY_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<SecurityPolicyType>>(getModel(), SystemConfigurationDto.F_SECURITY_POLICY));
add(passPolicyChoosePanel);
add(securityPolicyChoosePanel);
ObjectPolicyConfigurationEditor objectPolicyEditor = new ObjectPolicyConfigurationEditor(ID_OBJECT_POLICY_EDITOR, new PropertyModel<List<ObjectPolicyConfigurationTypeDto>>(getModel(), SystemConfigurationDto.F_OBJECT_POLICY_LIST));
add(objectPolicyEditor);
DropDownChoice<AEPlevel> aepLevel = new DropDownChoice<>(ID_GLOBAL_AEP, new PropertyModel<AEPlevel>(getModel(), SystemConfigurationDto.F_AEP_LEVEL), WebComponentUtil.createReadonlyModelFromEnum(AEPlevel.class), new EnumChoiceRenderer<AEPlevel>(SystemConfigPanel.this));
aepLevel.setOutputMarkupId(true);
if (aepLevel.getModel().getObject() == null) {
aepLevel.getModel().setObject(null);
}
aepLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
add(aepLevel);
TextField<String> auditRecordsField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_AUDIT_RECORDS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_AUDIT_CLEANUP));
TextField<String> closedTasksField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_CLOSED_TASKS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_TASK_CLEANUP));
add(auditRecordsField);
add(closedTasksField);
createTooltip(ID_CLEANUP_AUDIT_RECORDS_TOOLTIP);
createTooltip(ID_CLEANUP_CLOSED_TASKS_TOOLTIP);
CheckBox experimentalCodeCheck = WebComponentUtil.createAjaxCheckBox(ID_EXPERIMENTAL_CODE_CHECKBOX, new PropertyModel<Boolean>(getModel(), SystemConfigurationDto.F_ENABLE_EXPERIMENTAL_CODE));
add(experimentalCodeCheck);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class SystemConfigurationDto method loadPasswordPolicy.
private ObjectViewDto<ValuePolicyType> loadPasswordPolicy(SystemConfigurationType config) {
ValuePolicyType passPolicy = config.getGlobalPasswordPolicy();
if (passPolicy != null) {
passPolicyDto = new ObjectViewDto<>(passPolicy.getOid(), passPolicy.getName().getOrig());
} else {
passPolicyDto = new ObjectViewDto<>();
}
passPolicyDto.setType(ValuePolicyType.class);
return passPolicyDto;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestParsePasswordPolicy method testParsePasswordPolicyFile.
@Test
public void testParsePasswordPolicyFile() throws Exception {
System.out.println("===[ testParsePasswordPolicyFile ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
PrismObject<ValuePolicyType> policy = prismContext.parserFor(FILE).xml().parse();
// THEN
System.out.println("Parsed policy:");
System.out.println(policy.debugDump());
assertPolicy(policy);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class MappingEvaluator method createFocusMapping.
public <V extends PrismValue, D extends ItemDefinition, F extends FocusType, T extends FocusType> Mapping<V, D> createFocusMapping(final MappingFactory mappingFactory, final LensContext<F> context, final MappingType mappingType, ObjectType originObject, ObjectDeltaObject<F> focusOdo, PrismObject<T> defaultTargetObject, AssignmentPathVariables assignmentPathVariables, Integer iteration, String iterationToken, PrismObject<SystemConfigurationType> configuration, XMLGregorianCalendar now, String contextDesc, final Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
if (!Mapping.isApplicableToChannel(mappingType, context.getChannel())) {
LOGGER.trace("Mapping {} not applicable to channel {}, skipping.", mappingType, context.getChannel());
return null;
}
StringPolicyResolver stringPolicyResolver = new StringPolicyResolver() {
private ItemPath outputPath;
private ItemDefinition outputDefinition;
@Override
public void setOutputPath(ItemPath outputPath) {
this.outputPath = outputPath;
}
@Override
public void setOutputDefinition(ItemDefinition outputDefinition) {
this.outputDefinition = outputDefinition;
}
@Override
public StringPolicyType resolve() {
// TODO need to switch to ObjectValuePolicyEvaluator
if (outputDefinition.getName().equals(PasswordType.F_VALUE)) {
ValuePolicyType passwordPolicy = credentialsProcessor.determinePasswordPolicy(context.getFocusContext(), task, result);
if (passwordPolicy == null) {
return null;
}
return passwordPolicy.getStringPolicy();
}
if (mappingType.getExpression() != null) {
List<JAXBElement<?>> evaluators = mappingType.getExpression().getExpressionEvaluator();
if (evaluators != null) {
for (JAXBElement jaxbEvaluator : evaluators) {
Object object = jaxbEvaluator.getValue();
if (object instanceof GenerateExpressionEvaluatorType && ((GenerateExpressionEvaluatorType) object).getValuePolicyRef() != null) {
ObjectReferenceType ref = ((GenerateExpressionEvaluatorType) object).getValuePolicyRef();
try {
ValuePolicyType valuePolicyType = mappingFactory.getObjectResolver().resolve(ref, ValuePolicyType.class, null, "resolving value policy for generate attribute " + outputDefinition.getName() + " value", task, new OperationResult("Resolving value policy"));
if (valuePolicyType != null) {
return valuePolicyType.getStringPolicy();
}
} catch (CommonException ex) {
throw new SystemException(ex.getMessage(), ex);
}
}
}
}
}
return null;
}
};
ExpressionVariables variables = new ExpressionVariables();
FOCUS_VARIABLE_NAMES.forEach(name -> variables.addVariableDefinition(name, focusOdo));
variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION, iteration);
variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken);
variables.addVariableDefinition(ExpressionConstants.VAR_CONFIGURATION, configuration);
Collection<V> targetValues = computeTargetValues(mappingType.getTarget(), defaultTargetObject, variables, mappingFactory.getObjectResolver(), contextDesc, task, result);
Mapping.Builder<V, D> mappingBuilder = mappingFactory.<V, D>createMappingBuilder(mappingType, contextDesc).sourceContext(focusOdo).targetContext(defaultTargetObject.getDefinition()).variables(variables).originalTargetValues(targetValues).originType(OriginType.USER_POLICY).originObject(originObject).stringPolicyResolver(stringPolicyResolver).rootNode(focusOdo).now(now);
mappingBuilder = LensUtil.addAssignmentPathVariables(mappingBuilder, assignmentPathVariables);
Mapping<V, D> mapping = mappingBuilder.build();
ItemPath itemPath = mapping.getOutputPath();
if (itemPath == null) {
// no output element, i.e. this is a "validation mapping"
return mapping;
}
if (defaultTargetObject != null) {
Item<V, D> existingTargetItem = (Item<V, D>) defaultTargetObject.findItem(itemPath);
if (existingTargetItem != null && !existingTargetItem.isEmpty() && mapping.getStrength() == MappingStrengthType.WEAK) {
LOGGER.trace("Mapping {} is weak and target already has a value {}, skipping.", mapping, existingTargetItem);
return null;
}
}
return mapping;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class ValuePolicyProcessor method normalize.
/**
* add defined default values
*/
private void normalize(ValuePolicyType pp) {
if (null == pp) {
throw new IllegalArgumentException("Password policy cannot be null");
}
if (null == pp.getStringPolicy()) {
StringPolicyType sp = new StringPolicyType();
pp.setStringPolicy(StringPolicyUtils.normalize(sp));
} else {
pp.setStringPolicy(StringPolicyUtils.normalize(pp.getStringPolicy()));
}
if (null == pp.getLifetime()) {
PasswordLifeTimeType lt = new PasswordLifeTimeType();
lt.setExpiration(-1);
lt.setWarnBeforeExpiration(0);
lt.setLockAfterExpiration(0);
lt.setMinPasswordAge(0);
lt.setPasswordHistoryLength(0);
}
return;
}
Aggregations