@Override public boolean equivalent(AssignmentPath other) { if (size() != other.size()) { return false; } for (int i = 0; i < segments.size(); i++) { AssignmentPathSegment segment = segments.get(i); AssignmentPathSegment otherSegment = other.getSegments().get(i); if (!segment.equivalent(otherSegment)) { return false; } } return true; }
default AssignmentPathSegment getAt(int index) { return getSegment(index); }
@SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean pathMatches(AssignmentPath assignmentPath, List<OrderConstraintsType> definedOrderConstraints) { if (assignmentPath == null) { throw new IllegalStateException("Check this. Assignment path is null."); } if (assignmentPath.isEmpty()) { throw new IllegalStateException("Check this. Assignment path is empty."); } return assignmentPath.matches(definedOrderConstraints); }
if (assignmentPath.isEmpty()) { throw new ExpressionEvaluationException("Empty assignment path variable in "+desc+"; the expression may be used in a wrong place. It is only supposed to work in a role."); LOGGER.trace("ASSPATH {}:\n{}", evaluatorType.getDescription(), assignmentPath.debugDumpLazily(1)); segment = assignmentPath.getSegment(assignmentPathIndex); } catch (IndexOutOfBoundsException e) { throw new ExpressionEvaluationException("Wrong assignment path index in "+desc+"; Index "+assignmentPathIndex+" cannot be applied to a path of legth "+assignmentPath.size(), e);
public static boolean isDelegationPath(@NotNull AssignmentPath assignmentPath, @NotNull RelationRegistry relationRegistry) { for (AssignmentPathSegment segment : assignmentPath.getSegments()) { if (!isDelegationAssignment(segment.getAssignment(), relationRegistry)) { return false; } } return true; }
boolean isFull = options.getTriggeredRulesStorageStrategy() == FULL; if (isFull && assignmentPath != null) { rv.setAssignmentPath(assignmentPath.toAssignmentPathType(options.isIncludeAssignmentsContent()));
private ObjectType computeDirectOwner() { if (assignmentPath == null) { return null; } List<ObjectType> roots = assignmentPath.getFirstOrderChain(); return roots.isEmpty() ? null : roots.get(roots.size()-1); }
@Override public ExtensionType collectExtensions(AssignmentPathType path, int startAt) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { return AssignmentPath.collectExtensions(path, startAt, modelService, getCurrentTask(), getCurrentResult()); } @Override
public static List<OtherPrivilegesLimitationType> extractLimitations(AssignmentPath assignmentPath) { List<OtherPrivilegesLimitationType> rv = new ArrayList<>(); for (AssignmentPathSegment segment : assignmentPath.getSegments()) { CollectionUtils.addIgnoreNull(rv, segment.getAssignment().getLimitOtherPrivileges()); } return rv; }
@Override public EvaluatedExclusionTriggerType toEvaluatedPolicyRuleTriggerType(PolicyRuleExternalizationOptions options, PrismContext prismContext) { EvaluatedExclusionTriggerType rv = new EvaluatedExclusionTriggerType(); fillCommonContent(rv); if (options.getTriggeredRulesStorageStrategy() == FULL) { rv.setConflictingObjectRef(ObjectTypeUtil.createObjectRef(conflictingTarget, prismContext)); rv.setConflictingObjectDisplayName(ObjectTypeUtil.getDisplayName(conflictingTarget)); if (conflictingPath != null) { rv.setConflictingObjectPath(conflictingPath.toAssignmentPathType(options.isIncludeAssignmentsContent())); } if (options.isIncludeAssignmentsContent() && conflictingAssignment.getAssignmentType() != null) { rv.setConflictingAssignment(conflictingAssignment.getAssignmentType().clone()); } } return rv; } }
private ObjectType getConflictingObject(AssignmentPath path, PrismObject<?> defaultObject) { if (path == null) { return ObjectTypeUtil.toObjectable(defaultObject); } List<ObjectType> objects = path.getFirstOrderChain(); return objects.isEmpty() ? ObjectTypeUtil.toObjectable(defaultObject) : objects.get(objects.size()-1); }
protected void assertAssignmentPath(AssignmentPath path, String... targetOids) { assertEquals("Wrong path size", targetOids.length, path.size()); for (int i = 0; i < targetOids.length; i++) { ObjectType target = path.getSegments().get(i).getTarget(); if (targetOids[i] == null) { assertNull("Target #" + (i+1) + " should be null; it is: " + target, target); } else { assertNotNull("Target #" + (i+1) + " should not be null", target); assertEquals("Wrong OID in target #" + (i+1), targetOids[i], target.getOid()); } } }
public static ExtensionType collectExtensions(AssignmentPath path, int startAt, PrismContext prismContext) throws SchemaException { ExtensionType rv = new ExtensionType(prismContext); PrismContainerValue<?> pcv = rv.asPrismContainerValue(); for (int i = startAt; i < path.getSegments().size(); i++) { AssignmentPathSegment segment = path.getSegments().get(i); AssignmentType assignment = segment.getAssignmentAny(); if (assignment != null && assignment.getExtension() != null) { ObjectTypeUtil.mergeExtension(pcv, assignment.getExtension().asPrismContainerValue()); } if (segment.getTarget() != null && segment.getTarget().getExtension() != null) { ObjectTypeUtil.mergeExtension(pcv, segment.getTarget().getExtension().asPrismContainerValue()); } } return rv; }
private LocalizableMessage createObjectInfo(AssignmentPath path, PrismObject<?> defaultObject, boolean startsWithUppercase) { if (path == null) { return ObjectTypeUtil.createDisplayInformation(defaultObject, startsWithUppercase); } List<ObjectType> objects = path.getFirstOrderChain(); if (objects.isEmpty()) { // shouldn't occur return ObjectTypeUtil.createDisplayInformation(defaultObject, startsWithUppercase); } PrismObject<?> last = objects.get(objects.size()-1).asPrismObject(); if (objects.size() == 1) { return ObjectTypeUtil.createDisplayInformation(last, startsWithUppercase); } String pathString = objects.stream() .map(o -> PolyString.getOrig(o.getName())) .collect(Collectors.joining(" -> ")); return ObjectTypeUtil.createDisplayInformationWithPath(last, startsWithUppercase, pathString); }
boolean found = ctx.policyRule.getAssignmentPath().getSegments().stream() .anyMatch(segment -> segment.matches(sourceOrderConstraints)); if (!found) {
@Override public String debugDump(int indent) { StringBuilder sb = new StringBuilder(); DebugUtil.debugDumpLabelLn(sb, "EvaluatedPolicyRule " + (getName() != null ? getName() + " " : "") + "(triggers: " + triggers.size() + ")", indent); DebugUtil.debugDumpWithLabelLn(sb, "name", getName(), indent + 1); DebugUtil.debugDumpLabelLn(sb, "policyRuleType", indent + 1); DebugUtil.indentDebugDump(sb, indent + 2); PrismPrettyPrinter.debugDumpValue(sb, indent + 2, policyRuleType, prismContextForDebugDump, PolicyRuleType.COMPLEX_TYPE, PrismContext.LANG_XML); sb.append('\n'); DebugUtil.debugDumpWithLabelLn(sb, "assignmentPath", assignmentPath, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "triggers", triggers, indent + 1); DebugUtil.debugDumpWithLabelLn(sb, "directOwner", ObjectTypeUtil.toShortString(directOwner), indent + 1); DebugUtil.debugDumpWithLabel(sb, "rootObjects", assignmentPath != null ? String.valueOf(assignmentPath.getFirstOrderChain()) : null, indent + 1); return sb.toString(); }