001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
007import gov.nist.secauto.metaschema.core.model.IBoundObject;
008import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
009import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
010import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
011import gov.nist.secauto.metaschema.core.util.ObjectUtils;
012import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints;
013import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
014import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
015import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
016import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
017import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique;
018import gov.nist.secauto.metaschema.databind.model.annotations.KeyField;
019import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
020import java.lang.Override;
021import java.lang.String;
022import java.util.LinkedList;
023import java.util.List;
024import java.util.UUID;
025import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
026import org.apache.commons.lang3.builder.ToStringStyle;
027
028/**
029 * Describes how the containing component or capability implements an individual control.
030 */
031@MetaschemaAssembly(
032    formalName = "Control Implementation",
033    description = "Describes how the containing component or capability implements an individual control.",
034    name = "implemented-requirement",
035    moduleClass = OscalComponentDefinitionModule.class,
036    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"
037            + "\n"
038            + "Use of `set-parameter` in this context, sets the parameter for the referenced control and any associated statements.",
039    modelConstraints = @AssemblyConstraints(unique = {@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."), @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."), @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.")})
040)
041public class ComponentImplementedRequirement implements IBoundObject {
042  private final IMetaschemaData __metaschemaData;
043
044  /**
045   * "Provides a globally unique means to identify a given control implementation by a component."
046   */
047  @BoundFlag(
048      formalName = "Control Implementation Identifier",
049      description = "Provides a globally unique means to identify a given control implementation by a component.",
050      name = "uuid",
051      required = true,
052      typeAdapter = UuidAdapter.class
053  )
054  private UUID _uuid;
055
056  /**
057   * "A reference to a control with a corresponding <code>id</code> value. When referencing an externally defined <code>control</code>, the <code>Control Identifier Reference</code> must be used in the context of the external / imported OSCAL instance (e.g., uri-reference)."
058   */
059  @BoundFlag(
060      formalName = "Control Identifier Reference",
061      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).",
062      name = "control-id",
063      required = true,
064      typeAdapter = TokenAdapter.class
065  )
066  private String _controlId;
067
068  @BoundField(
069      formalName = "Control Implementation Description",
070      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.",
071      useName = "description",
072      minOccurs = 1,
073      typeAdapter = MarkupMultilineAdapter.class
074  )
075  private MarkupMultiline _description;
076
077  @BoundAssembly(
078      formalName = "Property",
079      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
080      useName = "prop",
081      maxOccurs = -1,
082      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
083  )
084  private List<Property> _props;
085
086  @BoundAssembly(
087      formalName = "Link",
088      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
089      useName = "link",
090      maxOccurs = -1,
091      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
092  )
093  private List<Link> _links;
094
095  @BoundAssembly(
096      formalName = "Set Parameter Value",
097      description = "Identifies the parameter that will be set by the enclosed value.",
098      useName = "set-parameter",
099      maxOccurs = -1,
100      groupAs = @GroupAs(name = "set-parameters", inJson = JsonGroupAsBehavior.LIST)
101  )
102  private List<SetParameter> _setParameters;
103
104  @BoundAssembly(
105      formalName = "Responsible Role",
106      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.",
107      useName = "responsible-role",
108      maxOccurs = -1,
109      groupAs = @GroupAs(name = "responsible-roles", inJson = JsonGroupAsBehavior.LIST)
110  )
111  private List<ResponsibleRole> _responsibleRoles;
112
113  @BoundAssembly(
114      formalName = "Control Statement Implementation",
115      description = "Identifies which statements within a control are addressed.",
116      useName = "statement",
117      maxOccurs = -1,
118      groupAs = @GroupAs(name = "statements", inJson = JsonGroupAsBehavior.LIST)
119  )
120  private List<ComponentStatement> _statements;
121
122  @BoundField(
123      formalName = "Remarks",
124      description = "Additional commentary about the containing object.",
125      useName = "remarks",
126      typeAdapter = MarkupMultilineAdapter.class
127  )
128  private MarkupMultiline _remarks;
129
130  public ComponentImplementedRequirement() {
131    this(null);
132  }
133
134  public ComponentImplementedRequirement(IMetaschemaData data) {
135    this.__metaschemaData = data;
136  }
137
138  @Override
139  public IMetaschemaData getMetaschemaData() {
140    return __metaschemaData;
141  }
142
143  public UUID getUuid() {
144    return _uuid;
145  }
146
147  public void setUuid(UUID value) {
148    _uuid = value;
149  }
150
151  public String getControlId() {
152    return _controlId;
153  }
154
155  public void setControlId(String value) {
156    _controlId = value;
157  }
158
159  public MarkupMultiline getDescription() {
160    return _description;
161  }
162
163  public void setDescription(MarkupMultiline value) {
164    _description = value;
165  }
166
167  public List<Property> getProps() {
168    return _props;
169  }
170
171  public void setProps(List<Property> value) {
172    _props = value;
173  }
174
175  /**
176   * Add a new {@link Property} item to the underlying collection.
177   * @param item the item to add
178   * @return {@code true}
179   */
180  public boolean addProp(Property item) {
181    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
182    if (_props == null) {
183      _props = new LinkedList<>();
184    }
185    return _props.add(value);
186  }
187
188  /**
189   * Remove the first matching {@link Property} item from the underlying collection.
190   * @param item the item to remove
191   * @return {@code true} if the item was removed or {@code false} otherwise
192   */
193  public boolean removeProp(Property item) {
194    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
195    return _props != null && _props.remove(value);
196  }
197
198  public List<Link> getLinks() {
199    return _links;
200  }
201
202  public void setLinks(List<Link> value) {
203    _links = value;
204  }
205
206  /**
207   * Add a new {@link Link} item to the underlying collection.
208   * @param item the item to add
209   * @return {@code true}
210   */
211  public boolean addLink(Link item) {
212    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
213    if (_links == null) {
214      _links = new LinkedList<>();
215    }
216    return _links.add(value);
217  }
218
219  /**
220   * Remove the first matching {@link Link} item from the underlying collection.
221   * @param item the item to remove
222   * @return {@code true} if the item was removed or {@code false} otherwise
223   */
224  public boolean removeLink(Link item) {
225    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
226    return _links != null && _links.remove(value);
227  }
228
229  public List<SetParameter> getSetParameters() {
230    return _setParameters;
231  }
232
233  public void setSetParameters(List<SetParameter> value) {
234    _setParameters = value;
235  }
236
237  /**
238   * Add a new {@link SetParameter} item to the underlying collection.
239   * @param item the item to add
240   * @return {@code true}
241   */
242  public boolean addSetParameter(SetParameter item) {
243    SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
244    if (_setParameters == null) {
245      _setParameters = new LinkedList<>();
246    }
247    return _setParameters.add(value);
248  }
249
250  /**
251   * Remove the first matching {@link SetParameter} item from the underlying collection.
252   * @param item the item to remove
253   * @return {@code true} if the item was removed or {@code false} otherwise
254   */
255  public boolean removeSetParameter(SetParameter item) {
256    SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
257    return _setParameters != null && _setParameters.remove(value);
258  }
259
260  public List<ResponsibleRole> getResponsibleRoles() {
261    return _responsibleRoles;
262  }
263
264  public void setResponsibleRoles(List<ResponsibleRole> value) {
265    _responsibleRoles = value;
266  }
267
268  /**
269   * Add a new {@link ResponsibleRole} item to the underlying collection.
270   * @param item the item to add
271   * @return {@code true}
272   */
273  public boolean addResponsibleRole(ResponsibleRole item) {
274    ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null");
275    if (_responsibleRoles == null) {
276      _responsibleRoles = new LinkedList<>();
277    }
278    return _responsibleRoles.add(value);
279  }
280
281  /**
282   * Remove the first matching {@link ResponsibleRole} item from the underlying collection.
283   * @param item the item to remove
284   * @return {@code true} if the item was removed or {@code false} otherwise
285   */
286  public boolean removeResponsibleRole(ResponsibleRole item) {
287    ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null");
288    return _responsibleRoles != null && _responsibleRoles.remove(value);
289  }
290
291  public List<ComponentStatement> getStatements() {
292    return _statements;
293  }
294
295  public void setStatements(List<ComponentStatement> value) {
296    _statements = value;
297  }
298
299  /**
300   * Add a new {@link ComponentStatement} item to the underlying collection.
301   * @param item the item to add
302   * @return {@code true}
303   */
304  public boolean addStatement(ComponentStatement item) {
305    ComponentStatement value = ObjectUtils.requireNonNull(item,"item cannot be null");
306    if (_statements == null) {
307      _statements = new LinkedList<>();
308    }
309    return _statements.add(value);
310  }
311
312  /**
313   * Remove the first matching {@link ComponentStatement} item from the underlying collection.
314   * @param item the item to remove
315   * @return {@code true} if the item was removed or {@code false} otherwise
316   */
317  public boolean removeStatement(ComponentStatement item) {
318    ComponentStatement value = ObjectUtils.requireNonNull(item,"item cannot be null");
319    return _statements != null && _statements.remove(value);
320  }
321
322  public MarkupMultiline getRemarks() {
323    return _remarks;
324  }
325
326  public void setRemarks(MarkupMultiline value) {
327    _remarks = value;
328  }
329
330  @Override
331  public String toString() {
332    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
333  }
334}