use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class OrgMemberPanel method removeManagerPerformed.
private void removeManagerPerformed(FocusType manager, AjaxRequestTarget target) {
OperationResult parentResult = new OperationResult("Remove manager");
Task task = getPageBase().createSimpleTask("Remove manager");
try {
ObjectDelta delta = ObjectDelta.createModificationDeleteContainer(manager.asPrismObject().getCompileTimeClass(), manager.getOid(), FocusType.F_ASSIGNMENT, getPageBase().getPrismContext(), createAssignmentToModify(SchemaConstants.ORG_MANAGER));
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, parentResult);
parentResult.computeStatus();
} catch (SchemaException | ObjectAlreadyExistsException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
parentResult.recordFatalError("Failed to remove manager " + e.getMessage(), e);
LoggingUtils.logUnexpectedException(LOGGER, "Failed to remove manager", e);
getPageBase().showResult(parentResult);
}
target.add(getPageBase().getFeedbackPanel());
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class AssignmentEditorPanel method loadSecurityDecisions.
private ItemSecurityDecisions loadSecurityDecisions() {
if (pageBase == null || getModelObject().getTargetRef() == null) {
return null;
}
PrismObject<UserType> user = null;
List<PrismObject<UserType>> targetUserList = pageBase.getSessionStorage().getRoleCatalog().getTargetUserList();
if (targetUserList == null || targetUserList.size() == 0) {
user = pageBase.loadUserSelf(pageBase);
} else {
user = targetUserList.get(0);
}
String targetObjectOid = getModelObject().getTargetRef().getOid();
Task task = pageBase.createSimpleTask(OPERATION_LOAD_TARGET_OBJECT);
OperationResult result = new OperationResult(OPERATION_LOAD_TARGET_OBJECT);
PrismObject<AbstractRoleType> targetRefObject = WebModelServiceUtils.loadObject(AbstractRoleType.class, targetObjectOid, pageBase, task, result);
ItemSecurityDecisions decisions = null;
try {
decisions = pageBase.getModelInteractionService().getAllowedRequestAssignmentItems(user, targetRefObject);
} catch (SchemaException | SecurityViolationException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load security decisions for assignment items.", ex);
}
return decisions;
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class ResourceContentPanel method deleteAccountConfirmedPerformed.
private void deleteAccountConfirmedPerformed(AjaxRequestTarget target, OperationResult result, List<ShadowType> selected) {
Task task = pageBase.createSimpleTask(OPERATION_DELETE_OBJECT);
ModelExecuteOptions opts = createModelOptions();
for (ShadowType shadow : selected) {
try {
ObjectDelta<ShadowType> deleteDelta = ObjectDelta.createDeleteDelta(ShadowType.class, shadow.getOid(), getPageBase().getPrismContext());
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(deleteDelta), opts, task, result);
} catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
result.recordPartialError("Could not delete object " + shadow, e);
LOGGER.error("Could not delete {}, using option {}", shadow, opts, e);
continue;
}
}
result.computeStatusIfUnknown();
getPageBase().showResult(result);
getTable().refreshTable(null, target);
target.add(getPageBase().getFeedbackPanel());
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class ResourceContentPanel method changeOwnerInternal.
private void changeOwnerInternal(String ownerOid, Collection<? extends ItemDelta> modifications, AjaxRequestTarget target) {
OperationResult result = new OperationResult(OPERATION_CHANGE_OWNER);
Task task = pageBase.createSimpleTask(OPERATION_CHANGE_OWNER);
ObjectDelta objectDelta = ObjectDelta.createModifyDelta(ownerOid, modifications, FocusType.class, pageBase.getPrismContext());
Collection deltas = new ArrayList<>();
deltas.add(objectDelta);
try {
if (!deltas.isEmpty()) {
pageBase.getModelService().executeChanges(deltas, null, task, result);
}
} catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
}
result.computeStatusIfUnknown();
pageBase.showResult(result);
target.add(pageBase.getFeedbackPanel());
getTable().refreshTable(null, target);
target.add(ResourceContentPanel.this);
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class RunReportPopupPanel method createLookupTableRows.
private <O extends ObjectType> List<LookupTableRowType> createLookupTableRows(JasperReportParameterDto param, String input) {
ItemPath label = null;
ItemPath key = null;
List<LookupTableRowType> rows = new ArrayList<>();
JasperReportParameterPropertiesDto properties = param.getProperties();
if (properties == null) {
return null;
}
String pLabel = properties.getLabel();
if (pLabel != null) {
label = new ItemPath(pLabel);
}
String pKey = properties.getKey();
if (pKey != null) {
key = new ItemPath(pKey);
}
String pTargetType = properties.getTargetType();
Class<O> targetType = null;
if (pTargetType != null) {
try {
targetType = (Class<O>) Class.forName(pTargetType);
} catch (ClassNotFoundException e) {
error("Error while creating lookup table for input parameter: " + param.getName() + ", " + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
//e.printStackTrace();
}
}
if (label != null && targetType != null && input != null) {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
Collection<PrismObject<O>> objects;
ObjectQuery query = QueryBuilder.queryFor(targetType, getPrismContext()).item(new QName(SchemaConstants.NS_C, pLabel)).startsWith(input).matching(new QName(SchemaConstants.NS_MATCHING_RULE, "origIgnoreCase")).maxSize(AUTO_COMPLETE_BOX_SIZE).build();
try {
objects = getPageBase().getModelService().searchObjects(targetType, query, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), task, result);
for (PrismObject<O> o : objects) {
Object realKeyValue = null;
PrismProperty labelItem = o.findProperty(label);
//TODO: e.g. support not only for property, but also ref, container..
if (labelItem == null || labelItem.isEmpty()) {
continue;
}
PrismProperty keyItem = o.findProperty(key);
if ("oid".equals(pKey)) {
realKeyValue = o.getOid();
}
if (realKeyValue == null && (keyItem == null || keyItem.isEmpty())) {
continue;
}
//TODO: support for single/multivalue value
if (!labelItem.isSingleValue()) {
continue;
}
Object realLabelValue = labelItem.getRealValue();
realKeyValue = (realKeyValue == null) ? keyItem.getRealValue() : realKeyValue;
// TODO: take definition into account
QName typeName = labelItem.getDefinition().getTypeName();
LookupTableRowType row = new LookupTableRowType();
if (realKeyValue != null) {
row.setKey(convertObjectToPolyStringType(realKeyValue).getOrig());
} else {
throw new SchemaException("Cannot create lookup table with null key for label: " + realLabelValue);
}
row.setLabel(convertObjectToPolyStringType(realLabelValue));
rows.add(row);
}
return rows;
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
error("Error while creating lookup table for input parameter: " + param.getName() + ", " + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
//e.printStackTrace();
}
}
return rows;
}
Aggregations