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.TokenAdapter; 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.util.LinkedList; 022import java.util.List; 023import java.util.UUID; 024import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 025import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 026 027/** 028 * Describes how the containing component or capability implements an individual control. 029 */ 030@MetaschemaAssembly( 031 formalName = "Control Implementation", 032 description = "Describes how the containing component or capability implements an individual control.", 033 name = "implemented-requirement", 034 metaschema = OscalComponentDefinitionMetaschema.class, 035 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" 036 + "\n" 037 + "Use of `set-parameter` in this context, sets the parameter for the referenced control and any associated statements." 038) 039@AssemblyConstraints( 040 isUnique = { 041 @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."), 042 @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."), 043 @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.") 044 } 045) 046public class ComponentImplementedRequirement { 047 @BoundFlag( 048 formalName = "Control Implementation Identifier", 049 description = "Provides a globally unique means to identify a given control implementation by a component.", 050 useName = "uuid", 051 required = true, 052 typeAdapter = UuidAdapter.class 053 ) 054 private UUID _uuid; 055 056 @BoundFlag( 057 formalName = "Control Identifier Reference", 058 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).", 059 useName = "control-id", 060 required = true, 061 typeAdapter = TokenAdapter.class 062 ) 063 private String _controlId; 064 065 /** 066 * "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." 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 ) 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 = "Responsible Role", 117 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.", 118 useName = "responsible-role", 119 maxOccurs = -1 120 ) 121 @GroupAs( 122 name = "responsible-roles", 123 inJson = JsonGroupAsBehavior.LIST 124 ) 125 private List<ResponsibleRole> _responsibleRoles; 126 127 @BoundAssembly( 128 formalName = "Control Statement Implementation", 129 description = "Identifies which statements within a control are addressed.", 130 useName = "statement", 131 maxOccurs = -1 132 ) 133 @GroupAs( 134 name = "statements", 135 inJson = JsonGroupAsBehavior.LIST 136 ) 137 private List<ComponentStatement> _statements; 138 139 @BoundField( 140 formalName = "Remarks", 141 description = "Additional commentary about the containing object.", 142 useName = "remarks" 143 ) 144 @BoundFieldValue( 145 typeAdapter = MarkupMultilineAdapter.class 146 ) 147 private MarkupMultiline _remarks; 148 149 public ComponentImplementedRequirement() { 150 } 151 152 public UUID getUuid() { 153 return _uuid; 154 } 155 156 public void setUuid(UUID value) { 157 _uuid = value; 158 } 159 160 public String getControlId() { 161 return _controlId; 162 } 163 164 public void setControlId(String value) { 165 _controlId = value; 166 } 167 168 public MarkupMultiline getDescription() { 169 return _description; 170 } 171 172 public void setDescription(MarkupMultiline value) { 173 _description = value; 174 } 175 176 public List<Property> getProps() { 177 return _props; 178 } 179 180 public void setProps(List<Property> value) { 181 _props = value; 182 } 183 184 /** 185 * Add a new {@link Property} item to the underlying collection. 186 * @param item the item to add 187 * @return {@code true} 188 */ 189 public boolean addProp(Property item) { 190 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 191 if (_props == null) { 192 _props = new LinkedList<>(); 193 } 194 return _props.add(value); 195 } 196 197 /** 198 * Remove the first matching {@link Property} item from the underlying collection. 199 * @param item the item to remove 200 * @return {@code true} if the item was removed or {@code false} otherwise 201 */ 202 public boolean removeProp(Property item) { 203 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 204 return _props == null ? false : _props.remove(value); 205 } 206 207 public List<Link> getLinks() { 208 return _links; 209 } 210 211 public void setLinks(List<Link> value) { 212 _links = value; 213 } 214 215 /** 216 * Add a new {@link Link} item to the underlying collection. 217 * @param item the item to add 218 * @return {@code true} 219 */ 220 public boolean addLink(Link item) { 221 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 222 if (_links == null) { 223 _links = new LinkedList<>(); 224 } 225 return _links.add(value); 226 } 227 228 /** 229 * Remove the first matching {@link Link} item from the underlying collection. 230 * @param item the item to remove 231 * @return {@code true} if the item was removed or {@code false} otherwise 232 */ 233 public boolean removeLink(Link item) { 234 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 235 return _links == null ? false : _links.remove(value); 236 } 237 238 public List<SetParameter> getSetParameters() { 239 return _setParameters; 240 } 241 242 public void setSetParameters(List<SetParameter> value) { 243 _setParameters = value; 244 } 245 246 /** 247 * Add a new {@link SetParameter} item to the underlying collection. 248 * @param item the item to add 249 * @return {@code true} 250 */ 251 public boolean addSetParameter(SetParameter item) { 252 SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null"); 253 if (_setParameters == null) { 254 _setParameters = new LinkedList<>(); 255 } 256 return _setParameters.add(value); 257 } 258 259 /** 260 * Remove the first matching {@link SetParameter} item from the underlying collection. 261 * @param item the item to remove 262 * @return {@code true} if the item was removed or {@code false} otherwise 263 */ 264 public boolean removeSetParameter(SetParameter item) { 265 SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null"); 266 return _setParameters == null ? false : _setParameters.remove(value); 267 } 268 269 public List<ResponsibleRole> getResponsibleRoles() { 270 return _responsibleRoles; 271 } 272 273 public void setResponsibleRoles(List<ResponsibleRole> value) { 274 _responsibleRoles = value; 275 } 276 277 /** 278 * Add a new {@link ResponsibleRole} item to the underlying collection. 279 * @param item the item to add 280 * @return {@code true} 281 */ 282 public boolean addResponsibleRole(ResponsibleRole item) { 283 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 284 if (_responsibleRoles == null) { 285 _responsibleRoles = new LinkedList<>(); 286 } 287 return _responsibleRoles.add(value); 288 } 289 290 /** 291 * Remove the first matching {@link ResponsibleRole} item from the underlying collection. 292 * @param item the item to remove 293 * @return {@code true} if the item was removed or {@code false} otherwise 294 */ 295 public boolean removeResponsibleRole(ResponsibleRole item) { 296 ResponsibleRole value = ObjectUtils.requireNonNull(item,"item cannot be null"); 297 return _responsibleRoles == null ? false : _responsibleRoles.remove(value); 298 } 299 300 public List<ComponentStatement> getStatements() { 301 return _statements; 302 } 303 304 public void setStatements(List<ComponentStatement> value) { 305 _statements = value; 306 } 307 308 /** 309 * Add a new {@link ComponentStatement} item to the underlying collection. 310 * @param item the item to add 311 * @return {@code true} 312 */ 313 public boolean addStatement(ComponentStatement item) { 314 ComponentStatement value = ObjectUtils.requireNonNull(item,"item cannot be null"); 315 if (_statements == null) { 316 _statements = new LinkedList<>(); 317 } 318 return _statements.add(value); 319 } 320 321 /** 322 * Remove the first matching {@link ComponentStatement} item from the underlying collection. 323 * @param item the item to remove 324 * @return {@code true} if the item was removed or {@code false} otherwise 325 */ 326 public boolean removeStatement(ComponentStatement item) { 327 ComponentStatement value = ObjectUtils.requireNonNull(item,"item cannot be null"); 328 return _statements == null ? false : _statements.remove(value); 329 } 330 331 public MarkupMultiline getRemarks() { 332 return _remarks; 333 } 334 335 public void setRemarks(MarkupMultiline value) { 336 _remarks = value; 337 } 338 339 @Override 340 public String toString() { 341 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 342 } 343}