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(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(level = IConstraint.Level.ERROR, target = "component/prop[@name='leveraged-authorization-uuid']", indexName = "index-system-implementation-leveraged-authorization-uuid", keyFields = @KeyField(target = "@value")), @IndexHasKey(level = IConstraint.Level.ERROR, target = "component/link[@rel='depends-on']", indexName = "index-system-implementation-component-uuid", keyFields = @KeyField(target = "@href")), @IndexHasKey(level = IConstraint.Level.ERROR, target = "component/link[@rel='validated-by']", indexName = "index-system-implementation-component-uuid-validation", keyFields = @KeyField(target = "@href")), @IndexHasKey(level = IConstraint.Level.ERROR, target = "component/link[@rel='proof-of-compliance']", indexName = "index-system-implementation-component-uuid-validation", keyFields = @KeyField(target = "@href")), @IndexHasKey(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(level = IConstraint.Level.ERROR, target = "leveraged-authorization", name = "index-system-implementation-leveraged-authorization-uuid", keyFields = @KeyField(target = "@uuid")), @Index(level = IConstraint.Level.ERROR, target = "component", name = "index-system-implementation-component-uuid", keyFields = @KeyField(target = "@uuid")), @Index(level = IConstraint.Level.ERROR, target = "component[@type='validation']", name = "index-system-implementation-component-uuid-validation", keyFields = @KeyField(target = "@uuid")), @Index(level = IConstraint.Level.ERROR, target = "component[@type='service']", name = "index-system-implementation-component-uuid-service", keyFields = @KeyField(target = "@uuid"))}, unique = @IsUnique(id = "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 minOccurs = 1, 085 maxOccurs = -1, 086 groupAs = @GroupAs(name = "users", inJson = JsonGroupAsBehavior.LIST) 087 ) 088 private List<SystemUser> _users; 089 090 @BoundAssembly( 091 formalName = "Component", 092 description = "A defined component that can be part of an implemented system.", 093 useName = "component", 094 minOccurs = 1, 095 maxOccurs = -1, 096 groupAs = @GroupAs(name = "components", inJson = JsonGroupAsBehavior.LIST) 097 ) 098 private List<SystemComponent> _components; 099 100 @BoundAssembly( 101 formalName = "Inventory Item", 102 description = "A single managed inventory item within the system.", 103 useName = "inventory-item", 104 remarks = "A set of `inventory-item` entries that represent the managed inventory instances of the system.", 105 maxOccurs = -1, 106 groupAs = @GroupAs(name = "inventory-items", inJson = JsonGroupAsBehavior.LIST) 107 ) 108 private List<InventoryItem> _inventoryItems; 109 110 @BoundField( 111 formalName = "Remarks", 112 description = "Additional commentary about the containing object.", 113 useName = "remarks", 114 typeAdapter = MarkupMultilineAdapter.class 115 ) 116 private MarkupMultiline _remarks; 117 118 public SystemImplementation() { 119 this(null); 120 } 121 122 public SystemImplementation(IMetaschemaData data) { 123 this.__metaschemaData = data; 124 } 125 126 @Override 127 public IMetaschemaData getMetaschemaData() { 128 return __metaschemaData; 129 } 130 131 public List<Property> getProps() { 132 return _props; 133 } 134 135 public void setProps(List<Property> value) { 136 _props = value; 137 } 138 139 /** 140 * Add a new {@link Property} item to the underlying collection. 141 * @param item the item to add 142 * @return {@code true} 143 */ 144 public boolean addProp(Property item) { 145 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 146 if (_props == null) { 147 _props = new LinkedList<>(); 148 } 149 return _props.add(value); 150 } 151 152 /** 153 * Remove the first matching {@link Property} item from the underlying collection. 154 * @param item the item to remove 155 * @return {@code true} if the item was removed or {@code false} otherwise 156 */ 157 public boolean removeProp(Property item) { 158 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 159 return _props != null && _props.remove(value); 160 } 161 162 public List<Link> getLinks() { 163 return _links; 164 } 165 166 public void setLinks(List<Link> value) { 167 _links = value; 168 } 169 170 /** 171 * Add a new {@link Link} item to the underlying collection. 172 * @param item the item to add 173 * @return {@code true} 174 */ 175 public boolean addLink(Link item) { 176 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 177 if (_links == null) { 178 _links = new LinkedList<>(); 179 } 180 return _links.add(value); 181 } 182 183 /** 184 * Remove the first matching {@link Link} item from the underlying collection. 185 * @param item the item to remove 186 * @return {@code true} if the item was removed or {@code false} otherwise 187 */ 188 public boolean removeLink(Link item) { 189 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 190 return _links != null && _links.remove(value); 191 } 192 193 public List<LeveragedAuthorization> getLeveragedAuthorizations() { 194 return _leveragedAuthorizations; 195 } 196 197 public void setLeveragedAuthorizations(List<LeveragedAuthorization> value) { 198 _leveragedAuthorizations = value; 199 } 200 201 /** 202 * Add a new {@link LeveragedAuthorization} item to the underlying collection. 203 * @param item the item to add 204 * @return {@code true} 205 */ 206 public boolean addLeveragedAuthorization(LeveragedAuthorization item) { 207 LeveragedAuthorization value = ObjectUtils.requireNonNull(item,"item cannot be null"); 208 if (_leveragedAuthorizations == null) { 209 _leveragedAuthorizations = new LinkedList<>(); 210 } 211 return _leveragedAuthorizations.add(value); 212 } 213 214 /** 215 * Remove the first matching {@link LeveragedAuthorization} item from the underlying collection. 216 * @param item the item to remove 217 * @return {@code true} if the item was removed or {@code false} otherwise 218 */ 219 public boolean removeLeveragedAuthorization(LeveragedAuthorization item) { 220 LeveragedAuthorization value = ObjectUtils.requireNonNull(item,"item cannot be null"); 221 return _leveragedAuthorizations != null && _leveragedAuthorizations.remove(value); 222 } 223 224 public List<SystemUser> getUsers() { 225 return _users; 226 } 227 228 public void setUsers(List<SystemUser> value) { 229 _users = value; 230 } 231 232 /** 233 * Add a new {@link SystemUser} item to the underlying collection. 234 * @param item the item to add 235 * @return {@code true} 236 */ 237 public boolean addUser(SystemUser item) { 238 SystemUser value = ObjectUtils.requireNonNull(item,"item cannot be null"); 239 if (_users == null) { 240 _users = new LinkedList<>(); 241 } 242 return _users.add(value); 243 } 244 245 /** 246 * Remove the first matching {@link SystemUser} item from the underlying collection. 247 * @param item the item to remove 248 * @return {@code true} if the item was removed or {@code false} otherwise 249 */ 250 public boolean removeUser(SystemUser item) { 251 SystemUser value = ObjectUtils.requireNonNull(item,"item cannot be null"); 252 return _users != null && _users.remove(value); 253 } 254 255 public List<SystemComponent> getComponents() { 256 return _components; 257 } 258 259 public void setComponents(List<SystemComponent> value) { 260 _components = value; 261 } 262 263 /** 264 * Add a new {@link SystemComponent} item to the underlying collection. 265 * @param item the item to add 266 * @return {@code true} 267 */ 268 public boolean addComponent(SystemComponent item) { 269 SystemComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 270 if (_components == null) { 271 _components = new LinkedList<>(); 272 } 273 return _components.add(value); 274 } 275 276 /** 277 * Remove the first matching {@link SystemComponent} item from the underlying collection. 278 * @param item the item to remove 279 * @return {@code true} if the item was removed or {@code false} otherwise 280 */ 281 public boolean removeComponent(SystemComponent item) { 282 SystemComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 283 return _components != null && _components.remove(value); 284 } 285 286 public List<InventoryItem> getInventoryItems() { 287 return _inventoryItems; 288 } 289 290 public void setInventoryItems(List<InventoryItem> value) { 291 _inventoryItems = value; 292 } 293 294 /** 295 * Add a new {@link InventoryItem} item to the underlying collection. 296 * @param item the item to add 297 * @return {@code true} 298 */ 299 public boolean addInventoryItem(InventoryItem item) { 300 InventoryItem value = ObjectUtils.requireNonNull(item,"item cannot be null"); 301 if (_inventoryItems == null) { 302 _inventoryItems = new LinkedList<>(); 303 } 304 return _inventoryItems.add(value); 305 } 306 307 /** 308 * Remove the first matching {@link InventoryItem} item from the underlying collection. 309 * @param item the item to remove 310 * @return {@code true} if the item was removed or {@code false} otherwise 311 */ 312 public boolean removeInventoryItem(InventoryItem item) { 313 InventoryItem value = ObjectUtils.requireNonNull(item,"item cannot be null"); 314 return _inventoryItems != null && _inventoryItems.remove(value); 315 } 316 317 public MarkupMultiline getRemarks() { 318 return _remarks; 319 } 320 321 public void setRemarks(MarkupMultiline value) { 322 _remarks = value; 323 } 324 325 @Override 326 public String toString() { 327 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 328 } 329 330 /** 331 * 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>. 332 */ 333 @MetaschemaAssembly( 334 formalName = "Leveraged Authorization", 335 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*.", 336 name = "leveraged-authorization", 337 moduleClass = OscalSspModule.class, 338 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(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(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(level = IConstraint.Level.ERROR, target = "link[@rel='system-security-plan']/@href[starts-with(.,'#')]", typeAdapter = UriReferenceAdapter.class), @Matches(level = IConstraint.Level.ERROR, target = "link[@rel='system-security-plan']/@href[not(starts-with(.,'#'))]", typeAdapter = UriAdapter.class)}) 339 ) 340 public static class LeveragedAuthorization implements IBoundObject { 341 private final IMetaschemaData __metaschemaData; 342 343 /** 344 * "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." 345 */ 346 @BoundFlag( 347 formalName = "Leveraged Authorization Universally Unique Identifier", 348 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.", 349 name = "uuid", 350 required = true, 351 typeAdapter = UuidAdapter.class 352 ) 353 private UUID _uuid; 354 355 @BoundField( 356 formalName = "title field", 357 description = "A human readable name for the leveraged authorization in the context of the system.", 358 useName = "title", 359 minOccurs = 1, 360 typeAdapter = MarkupLineAdapter.class 361 ) 362 private MarkupLine _title; 363 364 @BoundAssembly( 365 formalName = "Property", 366 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 367 useName = "prop", 368 maxOccurs = -1, 369 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 370 ) 371 private List<Property> _props; 372 373 @BoundAssembly( 374 formalName = "Link", 375 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 376 useName = "link", 377 maxOccurs = -1, 378 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 379 ) 380 private List<Link> _links; 381 382 @BoundField( 383 formalName = "party-uuid field", 384 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to the `party` that manages the leveraged system.", 385 useName = "party-uuid", 386 minOccurs = 1, 387 typeAdapter = UuidAdapter.class 388 ) 389 private UUID _partyUuid; 390 391 @BoundField( 392 formalName = "System Authorization Date", 393 description = "The date the system received its authorization.", 394 useName = "date-authorized", 395 minOccurs = 1, 396 typeAdapter = DateAdapter.class 397 ) 398 private AmbiguousDate _dateAuthorized; 399 400 @BoundField( 401 formalName = "Remarks", 402 description = "Additional commentary about the containing object.", 403 useName = "remarks", 404 typeAdapter = MarkupMultilineAdapter.class 405 ) 406 private MarkupMultiline _remarks; 407 408 public LeveragedAuthorization() { 409 this(null); 410 } 411 412 public LeveragedAuthorization(IMetaschemaData data) { 413 this.__metaschemaData = data; 414 } 415 416 @Override 417 public IMetaschemaData getMetaschemaData() { 418 return __metaschemaData; 419 } 420 421 public UUID getUuid() { 422 return _uuid; 423 } 424 425 public void setUuid(UUID value) { 426 _uuid = value; 427 } 428 429 public MarkupLine getTitle() { 430 return _title; 431 } 432 433 public void setTitle(MarkupLine value) { 434 _title = value; 435 } 436 437 public List<Property> getProps() { 438 return _props; 439 } 440 441 public void setProps(List<Property> value) { 442 _props = value; 443 } 444 445 /** 446 * Add a new {@link Property} item to the underlying collection. 447 * @param item the item to add 448 * @return {@code true} 449 */ 450 public boolean addProp(Property item) { 451 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 452 if (_props == null) { 453 _props = new LinkedList<>(); 454 } 455 return _props.add(value); 456 } 457 458 /** 459 * Remove the first matching {@link Property} item from the underlying collection. 460 * @param item the item to remove 461 * @return {@code true} if the item was removed or {@code false} otherwise 462 */ 463 public boolean removeProp(Property item) { 464 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 465 return _props != null && _props.remove(value); 466 } 467 468 public List<Link> getLinks() { 469 return _links; 470 } 471 472 public void setLinks(List<Link> value) { 473 _links = value; 474 } 475 476 /** 477 * Add a new {@link Link} item to the underlying collection. 478 * @param item the item to add 479 * @return {@code true} 480 */ 481 public boolean addLink(Link item) { 482 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 483 if (_links == null) { 484 _links = new LinkedList<>(); 485 } 486 return _links.add(value); 487 } 488 489 /** 490 * Remove the first matching {@link Link} item from the underlying collection. 491 * @param item the item to remove 492 * @return {@code true} if the item was removed or {@code false} otherwise 493 */ 494 public boolean removeLink(Link item) { 495 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 496 return _links != null && _links.remove(value); 497 } 498 499 public UUID getPartyUuid() { 500 return _partyUuid; 501 } 502 503 public void setPartyUuid(UUID value) { 504 _partyUuid = value; 505 } 506 507 public AmbiguousDate getDateAuthorized() { 508 return _dateAuthorized; 509 } 510 511 public void setDateAuthorized(AmbiguousDate value) { 512 _dateAuthorized = value; 513 } 514 515 public MarkupMultiline getRemarks() { 516 return _remarks; 517 } 518 519 public void setRemarks(MarkupMultiline value) { 520 _remarks = value; 521 } 522 523 @Override 524 public String toString() { 525 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 526 } 527 } 528}