1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
4 import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
6 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
7 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
8 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
9 import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
10 import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
11 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
12 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
13 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
14 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UriReferenceAdapter;
15 import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
16 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
17 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
18 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
19 import java.lang.Override;
20 import java.lang.String;
21 import java.net.URI;
22 import java.util.LinkedList;
23 import java.util.List;
24 import java.util.UUID;
25 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
26 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
27
28
29
30
31 @MetaschemaAssembly(
32 formalName = "Control Implementation Set",
33 description = "Defines how the component or capability supports a set of controls.",
34 name = "control-implementation",
35 metaschema = OscalComponentDefinitionMetaschema.class,
36 remarks = "Use of `set-parameter` in this context, sets the parameter for all controls referenced by any `implemented-requirement` contained in this context. Any `set-parameter` defined in a child context will override this value. If not overridden by a child, this value applies in the child context."
37 )
38 @AssemblyConstraints(
39 isUnique = @IsUnique(id = "unique-component-definition-control-implementation-set-parameter", level = IConstraint.Level.ERROR, target = "set-parameter", keyFields = @KeyField(target = "@param-id"), remarks = "Since multiple `set-parameter` entries can be provided, each parameter must be set only once.")
40 )
41 public class ComponentControlImplementation {
42 @BoundFlag(
43 formalName = "Control Implementation Set Identifier",
44 description = "Provides a means to identify a set of control implementations that are supported by a given component or capability.",
45 useName = "uuid",
46 required = true,
47 typeAdapter = UuidAdapter.class
48 )
49 private UUID _uuid;
50
51 @BoundFlag(
52 formalName = "Source Resource Reference",
53 description = "A reference to an OSCAL catalog or profile providing the referenced control or subcontrol definition.",
54 useName = "source",
55 required = true,
56 typeAdapter = UriReferenceAdapter.class,
57 remarks = "This value may be one of:\n"
58 + "\n"
59 + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n"
60 + "2. a [relative reference](https://pages.nist.gov/OSCAL/concepts/uri-use/#relative-reference) pointing to a network resolvable resource whose base URI is the URI of the containing document, or\n"
61 + "3. a bare URI fragment (i.e., \\`#uuid\\`) pointing to a `back-matter` resource in this or an imported document (see [linking to another OSCAL object](https://pages.nist.gov/OSCAL/concepts/uri-use/#linking-to-another-oscal-object))."
62 )
63 private URI _source;
64
65
66
67
68 @BoundField(
69 formalName = "Control Implementation Description",
70 description = "A description of how the specified set of controls are implemented for the containing component or capability.",
71 useName = "description",
72 minOccurs = 1
73 )
74 @BoundFieldValue(
75 typeAdapter = MarkupMultilineAdapter.class
76 )
77 private MarkupMultiline _description;
78
79 @BoundAssembly(
80 formalName = "Property",
81 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
82 useName = "prop",
83 maxOccurs = -1
84 )
85 @GroupAs(
86 name = "props",
87 inJson = JsonGroupAsBehavior.LIST
88 )
89 private List<Property> _props;
90
91 @BoundAssembly(
92 formalName = "Link",
93 description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
94 useName = "link",
95 maxOccurs = -1
96 )
97 @GroupAs(
98 name = "links",
99 inJson = JsonGroupAsBehavior.LIST
100 )
101 private List<Link> _links;
102
103 @BoundAssembly(
104 formalName = "Set Parameter Value",
105 description = "Identifies the parameter that will be set by the enclosed value.",
106 useName = "set-parameter",
107 maxOccurs = -1
108 )
109 @GroupAs(
110 name = "set-parameters",
111 inJson = JsonGroupAsBehavior.LIST
112 )
113 private List<SetParameter> _setParameters;
114
115 @BoundAssembly(
116 formalName = "Control Implementation",
117 description = "Describes how the containing component or capability implements an individual control.",
118 useName = "implemented-requirement",
119 minOccurs = 1,
120 maxOccurs = -1
121 )
122 @GroupAs(
123 name = "implemented-requirements",
124 inJson = JsonGroupAsBehavior.LIST
125 )
126 private List<ComponentImplementedRequirement> _implementedRequirements;
127
128 public ComponentControlImplementation() {
129 }
130
131 public UUID getUuid() {
132 return _uuid;
133 }
134
135 public void setUuid(UUID value) {
136 _uuid = value;
137 }
138
139 public URI getSource() {
140 return _source;
141 }
142
143 public void setSource(URI value) {
144 _source = value;
145 }
146
147 public MarkupMultiline getDescription() {
148 return _description;
149 }
150
151 public void setDescription(MarkupMultiline value) {
152 _description = value;
153 }
154
155 public List<Property> getProps() {
156 return _props;
157 }
158
159 public void setProps(List<Property> value) {
160 _props = value;
161 }
162
163
164
165
166
167
168 public boolean addProp(Property item) {
169 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
170 if (_props == null) {
171 _props = new LinkedList<>();
172 }
173 return _props.add(value);
174 }
175
176
177
178
179
180
181 public boolean removeProp(Property item) {
182 Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
183 return _props == null ? false : _props.remove(value);
184 }
185
186 public List<Link> getLinks() {
187 return _links;
188 }
189
190 public void setLinks(List<Link> value) {
191 _links = value;
192 }
193
194
195
196
197
198
199 public boolean addLink(Link item) {
200 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
201 if (_links == null) {
202 _links = new LinkedList<>();
203 }
204 return _links.add(value);
205 }
206
207
208
209
210
211
212 public boolean removeLink(Link item) {
213 Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
214 return _links == null ? false : _links.remove(value);
215 }
216
217 public List<SetParameter> getSetParameters() {
218 return _setParameters;
219 }
220
221 public void setSetParameters(List<SetParameter> value) {
222 _setParameters = value;
223 }
224
225
226
227
228
229
230 public boolean addSetParameter(SetParameter item) {
231 SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
232 if (_setParameters == null) {
233 _setParameters = new LinkedList<>();
234 }
235 return _setParameters.add(value);
236 }
237
238
239
240
241
242
243 public boolean removeSetParameter(SetParameter item) {
244 SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
245 return _setParameters == null ? false : _setParameters.remove(value);
246 }
247
248 public List<ComponentImplementedRequirement> getImplementedRequirements() {
249 return _implementedRequirements;
250 }
251
252 public void setImplementedRequirements(List<ComponentImplementedRequirement> value) {
253 _implementedRequirements = value;
254 }
255
256
257
258
259
260
261 public boolean addImplementedRequirement(ComponentImplementedRequirement item) {
262 ComponentImplementedRequirement value = ObjectUtils.requireNonNull(item,"item cannot be null");
263 if (_implementedRequirements == null) {
264 _implementedRequirements = new LinkedList<>();
265 }
266 return _implementedRequirements.add(value);
267 }
268
269
270
271
272
273
274 public boolean removeImplementedRequirement(ComponentImplementedRequirement item) {
275 ComponentImplementedRequirement value = ObjectUtils.requireNonNull(item,"item cannot be null");
276 return _implementedRequirements == null ? false : _implementedRequirements.remove(value);
277 }
278
279 @Override
280 public String toString() {
281 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
282 }
283 }