001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints; 004import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 007import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 008import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique; 009import gov.nist.secauto.metaschema.binding.model.annotations.KeyField; 010import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 011import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 012import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 013import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 014import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 015import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 016import java.lang.Override; 017import java.lang.String; 018import java.util.LinkedList; 019import java.util.List; 020import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 021import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 022 023/** 024 * Allows components, and inventory-items to be defined within the POA&M for circumstances where no OSCAL-based SSP exists, or is not delivered with the POA&M. 025 */ 026@MetaschemaAssembly( 027 formalName = "Local Definitions", 028 description = "Allows components, and inventory-items to be defined within the POA\\&M for circumstances where no OSCAL-based SSP exists, or is not delivered with the POA\\&M.", 029 name = "local-definitions", 030 metaschema = OscalPoamMetaschema.class 031) 032@AssemblyConstraints( 033 isUnique = @IsUnique(id = "unique-poam-local-definitions-component", level = IConstraint.Level.ERROR, target = "component", keyFields = @KeyField(target = "@uuid"), remarks = "Since multiple `component` entries can be provided, each component must have a unique `uuid`.") 034) 035public class LocalDefinitions { 036 @BoundAssembly( 037 formalName = "Component", 038 description = "A defined component that can be part of an implemented system.", 039 useName = "component", 040 maxOccurs = -1, 041 remarks = "Used to add any components, not defined via the System Security Plan (AR-\\>AP-\\>SSP)" 042 ) 043 @GroupAs( 044 name = "components", 045 inJson = JsonGroupAsBehavior.LIST 046 ) 047 private List<SystemComponent> _components; 048 049 @BoundAssembly( 050 formalName = "Inventory Item", 051 description = "A single managed inventory item within the system.", 052 useName = "inventory-item", 053 maxOccurs = -1, 054 remarks = "Used to add any inventory-items, not defined via the System Security Plan (AR-\\>AP-\\>SSP)" 055 ) 056 @GroupAs( 057 name = "inventory-items", 058 inJson = JsonGroupAsBehavior.LIST 059 ) 060 private List<InventoryItem> _inventoryItems; 061 062 @BoundAssembly( 063 formalName = "Assessment Assets", 064 description = "Identifies the assets used to perform this assessment, such as the assessment team, scanning tools, and assumptions.", 065 useName = "assessment-assets", 066 remarks = "Specifies components or assessment-platforms used in the assessment." 067 ) 068 private AssessmentAssets _assessmentAssets; 069 070 @BoundField( 071 formalName = "Remarks", 072 description = "Additional commentary about the containing object.", 073 useName = "remarks" 074 ) 075 @BoundFieldValue( 076 typeAdapter = MarkupMultilineAdapter.class 077 ) 078 private MarkupMultiline _remarks; 079 080 public LocalDefinitions() { 081 } 082 083 public List<SystemComponent> getComponents() { 084 return _components; 085 } 086 087 public void setComponents(List<SystemComponent> value) { 088 _components = value; 089 } 090 091 /** 092 * Add a new {@link SystemComponent} item to the underlying collection. 093 * @param item the item to add 094 * @return {@code true} 095 */ 096 public boolean addComponent(SystemComponent item) { 097 SystemComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 098 if (_components == null) { 099 _components = new LinkedList<>(); 100 } 101 return _components.add(value); 102 } 103 104 /** 105 * Remove the first matching {@link SystemComponent} item from the underlying collection. 106 * @param item the item to remove 107 * @return {@code true} if the item was removed or {@code false} otherwise 108 */ 109 public boolean removeComponent(SystemComponent item) { 110 SystemComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 111 return _components == null ? false : _components.remove(value); 112 } 113 114 public List<InventoryItem> getInventoryItems() { 115 return _inventoryItems; 116 } 117 118 public void setInventoryItems(List<InventoryItem> value) { 119 _inventoryItems = value; 120 } 121 122 /** 123 * Add a new {@link InventoryItem} item to the underlying collection. 124 * @param item the item to add 125 * @return {@code true} 126 */ 127 public boolean addInventoryItem(InventoryItem item) { 128 InventoryItem value = ObjectUtils.requireNonNull(item,"item cannot be null"); 129 if (_inventoryItems == null) { 130 _inventoryItems = new LinkedList<>(); 131 } 132 return _inventoryItems.add(value); 133 } 134 135 /** 136 * Remove the first matching {@link InventoryItem} item from the underlying collection. 137 * @param item the item to remove 138 * @return {@code true} if the item was removed or {@code false} otherwise 139 */ 140 public boolean removeInventoryItem(InventoryItem item) { 141 InventoryItem value = ObjectUtils.requireNonNull(item,"item cannot be null"); 142 return _inventoryItems == null ? false : _inventoryItems.remove(value); 143 } 144 145 public AssessmentAssets getAssessmentAssets() { 146 return _assessmentAssets; 147 } 148 149 public void setAssessmentAssets(AssessmentAssets value) { 150 _assessmentAssets = value; 151 } 152 153 public MarkupMultiline getRemarks() { 154 return _remarks; 155 } 156 157 public void setRemarks(MarkupMultiline value) { 158 _remarks = value; 159 } 160 161 @Override 162 public String toString() { 163 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 164 } 165}