diff --git a/src/main/java/dev/metaschema/oscal/lib/model/control/profile/AbstractProfileSelectControlById.java b/src/main/java/dev/metaschema/oscal/lib/model/control/AbstractControlCommonSelectControlById.java similarity index 81% rename from src/main/java/dev/metaschema/oscal/lib/model/control/profile/AbstractProfileSelectControlById.java rename to src/main/java/dev/metaschema/oscal/lib/model/control/AbstractControlCommonSelectControlById.java index 76f5c74e..21beb221 100644 --- a/src/main/java/dev/metaschema/oscal/lib/model/control/profile/AbstractProfileSelectControlById.java +++ b/src/main/java/dev/metaschema/oscal/lib/model/control/AbstractControlCommonSelectControlById.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: CC0-1.0 */ -package dev.metaschema.oscal.lib.model.control.profile; +package dev.metaschema.oscal.lib.model.control; import java.util.Collection; import java.util.LinkedList; @@ -11,11 +11,11 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import dev.metaschema.oscal.lib.model.ControlCommonSelectControlById; import dev.metaschema.oscal.lib.model.ProfileMatching; -import dev.metaschema.oscal.lib.model.ProfileSelectControlById; import edu.umd.cs.findbugs.annotations.NonNull; -public abstract class AbstractProfileSelectControlById implements IProfileSelectControlById { +public abstract class AbstractControlCommonSelectControlById implements IControlCommonSelectControlById { // TODO: move implementation from profile resolver selection code here @NonNull @@ -53,8 +53,8 @@ public Builder matching(@NonNull Pattern pattern) { } @NonNull - public ProfileSelectControlById build() { - ProfileSelectControlById retval = new ProfileSelectControlById(); + public ControlCommonSelectControlById build() { + ControlCommonSelectControlById retval = new ControlCommonSelectControlById(); retval.setWithChildControls(withChildControls ? "yes" : "no"); retval.setWithIds(withIds); retval.setMatching(matching.stream() diff --git a/src/main/java/dev/metaschema/oscal/lib/model/control/AbstractControlMatching.java b/src/main/java/dev/metaschema/oscal/lib/model/control/AbstractControlMatching.java new file mode 100644 index 00000000..a52b4028 --- /dev/null +++ b/src/main/java/dev/metaschema/oscal/lib/model/control/AbstractControlMatching.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package dev.metaschema.oscal.lib.model.control; + +public abstract class AbstractControlMatching implements IControlMatching { + protected AbstractControlMatching() { + // base class for generated matching bindings + } +} diff --git a/src/main/java/dev/metaschema/oscal/lib/model/control/profile/IProfileSelectControlById.java b/src/main/java/dev/metaschema/oscal/lib/model/control/IControlCommonSelectControlById.java similarity index 54% rename from src/main/java/dev/metaschema/oscal/lib/model/control/profile/IProfileSelectControlById.java rename to src/main/java/dev/metaschema/oscal/lib/model/control/IControlCommonSelectControlById.java index be598dfb..bb65a99c 100644 --- a/src/main/java/dev/metaschema/oscal/lib/model/control/profile/IProfileSelectControlById.java +++ b/src/main/java/dev/metaschema/oscal/lib/model/control/IControlCommonSelectControlById.java @@ -3,18 +3,15 @@ * SPDX-License-Identifier: CC0-1.0 */ -package dev.metaschema.oscal.lib.model.control.profile; +package dev.metaschema.oscal.lib.model.control; import java.util.List; import dev.metaschema.oscal.lib.model.ProfileMatching; -public interface IProfileSelectControlById { - - String getWithChildControls(); - - List getWithIds(); +public interface IControlCommonSelectControlById extends IControlSelection { + @Override List getMatching(); } diff --git a/src/main/java/dev/metaschema/oscal/lib/model/control/IControlMatching.java b/src/main/java/dev/metaschema/oscal/lib/model/control/IControlMatching.java new file mode 100644 index 00000000..b798b50c --- /dev/null +++ b/src/main/java/dev/metaschema/oscal/lib/model/control/IControlMatching.java @@ -0,0 +1,13 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package dev.metaschema.oscal.lib.model.control; + +@SuppressWarnings("PMD.ImplicitFunctionalInterface") +public interface IControlMatching { + + String getPattern(); + +} diff --git a/src/main/java/dev/metaschema/oscal/lib/model/control/IControlSelection.java b/src/main/java/dev/metaschema/oscal/lib/model/control/IControlSelection.java new file mode 100644 index 00000000..2dab7c46 --- /dev/null +++ b/src/main/java/dev/metaschema/oscal/lib/model/control/IControlSelection.java @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: none + * SPDX-License-Identifier: CC0-1.0 + */ + +package dev.metaschema.oscal.lib.model.control; + +import java.util.List; + +public interface IControlSelection { + + String getWithChildControls(); + + List getWithIds(); + + List getMatching(); + +} diff --git a/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilter.java b/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilter.java index 9649cca6..608d9b67 100644 --- a/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilter.java +++ b/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilter.java @@ -18,8 +18,8 @@ import dev.metaschema.core.util.ObjectUtils; import dev.metaschema.oscal.lib.model.ProfileMatching; +import dev.metaschema.oscal.lib.model.control.IControlCommonSelectControlById; import dev.metaschema.oscal.lib.model.control.catalog.IControl; -import dev.metaschema.oscal.lib.model.control.profile.IProfileSelectControlById; import dev.metaschema.oscal.lib.profile.resolver.ProfileResolutionEvaluationException; import edu.umd.cs.findbugs.annotations.NonNull; @@ -37,7 +37,7 @@ public class DefaultControlSelectionFilter implements IControlSelectionFilter { * a list of select criteria */ @SuppressWarnings("null") - public DefaultControlSelectionFilter(@NonNull List selections) { + public DefaultControlSelectionFilter(@NonNull List selections) { this.selections = selections.stream() // ignore null entries .filter(Objects::nonNull) @@ -132,7 +132,7 @@ private static class Selection { private final Set identifiers; private final List patterns; - public Selection(IProfileSelectControlById selection) { + public Selection(IControlCommonSelectControlById selection) { // process with-child-controls // default is "no" this.withChildControls = "yes".equals(selection.getWithChildControls()); diff --git a/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/IControlFilter.java b/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/IControlFilter.java index c9fcfba8..0f0f669f 100644 --- a/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/IControlFilter.java +++ b/src/main/java/dev/metaschema/oscal/lib/profile/resolver/selection/IControlFilter.java @@ -12,8 +12,8 @@ import dev.metaschema.core.util.ObjectUtils; import dev.metaschema.oscal.lib.model.IncludeAll; import dev.metaschema.oscal.lib.model.ProfileImport; +import dev.metaschema.oscal.lib.model.control.IControlCommonSelectControlById; import dev.metaschema.oscal.lib.model.control.catalog.IControl; -import dev.metaschema.oscal.lib.model.control.profile.IProfileSelectControlById; import edu.umd.cs.findbugs.annotations.NonNull; public interface IControlFilter { @@ -127,7 +127,7 @@ public Filter(@NonNull ProfileImport profileImport) { IncludeAll includeAll = profileImport.getIncludeAll(); if (includeAll == null) { - List includeSelections = profileImport.getIncludeControls(); + List includeSelections = profileImport.getIncludeControls(); if (includeSelections.isEmpty()) { this.inclusionFilter = IControlSelectionFilter.NONE_MATCH; } else { @@ -137,7 +137,7 @@ public Filter(@NonNull ProfileImport profileImport) { this.inclusionFilter = IControlSelectionFilter.ALL_MATCH; } - List excludeSelections = profileImport.getExcludeControls(); + List excludeSelections = profileImport.getExcludeControls(); if (excludeSelections.isEmpty()) { this.exclusionFilter = IControlSelectionFilter.NONE_MATCH; } else { diff --git a/src/main/metaschema-bindings/oscal-metaschema-bindings.xml b/src/main/metaschema-bindings/oscal-metaschema-bindings.xml index 86314b9b..ff24a600 100644 --- a/src/main/metaschema-bindings/oscal-metaschema-bindings.xml +++ b/src/main/metaschema-bindings/oscal-metaschema-bindings.xml @@ -58,13 +58,14 @@ - ProfileSelectControlById - dev.metaschema.oscal.lib.model.control.profile.AbstractProfileSelectControlById + ControlCommonSelectControlById + dev.metaschema.oscal.lib.model.control.AbstractControlCommonSelectControlById ProfileMatching + dev.metaschema.oscal.lib.model.control.AbstractControlMatching @@ -158,6 +159,14 @@ + + + + AssessmentCommonSelectControlById + + + diff --git a/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilterTest.java b/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilterTest.java index 321c67ed..82857c52 100644 --- a/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilterTest.java +++ b/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/DefaultControlSelectionFilterTest.java @@ -21,8 +21,8 @@ import dev.metaschema.core.util.ObjectUtils; import dev.metaschema.oscal.lib.model.ProfileMatching; +import dev.metaschema.oscal.lib.model.control.IControlCommonSelectControlById; import dev.metaschema.oscal.lib.model.control.catalog.IControl; -import dev.metaschema.oscal.lib.model.control.profile.IProfileSelectControlById; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -35,13 +35,13 @@ class DefaultControlSelectionFilterTest { }; @Mock - private IProfileSelectControlById selectControlByIdA; + private IControlCommonSelectControlById selectControlByIdA; @Mock private ProfileMatching matchingA; @Mock private ProfileMatching matchingB; @Mock - private IProfileSelectControlById selectControlByIdB; + private IControlCommonSelectControlById selectControlByIdB; @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") @NonNull diff --git a/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/ImportTest.java b/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/ImportTest.java index 8edf53d3..1ed434cb 100644 --- a/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/ImportTest.java +++ b/src/test/java/dev/metaschema/oscal/lib/profile/resolver/selection/ImportTest.java @@ -24,8 +24,8 @@ import dev.metaschema.oscal.lib.model.IncludeAll; import dev.metaschema.oscal.lib.model.Profile; import dev.metaschema.oscal.lib.model.ProfileImport; +import dev.metaschema.oscal.lib.model.control.AbstractControlCommonSelectControlById; import dev.metaschema.oscal.lib.model.control.catalog.AbstractControl; -import dev.metaschema.oscal.lib.model.control.profile.AbstractProfileSelectControlById; import dev.metaschema.oscal.lib.profile.resolver.ProfileResolutionException; import edu.umd.cs.findbugs.annotations.NonNull; @@ -59,7 +59,7 @@ void test() throws ProfileResolutionException { ProfileImport profileImport = new ProfileImport(); profileImport.setIncludeAll(new IncludeAll()); profileImport.setExcludeControls(Collections.singletonList( - AbstractProfileSelectControlById.builder() + AbstractControlCommonSelectControlById.builder() .withId("control1") .build())); profileImport.setHref(cwd);