use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class ResourceCredentialsEditor method createPasswordPolicyList.
private List<ObjectReferenceType> createPasswordPolicyList() {
passPolicyMap.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) {
passPolicyMap.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.prism.PrismObject in project midpoint by Evolveum.
the class PageSecurityQuestions method loadPageModel.
private PasswordQuestionsDto loadPageModel() {
LOGGER.debug("Loading user.");
final String userOid = getPageParameters().get(SESSION_ATTRIBUTE_POID).toString();
PrismObject<UserType> user = runPrivileged(new Producer<PrismObject<UserType>>() {
@Override
public PrismObject<UserType> run() {
Task task = createAnonymousTask(OPERATION_LOAD_USER);
OperationResult subResult = task.getResult();
try {
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
return getModelService().getObject(UserType.class, userOid, options, task, subResult);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
LOGGER.error("Error getting user {}: {}", userOid, e.getMessage(), e);
// we do not want to provide any information to the attacker.
return null;
}
}
});
principalModel.setObject(user);
PasswordQuestionsDto dto = new PasswordQuestionsDto();
dto.setSecurityAnswers(createUsersSecurityQuestionsList(user));
return dto;
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class OrgTreeProvider method getChildren.
@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
// getAvailableData().clear();
LOGGER.debug("Loading children for {}", new Object[] { node });
Iterator<SelectableBean<OrgType>> iterator = null;
ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
node.getValue().getOid()).asc(ObjectType.F_NAME).build();
OperationResult result = new OperationResult(LOAD_ORG_UNITS);
try {
// Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
Collection<SelectorOptions<GetOperationOptions>> options = null;
Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
LOGGER.debug("Found {} units.", units.size());
List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
for (PrismObject<OrgType> unit : units) {
SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
list.add(selectable);
// if (getAvailableData().contains(selectable)){
// getAvailableData().remove(selectable);
// }
// getAvailableData().add(selectable);
}
getAvailableData().addAll(list);
// Collections.sort(list);
iterator = list.iterator();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
result.recordFatalError("Unable to load org unit", ex);
} finally {
result.computeStatus();
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageOrgTree.class);
}
if (iterator == null) {
iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
}
LOGGER.debug("Finished loading children.");
return iterator;
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestObjectQuery method testMatchEqualNonEmptyAgainstEmptyItem.
@Test
public void testMatchEqualNonEmptyAgainstEmptyItem() throws Exception {
PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
// jack has no locality
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_LOCALITY).eq("some").buildFilter();
boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
AssertJUnit.assertFalse("filter matches object, but it should not", match);
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestObjectQuery method testMatchAndFilter.
@Test
public void testMatchAndFilter() throws Exception {
PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_GIVEN_NAME).eq("Jack").matchingCaseIgnore().and().item(UserType.F_FULL_NAME).contains("arr").buildFilter();
boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
AssertJUnit.assertTrue("filter does not match object", match);
}
Aggregations