001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.DateAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.UriAdapter;
005import gov.nist.secauto.metaschema.core.datatype.adapter.UriReferenceAdapter;
006import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
007import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
008import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
009import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline;
010import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter;
011import gov.nist.secauto.metaschema.core.datatype.object.AmbiguousDate;
012import gov.nist.secauto.metaschema.core.model.IBoundObject;
013import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
014import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
015import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
016import gov.nist.secauto.metaschema.core.util.ObjectUtils;
017import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
018import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
019import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints;
020import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
021import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
022import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
023import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
024import gov.nist.secauto.metaschema.databind.model.annotations.Index;
025import gov.nist.secauto.metaschema.databind.model.annotations.IndexHasKey;
026import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique;
027import gov.nist.secauto.metaschema.databind.model.annotations.KeyField;
028import gov.nist.secauto.metaschema.databind.model.annotations.Matches;
029import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
030import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
031import java.lang.Override;
032import java.lang.String;
033import java.util.LinkedList;
034import java.util.List;
035import java.util.UUID;
036import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
037import org.apache.commons.lang3.builder.ToStringStyle;
038
039/**
040 * Provides information as to how the system is implemented.
041 */
042@MetaschemaAssembly(
043    formalName = "System Implementation",
044    description = "Provides information as to how the system is implemented.",
045    name = "system-implementation",
046    moduleClass = OscalSspModule.class,
047    valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-component-inventory-item-allows-authenticated-scan-values", level = IConstraint.Level.ERROR, target = "(component | inventory-item)/prop[has-oscal-namespace('http://csrc.nist.gov/ns/oscal') and @name='allows-authenticated-scan']/@value", values = {@AllowedValue(value = "yes", description = "The component allows an authenticated scan."), @AllowedValue(value = "no", description = "The component does not allow an authenticated scan.")}), indexHasKey = {@IndexHasKey(id = "oscal-system-implementation-component-prop-leveraged-authorization-uuid-index", level = IConstraint.Level.ERROR, target = "component/prop[@name='leveraged-authorization-uuid']", indexName = "index-system-implementation-leveraged-authorization-uuid", keyFields = @KeyField(target = "@value")), @IndexHasKey(id = "oscal-system-implementation-component-depends-on-link-index", level = IConstraint.Level.ERROR, target = "component/link[@rel='depends-on']", indexName = "index-system-implementation-component-uuid", keyFields = @KeyField(target = "@href")), @IndexHasKey(id = "oscal-system-implementation-validated-by-index", level = IConstraint.Level.ERROR, target = "component/link[@rel='validated-by']", indexName = "index-system-implementation-component-uuid-validation", keyFields = @KeyField(target = "@href")), @IndexHasKey(id = "oscal-system-implementation-proof-of-compliance-index", level = IConstraint.Level.ERROR, target = "component/link[@rel='proof-of-compliance']", indexName = "index-system-implementation-component-uuid-validation", keyFields = @KeyField(target = "@href")), @IndexHasKey(id = "oscal-index-system-implementation-component-uuid-service", level = IConstraint.Level.ERROR, target = "component/link[@rel='uses-service']", indexName = "index-system-implementation-component-uuid-service", keyFields = @KeyField(target = "@href"))}),
048    modelConstraints = @AssemblyConstraints(index = {@Index(id = "oscal-system-implementation-component-leveraged-authorization-uuid-index", level = IConstraint.Level.ERROR, target = "leveraged-authorization", name = "index-system-implementation-leveraged-authorization-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-system-implementation-component-uuid-index", level = IConstraint.Level.ERROR, target = "component", name = "index-system-implementation-component-uuid", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-system-implementation-component-validation-uuid-index", level = IConstraint.Level.ERROR, target = "component[@type='validation']", name = "index-system-implementation-component-uuid-validation", keyFields = @KeyField(target = "@uuid")), @Index(id = "oscal-index-system-implementation-component-uuid-service", level = IConstraint.Level.ERROR, target = "component[@type='service']", name = "index-system-implementation-component-uuid-service", keyFields = @KeyField(target = "@uuid"))}, unique = @IsUnique(id = "oscal-unique-ssp-system-implementation-user", level = IConstraint.Level.ERROR, target = "user", keyFields = @KeyField(target = "@uuid"), remarks = "A given `uuid` must be assigned only once to a user."))
049)
050public class SystemImplementation implements IBoundObject {
051  private final IMetaschemaData __metaschemaData;
052
053  @BoundAssembly(
054      formalName = "Property",
055      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
056      useName = "prop",
057      maxOccurs = -1,
058      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
059  )
060  private List<Property> _props;
061
062  @BoundAssembly(
063      formalName = "Link",
064      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
065      useName = "link",
066      maxOccurs = -1,
067      groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
068  )
069  private List<Link> _links;
070
071  @BoundAssembly(
072      formalName = "Leveraged Authorization",
073      description = "A description of another authorized system from which this system inherits capabilities that satisfy security requirements. Another term for this concept is a *common control provider*.",
074      useName = "leveraged-authorization",
075      maxOccurs = -1,
076      groupAs = @GroupAs(name = "leveraged-authorizations", inJson = JsonGroupAsBehavior.LIST)
077  )
078  private List<LeveragedAuthorization> _leveragedAuthorizations;
079
080  @BoundAssembly(
081      formalName = "System User",
082      description = "A type of user that interacts with the system based on an associated role.",
083      useName = "user",
084      maxOccurs = -1,
085      groupAs = @GroupAs(name = "users", inJson = JsonGroupAsBehavior.LIST)
086  )
087  private List<SystemUser> _users;
088
089  @BoundAssembly(
090      formalName = "Component",
091      description = "A defined component that can be part of an implemented system.",
092      useName = "component",
093      minOccurs = 1,
094      maxOccurs = -1,
095      groupAs = @GroupAs(name = "components", inJson = JsonGroupAsBehavior.LIST)
096  )
097  private List<SystemComponent> _components;
098
099  @BoundAssembly(
100      formalName = "Inventory Item",
101      description = "A single managed inventory item within the system.",
102      useName = "inventory-item",
103      remarks = "A set of `inventory-item` entries that represent the managed inventory instances of the system.",
104      maxOccurs = -1,
105      groupAs = @GroupAs(name = "inventory-items", inJson = JsonGroupAsBehavior.LIST)
106  )
107  private List<InventoryItem> _inventoryItems;
108
109  @BoundField(
110      formalName = "Remarks",
111      description = "Additional commentary about the containing object.",
112      useName = "remarks",
113      typeAdapter = MarkupMultilineAdapter.class
114  )
115  private MarkupMultiline _remarks;
116
117  public SystemImplementation() {
118    this(null);
119  }
120
121  public SystemImplementation(IMetaschemaData data) {
122    this.__metaschemaData = data;
123  }
124
125  @Override
126  public IMetaschemaData getMetaschemaData() {
127    return __metaschemaData;
128  }
129
130  public List<Property> getProps() {
131    return _props;
132  }
133
134  public void setProps(List<Property> value) {
135    _props = value;
136  }
137
138  /**
139   * Add a new {@link Property} item to the underlying collection.
140   * @param item the item to add
141   * @return {@code true}
142   */
143  public boolean addProp(Property item) {
144    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
145    if (_props == null) {
146      _props = new LinkedList<>();
147    }
148    return _props.add(value);
149  }
150
151  /**
152   * Remove the first matching {@link Property} item from the underlying collection.
153   * @param item the item to remove
154   * @return {@code true} if the item was removed or {@code false} otherwise
155   */
156  public boolean removeProp(Property item) {
157    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
158    return _props != null && _props.remove(value);
159  }
160
161  public List<Link> getLinks() {
162    return _links;
163  }
164
165  public void setLinks(List<Link> value) {
166    _links = value;
167  }
168
169  /**
170   * Add a new {@link Link} item to the underlying collection.
171   * @param item the item to add
172   * @return {@code true}
173   */
174  public boolean addLink(Link item) {
175    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
176    if (_links == null) {
177      _links = new LinkedList<>();
178    }
179    return _links.add(value);
180  }
181
182  /**
183   * Remove the first matching {@link Link} item from the underlying collection.
184   * @param item the item to remove
185   * @return {@code true} if the item was removed or {@code false} otherwise
186   */
187  public boolean removeLink(Link item) {
188    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
189    return _links != null && _links.remove(value);
190  }
191
192  public List<LeveragedAuthorization> getLeveragedAuthorizations() {
193    return _leveragedAuthorizations;
194  }
195
196  public void setLeveragedAuthorizations(List<LeveragedAuthorization> value) {
197    _leveragedAuthorizations = value;
198  }
199
200  /**
201   * Add a new {@link LeveragedAuthorization} item to the underlying collection.
202   * @param item the item to add
203   * @return {@code true}
204   */
205  public boolean addLeveragedAuthorization(LeveragedAuthorization item) {
206    LeveragedAuthorization value = ObjectUtils.requireNonNull(item,"item cannot be null");
207    if (_leveragedAuthorizations == null) {
208      _leveragedAuthorizations = new LinkedList<>();
209    }
210    return _leveragedAuthorizations.add(value);
211  }
212
213  /**
214   * Remove the first matching {@link LeveragedAuthorization} item from the underlying collection.
215   * @param item the item to remove
216   * @return {@code true} if the item was removed or {@code false} otherwise
217   */
218  public boolean removeLeveragedAuthorization(LeveragedAuthorization item) {
219    LeveragedAuthorization value = ObjectUtils.requireNonNull(item,"item cannot be null");
220    return _leveragedAuthorizations != null && _leveragedAuthorizations.remove(value);
221  }
222
223  public List<SystemUser> getUsers() {
224    return _users;
225  }
226
227  public void setUsers(List<SystemUser> value) {
228    _users = value;
229  }
230
231  /**
232   * Add a new {@link SystemUser} item to the underlying collection.
233   * @param item the item to add
234   * @return {@code true}
235   */
236  public boolean addUser(SystemUser item) {
237    SystemUser value = ObjectUtils.requireNonNull(item,"item cannot be null");
238    if (_users == null) {
239      _users = new LinkedList<>();
240    }
241    return _users.add(value);
242  }
243
244  /**
245   * Remove the first matching {@link SystemUser} item from the underlying collection.
246   * @param item the item to remove
247   * @return {@code true} if the item was removed or {@code false} otherwise
248   */
249  public boolean removeUser(SystemUser item) {
250    SystemUser value = ObjectUtils.requireNonNull(item,"item cannot be null");
251    return _users != null && _users.remove(value);
252  }
253
254  public List<SystemComponent> getComponents() {
255    return _components;
256  }
257
258  public void setComponents(List<SystemComponent> value) {
259    _components = value;
260  }
261
262  /**
263   * Add a new {@link SystemComponent} item to the underlying collection.
264   * @param item the item to add
265   * @return {@code true}
266   */
267  public boolean addComponent(SystemComponent item) {
268    SystemComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
269    if (_components == null) {
270      _components = new LinkedList<>();
271    }
272    return _components.add(value);
273  }
274
275  /**
276   * Remove the first matching {@link SystemComponent} item from the underlying collection.
277   * @param item the item to remove
278   * @return {@code true} if the item was removed or {@code false} otherwise
279   */
280  public boolean removeComponent(SystemComponent item) {
281    SystemComponent value = ObjectUtils.requireNonNull(item,"item cannot be null");
282    return _components != null && _components.remove(value);
283  }
284
285  public List<InventoryItem> getInventoryItems() {
286    return _inventoryItems;
287  }
288
289  public void setInventoryItems(List<InventoryItem> value) {
290    _inventoryItems = value;
291  }
292
293  /**
294   * Add a new {@link InventoryItem} item to the underlying collection.
295   * @param item the item to add
296   * @return {@code true}
297   */
298  public boolean addInventoryItem(InventoryItem item) {
299    InventoryItem value = ObjectUtils.requireNonNull(item,"item cannot be null");
300    if (_inventoryItems == null) {
301      _inventoryItems = new LinkedList<>();
302    }
303    return _inventoryItems.add(value);
304  }
305
306  /**
307   * Remove the first matching {@link InventoryItem} item from the underlying collection.
308   * @param item the item to remove
309   * @return {@code true} if the item was removed or {@code false} otherwise
310   */
311  public boolean removeInventoryItem(InventoryItem item) {
312    InventoryItem value = ObjectUtils.requireNonNull(item,"item cannot be null");
313    return _inventoryItems != null && _inventoryItems.remove(value);
314  }
315
316  public MarkupMultiline getRemarks() {
317    return _remarks;
318  }
319
320  public void setRemarks(MarkupMultiline value) {
321    _remarks = value;
322  }
323
324  @Override
325  public String toString() {
326    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
327  }
328
329  /**
330   * A description of another authorized system from which this system inherits capabilities that satisfy security requirements. Another term for this concept is a <em>common control provider</em>.
331   */
332  @MetaschemaAssembly(
333      formalName = "Leveraged Authorization",
334      description = "A description of another authorized system from which this system inherits capabilities that satisfy security requirements. Another term for this concept is a *common control provider*.",
335      name = "leveraged-authorization",
336      moduleClass = OscalSspModule.class,
337      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-leveraged-authorization-link-rel-values", level = IConstraint.Level.ERROR, target = "link/@rel", allowOthers = true, values = @AllowedValue(value = "system-security-plan", description = "A reference to the system security plan for the leveraged authorization.")), indexHasKey = @IndexHasKey(id = "oscal-leveraged-authorization-index-back-matter-resource-ssp", level = IConstraint.Level.ERROR, target = "link[@rel='system-security-plan' and starts-with(@href,'#')]", indexName = "index-back-matter-resource", keyFields = @KeyField(target = "@href", pattern = "#(.*)")), matches = {@Matches(id = "oscal-leveraged-authorization-link-rel-ssp-datatype-uri-reference", level = IConstraint.Level.ERROR, target = "link[@rel='system-security-plan']/@href[starts-with(.,'#')]", typeAdapter = UriReferenceAdapter.class), @Matches(id = "oscal-leveraged-authorization-link-rel-ssp-datatype-uri", level = IConstraint.Level.ERROR, target = "link[@rel='system-security-plan']/@href[not(starts-with(.,'#'))]", typeAdapter = UriAdapter.class)})
338  )
339  public static class LeveragedAuthorization implements IBoundObject {
340    private final IMetaschemaData __metaschemaData;
341
342    /**
343     * "A <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented\">machine-oriented</a>, <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique\">globally unique</a> identifier with <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance\">cross-instance</a> scope and can be used to reference this leveraged authorization elsewhere in <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#ssp-identifiers\">this or other OSCAL instances</a>. The locally defined <em>UUID</em> of the <code>leveraged authorization</code> can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned <a href=\"https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency\">per-subject</a>, which means it should be consistently used to identify the same subject across revisions of the document."
344     */
345    @BoundFlag(
346        formalName = "Leveraged Authorization Universally Unique Identifier",
347        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented), [globally unique](https://pages.nist.gov/OSCAL/concepts/identifier-use/#globally-unique) identifier with [cross-instance](https://pages.nist.gov/OSCAL/concepts/identifier-use/#cross-instance) scope and can be used to reference this leveraged authorization elsewhere in [this or other OSCAL instances](https://pages.nist.gov/OSCAL/concepts/identifier-use/#ssp-identifiers). The locally defined *UUID* of the `leveraged authorization` can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned [per-subject](https://pages.nist.gov/OSCAL/concepts/identifier-use/#consistency), which means it should be consistently used to identify the same subject across revisions of the document.",
348        name = "uuid",
349        required = true,
350        typeAdapter = UuidAdapter.class
351    )
352    private UUID _uuid;
353
354    @BoundField(
355        formalName = "title field",
356        description = "A human readable name for the leveraged authorization in the context of the system.",
357        useName = "title",
358        minOccurs = 1,
359        typeAdapter = MarkupLineAdapter.class
360    )
361    private MarkupLine _title;
362
363    @BoundAssembly(
364        formalName = "Property",
365        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
366        useName = "prop",
367        maxOccurs = -1,
368        groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
369    )
370    private List<Property> _props;
371
372    @BoundAssembly(
373        formalName = "Link",
374        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
375        useName = "link",
376        maxOccurs = -1,
377        groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST)
378    )
379    private List<Link> _links;
380
381    @BoundField(
382        formalName = "party-uuid field",
383        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to the `party` that manages the leveraged system.",
384        useName = "party-uuid",
385        minOccurs = 1,
386        typeAdapter = UuidAdapter.class
387    )
388    private UUID _partyUuid;
389
390    @BoundField(
391        formalName = "System Authorization Date",
392        description = "The date the system received its authorization.",
393        useName = "date-authorized",
394        minOccurs = 1,
395        typeAdapter = DateAdapter.class
396    )
397    private AmbiguousDate _dateAuthorized;
398
399    @BoundField(
400        formalName = "Remarks",
401        description = "Additional commentary about the containing object.",
402        useName = "remarks",
403        typeAdapter = MarkupMultilineAdapter.class
404    )
405    private MarkupMultiline _remarks;
406
407    public LeveragedAuthorization() {
408      this(null);
409    }
410
411    public LeveragedAuthorization(IMetaschemaData data) {
412      this.__metaschemaData = data;
413    }
414
415    @Override
416    public IMetaschemaData getMetaschemaData() {
417      return __metaschemaData;
418    }
419
420    public UUID getUuid() {
421      return _uuid;
422    }
423
424    public void setUuid(UUID value) {
425      _uuid = value;
426    }
427
428    public MarkupLine getTitle() {
429      return _title;
430    }
431
432    public void setTitle(MarkupLine value) {
433      _title = value;
434    }
435
436    public List<Property> getProps() {
437      return _props;
438    }
439
440    public void setProps(List<Property> value) {
441      _props = value;
442    }
443
444    /**
445     * Add a new {@link Property} item to the underlying collection.
446     * @param item the item to add
447     * @return {@code true}
448     */
449    public boolean addProp(Property item) {
450      Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
451      if (_props == null) {
452        _props = new LinkedList<>();
453      }
454      return _props.add(value);
455    }
456
457    /**
458     * Remove the first matching {@link Property} item from the underlying collection.
459     * @param item the item to remove
460     * @return {@code true} if the item was removed or {@code false} otherwise
461     */
462    public boolean removeProp(Property item) {
463      Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
464      return _props != null && _props.remove(value);
465    }
466
467    public List<Link> getLinks() {
468      return _links;
469    }
470
471    public void setLinks(List<Link> value) {
472      _links = value;
473    }
474
475    /**
476     * Add a new {@link Link} item to the underlying collection.
477     * @param item the item to add
478     * @return {@code true}
479     */
480    public boolean addLink(Link item) {
481      Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
482      if (_links == null) {
483        _links = new LinkedList<>();
484      }
485      return _links.add(value);
486    }
487
488    /**
489     * Remove the first matching {@link Link} item from the underlying collection.
490     * @param item the item to remove
491     * @return {@code true} if the item was removed or {@code false} otherwise
492     */
493    public boolean removeLink(Link item) {
494      Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
495      return _links != null && _links.remove(value);
496    }
497
498    public UUID getPartyUuid() {
499      return _partyUuid;
500    }
501
502    public void setPartyUuid(UUID value) {
503      _partyUuid = value;
504    }
505
506    public AmbiguousDate getDateAuthorized() {
507      return _dateAuthorized;
508    }
509
510    public void setDateAuthorized(AmbiguousDate value) {
511      _dateAuthorized = value;
512    }
513
514    public MarkupMultiline getRemarks() {
515      return _remarks;
516    }
517
518    public void setRemarks(MarkupMultiline value) {
519      _remarks = value;
520    }
521
522    @Override
523    public String toString() {
524      return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
525    }
526  }
527}