View Javadoc
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.TokenAdapter;
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.util.LinkedList;
22  import java.util.List;
23  import java.util.UUID;
24  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
25  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
26  
27  /**
28   * Describes how the containing component or capability implements an individual control.
29   */
30  @MetaschemaAssembly(
31      formalName = "Control Implementation",
32      description = "Describes how the containing component or capability implements an individual control.",
33      name = "implemented-requirement",
34      metaschema = OscalComponentDefinitionMetaschema.class,
35      remarks = "Implemented requirements within a component or capability in a component definition provide a means for component suppliers to suggest possible control implementation details, which may be used by a different party (e.g., component consumers) when authoring a system security plan. Thus, these requirements defined in a component definition are only a suggestion of how to implement, which may be adopted wholesale, changed, or ignored by a person defining an information system implementation.\n"
36              + "\n"
37              + "Use of `set-parameter` in this context, sets the parameter for the referenced control and any associated statements."
38  )
39  @AssemblyConstraints(
40      isUnique = {
41          @IsUnique(id = "unique-component-definition-implemented-requirement-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."),
42          @IsUnique(id = "unique-component-definition-implemented-requirement-responsible-role", level = IConstraint.Level.ERROR, target = "responsible-role", keyFields = @KeyField(target = "@role-id"), remarks = "Since `responsible-role` associates multiple `party-uuid` entries with a single `role-id`, each role-id must be referenced only once."),
43          @IsUnique(id = "unique-component-definition-implemented-requirement-statement", level = IConstraint.Level.ERROR, target = "statement", keyFields = @KeyField(target = "@statement-id"), remarks = "Since `statement` entries can be referenced using the statement's statement-id, each statement must be referenced only once.")
44      }
45  )
46  public class ComponentImplementedRequirement {
47    @BoundFlag(
48        formalName = "Control Implementation Identifier",
49        description = "Provides a globally unique means to identify a given control implementation by a component.",
50        useName = "uuid",
51        required = true,
52        typeAdapter = UuidAdapter.class
53    )
54    private UUID _uuid;
55  
56    @BoundFlag(
57        formalName = "Control Identifier Reference",
58        description = "A reference to a control with a corresponding `id` value. When referencing an externally defined `control`, the `Control Identifier Reference` must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).",
59        useName = "control-id",
60        required = true,
61        typeAdapter = TokenAdapter.class
62    )
63    private String _controlId;
64  
65    /**
66     * "A suggestion from the supplier (e.g., component vendor or author) for how the specified control may be implemented if the containing component or capability is instantiated in a system security plan."
67     */
68    @BoundField(
69        formalName = "Control Implementation Description",
70        description = "A suggestion from the supplier (e.g., component vendor or author) for how the specified control may be implemented if the containing component or capability is instantiated in a system security plan.",
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 = "Responsible Role",
117       description = "A reference to a role with responsibility for performing a function relative to the containing object, optionally associated with a set of persons and/or organizations that perform that role.",
118       useName = "responsible-role",
119       maxOccurs = -1
120   )
121   @GroupAs(
122       name = "responsible-roles",
123       inJson = JsonGroupAsBehavior.LIST
124   )
125   private List<ResponsibleRole> _responsibleRoles;
126 
127   @BoundAssembly(
128       formalName = "Control Statement Implementation",
129       description = "Identifies which statements within a control are addressed.",
130       useName = "statement",
131       maxOccurs = -1
132   )
133   @GroupAs(
134       name = "statements",
135       inJson = JsonGroupAsBehavior.LIST
136   )
137   private List<ComponentStatement> _statements;
138 
139   @BoundField(
140       formalName = "Remarks",
141       description = "Additional commentary about the containing object.",
142       useName = "remarks"
143   )
144   @BoundFieldValue(
145       typeAdapter = MarkupMultilineAdapter.class
146   )
147   private MarkupMultiline _remarks;
148 
149   public ComponentImplementedRequirement() {
150   }
151 
152   public UUID getUuid() {
153     return _uuid;
154   }
155 
156   public void setUuid(UUID value) {
157     _uuid = value;
158   }
159 
160   public String getControlId() {
161     return _controlId;
162   }
163 
164   public void setControlId(String value) {
165     _controlId = value;
166   }
167 
168   public MarkupMultiline getDescription() {
169     return _description;
170   }
171 
172   public void setDescription(MarkupMultiline value) {
173     _description = value;
174   }
175 
176   public List<Property> getProps() {
177     return _props;
178   }
179 
180   public void setProps(List<Property> value) {
181     _props = value;
182   }
183 
184   /**
185    * Add a new {@link Property} item to the underlying collection.
186    * @param item the item to add
187    * @return {@code true}
188    */
189   public boolean addProp(Property item) {
190     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
191     if (_props == null) {
192       _props = new LinkedList<>();
193     }
194     return _props.add(value);
195   }
196 
197   /**
198    * Remove the first matching {@link Property} item from the underlying collection.
199    * @param item the item to remove
200    * @return {@code true} if the item was removed or {@code false} otherwise
201    */
202   public boolean removeProp(Property item) {
203     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
204     return _props == null ? false : _props.remove(value);
205   }
206 
207   public List<Link> getLinks() {
208     return _links;
209   }
210 
211   public void setLinks(List<Link> value) {
212     _links = value;
213   }
214 
215   /**
216    * Add a new {@link Link} item to the underlying collection.
217    * @param item the item to add
218    * @return {@code true}
219    */
220   public boolean addLink(Link item) {
221     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
222     if (_links == null) {
223       _links = new LinkedList<>();
224     }
225     return _links.add(value);
226   }
227 
228   /**
229    * Remove the first matching {@link Link} item from the underlying collection.
230    * @param item the item to remove
231    * @return {@code true} if the item was removed or {@code false} otherwise
232    */
233   public boolean removeLink(Link item) {
234     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
235     return _links == null ? false : _links.remove(value);
236   }
237 
238   public List<SetParameter> getSetParameters() {
239     return _setParameters;
240   }
241 
242   public void setSetParameters(List<SetParameter> value) {
243     _setParameters = value;
244   }
245 
246   /**
247    * Add a new {@link SetParameter} item to the underlying collection.
248    * @param item the item to add
249    * @return {@code true}
250    */
251   public boolean addSetParameter(SetParameter item) {
252     SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
253     if (_setParameters == null) {
254       _setParameters = new LinkedList<>();
255     }
256     return _setParameters.add(value);
257   }
258 
259   /**
260    * Remove the first matching {@link SetParameter} item from the underlying collection.
261    * @param item the item to remove
262    * @return {@code true} if the item was removed or {@code false} otherwise
263    */
264   public boolean removeSetParameter(SetParameter item) {
265     SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
266     return _setParameters == null ? false : _setParameters.remove(value);
267   }
268 
269   public List<ResponsibleRole> getResponsibleRoles() {
270     return _responsibleRoles;
271   }
272 
273   public void setResponsibleRoles(List<ResponsibleRole> value) {
274     _responsibleRoles = value;
275   }
276 
277   /**
278    * Add a new {@link ResponsibleRole} item to the underlying collection.
279    * @param item the item to add
280    * @return {@code true}
281    */
282   public boolean addResponsibleRole(ResponsibleRole item) {
283     ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null");
284     if (_responsibleRoles == null) {
285       _responsibleRoles = new LinkedList<>();
286     }
287     return _responsibleRoles.add(value);
288   }
289 
290   /**
291    * Remove the first matching {@link ResponsibleRole} item from the underlying collection.
292    * @param item the item to remove
293    * @return {@code true} if the item was removed or {@code false} otherwise
294    */
295   public boolean removeResponsibleRole(ResponsibleRole item) {
296     ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null");
297     return _responsibleRoles == null ? false : _responsibleRoles.remove(value);
298   }
299 
300   public List<ComponentStatement> getStatements() {
301     return _statements;
302   }
303 
304   public void setStatements(List<ComponentStatement> value) {
305     _statements = value;
306   }
307 
308   /**
309    * Add a new {@link ComponentStatement} item to the underlying collection.
310    * @param item the item to add
311    * @return {@code true}
312    */
313   public boolean addStatement(ComponentStatement item) {
314     ComponentStatement value = ObjectUtils.requireNonNull(item,"item cannot be null");
315     if (_statements == null) {
316       _statements = new LinkedList<>();
317     }
318     return _statements.add(value);
319   }
320 
321   /**
322    * Remove the first matching {@link ComponentStatement} item from the underlying collection.
323    * @param item the item to remove
324    * @return {@code true} if the item was removed or {@code false} otherwise
325    */
326   public boolean removeStatement(ComponentStatement item) {
327     ComponentStatement value = ObjectUtils.requireNonNull(item,"item cannot be null");
328     return _statements == null ? false : _statements.remove(value);
329   }
330 
331   public MarkupMultiline getRemarks() {
332     return _remarks;
333   }
334 
335   public void setRemarks(MarkupMultiline value) {
336     _remarks = value;
337   }
338 
339   @Override
340   public String toString() {
341     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
342   }
343 }