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.BoundFlag; 008import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 009import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique; 010import gov.nist.secauto.metaschema.binding.model.annotations.KeyField; 011import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 012import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 013import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 014import gov.nist.secauto.metaschema.model.common.datatype.adapter.UriReferenceAdapter; 015import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter; 016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 017import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 018import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 019import java.lang.Override; 020import java.lang.String; 021import java.net.URI; 022import java.util.LinkedList; 023import java.util.List; 024import java.util.UUID; 025import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 026import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 027 028/** 029 * Defines how the component or capability supports a set of controls. 030 */ 031@MetaschemaAssembly( 032 formalName = "Control Implementation Set", 033 description = "Defines how the component or capability supports a set of controls.", 034 name = "control-implementation", 035 metaschema = OscalComponentDefinitionMetaschema.class, 036 remarks = "Use of `set-parameter` in this context, sets the parameter for all controls referenced by any `implemented-requirement` contained in this context. Any `set-parameter` defined in a child context will override this value. If not overridden by a child, this value applies in the child context." 037) 038@AssemblyConstraints( 039 isUnique = @IsUnique(id = "unique-component-definition-control-implementation-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.") 040) 041public class ComponentControlImplementation { 042 @BoundFlag( 043 formalName = "Control Implementation Set Identifier", 044 description = "Provides a means to identify a set of control implementations that are supported by a given component or capability.", 045 useName = "uuid", 046 required = true, 047 typeAdapter = UuidAdapter.class 048 ) 049 private UUID _uuid; 050 051 @BoundFlag( 052 formalName = "Source Resource Reference", 053 description = "A reference to an OSCAL catalog or profile providing the referenced control or subcontrol definition.", 054 useName = "source", 055 required = true, 056 typeAdapter = UriReferenceAdapter.class, 057 remarks = "This value may be one of:\n" 058 + "\n" 059 + "1. an [absolute URI](https://pages.nist.gov/OSCAL/concepts/uri-use/#absolute-uri) that points to a network resolvable resource,\n" 060 + "2. a [relative reference](https://pages.nist.gov/OSCAL/concepts/uri-use/#relative-reference) pointing to a network resolvable resource whose base URI is the URI of the containing document, or\n" 061 + "3. a bare URI fragment (i.e., \\`#uuid\\`) pointing to a `back-matter` resource in this or an imported document (see [linking to another OSCAL object](https://pages.nist.gov/OSCAL/concepts/uri-use/#linking-to-another-oscal-object))." 062 ) 063 private URI _source; 064 065 /** 066 * "A description of how the specified set of controls are implemented for the containing component or capability." 067 */ 068 @BoundField( 069 formalName = "Control Implementation Description", 070 description = "A description of how the specified set of controls are implemented for the containing component or capability.", 071 useName = "description", 072 minOccurs = 1 073 ) 074 @BoundFieldValue( 075 typeAdapter = MarkupMultilineAdapter.class 076 ) 077 private MarkupMultiline _description; 078 079 @BoundAssembly( 080 formalName = "Property", 081 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 082 useName = "prop", 083 maxOccurs = -1 084 ) 085 @GroupAs( 086 name = "props", 087 inJson = JsonGroupAsBehavior.LIST 088 ) 089 private List<Property> _props; 090 091 @BoundAssembly( 092 formalName = "Link", 093 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 094 useName = "link", 095 maxOccurs = -1 096 ) 097 @GroupAs( 098 name = "links", 099 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 = "Control Implementation", 117 description = "Describes how the containing component or capability implements an individual control.", 118 useName = "implemented-requirement", 119 minOccurs = 1, 120 maxOccurs = -1 121 ) 122 @GroupAs( 123 name = "implemented-requirements", 124 inJson = JsonGroupAsBehavior.LIST 125 ) 126 private List<ComponentImplementedRequirement> _implementedRequirements; 127 128 public ComponentControlImplementation() { 129 } 130 131 public UUID getUuid() { 132 return _uuid; 133 } 134 135 public void setUuid(UUID value) { 136 _uuid = value; 137 } 138 139 public URI getSource() { 140 return _source; 141 } 142 143 public void setSource(URI value) { 144 _source = value; 145 } 146 147 public MarkupMultiline getDescription() { 148 return _description; 149 } 150 151 public void setDescription(MarkupMultiline value) { 152 _description = value; 153 } 154 155 public List<Property> getProps() { 156 return _props; 157 } 158 159 public void setProps(List<Property> value) { 160 _props = value; 161 } 162 163 /** 164 * Add a new {@link Property} item to the underlying collection. 165 * @param item the item to add 166 * @return {@code true} 167 */ 168 public boolean addProp(Property item) { 169 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 170 if (_props == null) { 171 _props = new LinkedList<>(); 172 } 173 return _props.add(value); 174 } 175 176 /** 177 * Remove the first matching {@link Property} item from the underlying collection. 178 * @param item the item to remove 179 * @return {@code true} if the item was removed or {@code false} otherwise 180 */ 181 public boolean removeProp(Property item) { 182 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 183 return _props == null ? false : _props.remove(value); 184 } 185 186 public List<Link> getLinks() { 187 return _links; 188 } 189 190 public void setLinks(List<Link> value) { 191 _links = value; 192 } 193 194 /** 195 * Add a new {@link Link} item to the underlying collection. 196 * @param item the item to add 197 * @return {@code true} 198 */ 199 public boolean addLink(Link item) { 200 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 201 if (_links == null) { 202 _links = new LinkedList<>(); 203 } 204 return _links.add(value); 205 } 206 207 /** 208 * Remove the first matching {@link Link} item from the underlying collection. 209 * @param item the item to remove 210 * @return {@code true} if the item was removed or {@code false} otherwise 211 */ 212 public boolean removeLink(Link item) { 213 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 214 return _links == null ? false : _links.remove(value); 215 } 216 217 public List<SetParameter> getSetParameters() { 218 return _setParameters; 219 } 220 221 public void setSetParameters(List<SetParameter> value) { 222 _setParameters = value; 223 } 224 225 /** 226 * Add a new {@link SetParameter} item to the underlying collection. 227 * @param item the item to add 228 * @return {@code true} 229 */ 230 public boolean addSetParameter(SetParameter item) { 231 SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null"); 232 if (_setParameters == null) { 233 _setParameters = new LinkedList<>(); 234 } 235 return _setParameters.add(value); 236 } 237 238 /** 239 * Remove the first matching {@link SetParameter} item from the underlying collection. 240 * @param item the item to remove 241 * @return {@code true} if the item was removed or {@code false} otherwise 242 */ 243 public boolean removeSetParameter(SetParameter item) { 244 SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null"); 245 return _setParameters == null ? false : _setParameters.remove(value); 246 } 247 248 public List<ComponentImplementedRequirement> getImplementedRequirements() { 249 return _implementedRequirements; 250 } 251 252 public void setImplementedRequirements(List<ComponentImplementedRequirement> value) { 253 _implementedRequirements = value; 254 } 255 256 /** 257 * Add a new {@link ComponentImplementedRequirement} item to the underlying collection. 258 * @param item the item to add 259 * @return {@code true} 260 */ 261 public boolean addImplementedRequirement(ComponentImplementedRequirement item) { 262 ComponentImplementedRequirement value = ObjectUtils.requireNonNull(item,"item cannot be null"); 263 if (_implementedRequirements == null) { 264 _implementedRequirements = new LinkedList<>(); 265 } 266 return _implementedRequirements.add(value); 267 } 268 269 /** 270 * Remove the first matching {@link ComponentImplementedRequirement} item from the underlying collection. 271 * @param item the item to remove 272 * @return {@code true} if the item was removed or {@code false} otherwise 273 */ 274 public boolean removeImplementedRequirement(ComponentImplementedRequirement item) { 275 ComponentImplementedRequirement value = ObjectUtils.requireNonNull(item,"item cannot be null"); 276 return _implementedRequirements == null ? false : _implementedRequirements.remove(value); 277 } 278 279 @Override 280 public String toString() { 281 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 282 } 283}