use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class SecurityHelper method postProcessPasswordPolicy.
private SecurityPolicyType postProcessPasswordPolicy(ValuePolicyType passwordPolicyType) {
SecurityPolicyType securityPolicyType = new SecurityPolicyType();
CredentialsPolicyType creds = new CredentialsPolicyType();
PasswordCredentialsPolicyType passwd = new PasswordCredentialsPolicyType();
ObjectReferenceType passwordPolicyRef = new ObjectReferenceType();
passwordPolicyRef.asReferenceValue().setObject(passwordPolicyType.asPrismObject());
passwd.setValuePolicyRef(passwordPolicyRef);
creds.setPassword(passwd);
securityPolicyType.setCredentials(creds);
setDeprecatedPasswordPolicyProperties(passwordPolicyType, passwd);
return securityPolicyType;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testValueGenerateRandomPin.
@Test
public void testValueGenerateRandomPin() throws Exception {
final String TEST_NAME = "testValueGenerateRandomPin";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ValuePolicyType pp = parsePasswordPolicy("value-policy-random-pin.xml");
// WHEN
TestUtil.displayWhen(TEST_NAME);
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, true, null, TEST_NAME, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
display("Generated password", psswd);
result.computeStatus();
TestUtil.assertSuccess(result);
assertNotNull(psswd);
assertPassword(psswd, pp);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class MappingEditorDialog method createPasswordPolicyList.
private List<ObjectReferenceType> createPasswordPolicyList() {
policyMap.clear();
OperationResult result = new OperationResult(OPERATION_LOAD_PASSWORD_POLICIES);
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_PASSWORD_POLICIES);
List<PrismObject<ValuePolicyType>> policies = null;
List<ObjectReferenceType> references = new ArrayList<>();
try {
policies = getPageBase().getModelService().searchObjects(ValuePolicyType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (CommonException | RuntimeException e) {
result.recordFatalError("Couldn't load password policies.", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load password policies", e);
}
if (policies != null) {
ObjectReferenceType ref;
for (PrismObject<ValuePolicyType> policy : policies) {
policyMap.put(policy.getOid(), WebComponentUtil.getName(policy));
ref = new ObjectReferenceType();
ref.setType(ValuePolicyType.COMPLEX_TYPE);
ref.setOid(policy.getOid());
references.add(ref);
}
}
return references;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class PageForgotPassword method generateNonce.
private <O extends ObjectType> String generateNonce(NonceCredentialsPolicyType noncePolicy, Task task, PrismObject<O> user, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
ValuePolicyType policy = null;
if (noncePolicy != null && noncePolicy.getValuePolicyRef() != null) {
PrismObject<ValuePolicyType> valuePolicy = WebModelServiceUtils.loadObject(ValuePolicyType.class, noncePolicy.getValuePolicyRef().getOid(), PageForgotPassword.this, task, result);
policy = valuePolicy.asObjectable();
}
return getModelInteractionService().generateValue(policy != null ? policy.getStringPolicy() : null, 24, false, user, "nonce generation", task, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestMappingDynamicSimple method generatePolicyNumeric.
private <T> void generatePolicyNumeric(final String TEST_NAME, String mappingFileName, String policyFileName, String extensionPropName, Class<T> clazz) throws Exception {
TestUtil.displayTestTile(TEST_NAME);
// This is just for validation. The expression has to resolve reference of its own
PrismObject<ValuePolicyType> valuePolicy = PrismTestUtil.parseObject(new File(MidPointTestConstants.OBJECTS_DIR, policyFileName));
final StringPolicyType stringPolicy = valuePolicy.asObjectable().getStringPolicy();
// GIVEN
Mapping<PrismPropertyValue<T>, PrismPropertyDefinition<T>> mapping = evaluator.<T>createMappingBuilder(mappingFileName, TEST_NAME, stringPolicy, new ItemPath(UserType.F_EXTENSION, new QName(NS_EXTENSION, extensionPropName)), null).build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN (1)
mapping.evaluate(null, opResult);
// THEN (1)
PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
T value1 = MappingTestEvaluator.getSingleValue("plus set", outputTriple.getZeroSet());
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
System.out.println("Generated value (1): " + value1);
assertNotNull("Generated null value", value1);
// We need to ignore the minLength. Conversion string -> number -> string may lose the leading zeroes
assertGeneratedValue(value1.toString(), stringPolicy, PATTERN_NUMERIC, true, false);
// GIVEN (2)
mapping = evaluator.<T>createMappingBuilder(mappingFileName, TEST_NAME, stringPolicy, new ItemPath(UserType.F_EXTENSION, new QName(NS_EXTENSION, extensionPropName)), null).build();
// WHEN (2)
mapping.evaluate(null, opResult);
// THEN (2)
outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
T value2 = MappingTestEvaluator.getSingleValue("plus set", outputTriple.getZeroSet());
System.out.println("Generated value (2): " + value2);
assertNotNull("Generated null value", value2);
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
assertFalse("Generated the same value", value1.equals(value2));
assertGeneratedValue(value1.toString(), stringPolicy, PATTERN_NUMERIC, true, false);
}
Aggregations