001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue; 004import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 007import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 008import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 009import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 010import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 011import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints; 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.markup.MarkupMultiline; 016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 017import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 018import java.lang.Override; 019import java.lang.String; 020import java.util.LinkedList; 021import java.util.List; 022import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 023import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 024 025/** 026 * Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope. 027 */ 028@MetaschemaAssembly( 029 formalName = "Subject of Assessment", 030 description = "Identifies system elements being assessed, such as components, inventory items, and locations. In the assessment plan, this identifies a planned assessment subject. In the assessment results this is an actual assessment subject, and reflects any changes from the plan. exactly what will be the focus of this assessment. Any subjects not identified in this way are out-of-scope.", 031 name = "assessment-subject", 032 metaschema = OscalAssessmentCommonMetaschema.class, 033 remarks = "Processing of an include/exclude pair starts with processing the include, then removing matching entries in the exclude." 034) 035public class AssessmentSubject { 036 @BoundFlag( 037 formalName = "Subject Type", 038 description = "Indicates the type of assessment subject, such as a component, inventory, item, location, or party represented by this selection statement.", 039 useName = "type", 040 required = true, 041 typeAdapter = TokenAdapter.class 042 ) 043 @ValueConstraints( 044 allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "component", description = "The referenced assessment subject is a component defined in the SSP, or in the `local-definitions` of an Assessment Plan or Assessment Results."), @AllowedValue(value = "inventory-item", description = "The referenced assessment subject is a inventory item defined in the SSP, or in the `local-definitions` of an Assessment Plan or Assessment Results."), @AllowedValue(value = "location", description = "The referenced assessment subject is a `location` defined in the `metadata` of the SSP, Assessment Plan, or Assessment Results."), @AllowedValue(value = "party", description = "The referenced assessment subject is a person or team to interview, who is defined as a `party` in the `metadata` of the SSP, Assessment Plan, or Assessment Results."), @AllowedValue(value = "user", description = "The referenced assessment subject is a `user` defined in the SSP, or in the `local-definitions` of an Assessment Plan or Assessment Results.")}) 045 ) 046 private String _type; 047 048 /** 049 * "A human-readable description of the collection of subjects being included in this assessment." 050 */ 051 @BoundField( 052 formalName = "Include Subjects Description", 053 description = "A human-readable description of the collection of subjects being included in this assessment.", 054 useName = "description" 055 ) 056 @BoundFieldValue( 057 typeAdapter = MarkupMultilineAdapter.class 058 ) 059 private MarkupMultiline _description; 060 061 @BoundAssembly( 062 formalName = "Property", 063 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 064 useName = "prop", 065 maxOccurs = -1 066 ) 067 @GroupAs( 068 name = "props", 069 inJson = JsonGroupAsBehavior.LIST 070 ) 071 private List<Property> _props; 072 073 @BoundAssembly( 074 formalName = "Link", 075 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 076 useName = "link", 077 maxOccurs = -1 078 ) 079 @GroupAs( 080 name = "links", 081 inJson = JsonGroupAsBehavior.LIST 082 ) 083 private List<Link> _links; 084 085 @BoundAssembly( 086 formalName = "Include All", 087 description = "Include all controls from the imported catalog or profile resources.", 088 useName = "include-all", 089 minOccurs = 1 090 ) 091 private IncludeAll _includeAll; 092 093 @BoundAssembly( 094 formalName = "Select Assessment Subject", 095 description = "Identifies a set of assessment subjects to include/exclude by UUID.", 096 useName = "include-subject", 097 minOccurs = 1, 098 maxOccurs = -1 099 ) 100 @GroupAs( 101 name = "include-subjects", 102 inJson = JsonGroupAsBehavior.LIST 103 ) 104 private List<SelectSubjectById> _includeSubjects; 105 106 @BoundAssembly( 107 formalName = "Select Assessment Subject", 108 description = "Identifies a set of assessment subjects to include/exclude by UUID.", 109 useName = "exclude-subject", 110 maxOccurs = -1 111 ) 112 @GroupAs( 113 name = "exclude-subjects", 114 inJson = JsonGroupAsBehavior.LIST 115 ) 116 private List<SelectSubjectById> _excludeSubjects; 117 118 @BoundField( 119 formalName = "Remarks", 120 description = "Additional commentary about the containing object.", 121 useName = "remarks" 122 ) 123 @BoundFieldValue( 124 typeAdapter = MarkupMultilineAdapter.class 125 ) 126 private MarkupMultiline _remarks; 127 128 public AssessmentSubject() { 129 } 130 131 public String getType() { 132 return _type; 133 } 134 135 public void setType(String value) { 136 _type = value; 137 } 138 139 public MarkupMultiline getDescription() { 140 return _description; 141 } 142 143 public void setDescription(MarkupMultiline value) { 144 _description = value; 145 } 146 147 public List<Property> getProps() { 148 return _props; 149 } 150 151 public void setProps(List<Property> value) { 152 _props = value; 153 } 154 155 /** 156 * Add a new {@link Property} item to the underlying collection. 157 * @param item the item to add 158 * @return {@code true} 159 */ 160 public boolean addProp(Property item) { 161 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 162 if (_props == null) { 163 _props = new LinkedList<>(); 164 } 165 return _props.add(value); 166 } 167 168 /** 169 * Remove the first matching {@link Property} item from the underlying collection. 170 * @param item the item to remove 171 * @return {@code true} if the item was removed or {@code false} otherwise 172 */ 173 public boolean removeProp(Property item) { 174 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 175 return _props == null ? false : _props.remove(value); 176 } 177 178 public List<Link> getLinks() { 179 return _links; 180 } 181 182 public void setLinks(List<Link> value) { 183 _links = value; 184 } 185 186 /** 187 * Add a new {@link Link} item to the underlying collection. 188 * @param item the item to add 189 * @return {@code true} 190 */ 191 public boolean addLink(Link item) { 192 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 193 if (_links == null) { 194 _links = new LinkedList<>(); 195 } 196 return _links.add(value); 197 } 198 199 /** 200 * Remove the first matching {@link Link} item from the underlying collection. 201 * @param item the item to remove 202 * @return {@code true} if the item was removed or {@code false} otherwise 203 */ 204 public boolean removeLink(Link item) { 205 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 206 return _links == null ? false : _links.remove(value); 207 } 208 209 public IncludeAll getIncludeAll() { 210 return _includeAll; 211 } 212 213 public void setIncludeAll(IncludeAll value) { 214 _includeAll = value; 215 } 216 217 public List<SelectSubjectById> getIncludeSubjects() { 218 return _includeSubjects; 219 } 220 221 public void setIncludeSubjects(List<SelectSubjectById> value) { 222 _includeSubjects = value; 223 } 224 225 /** 226 * Add a new {@link SelectSubjectById} item to the underlying collection. 227 * @param item the item to add 228 * @return {@code true} 229 */ 230 public boolean addIncludeSubject(SelectSubjectById item) { 231 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 232 if (_includeSubjects == null) { 233 _includeSubjects = new LinkedList<>(); 234 } 235 return _includeSubjects.add(value); 236 } 237 238 /** 239 * Remove the first matching {@link SelectSubjectById} 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 removeIncludeSubject(SelectSubjectById item) { 244 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 245 return _includeSubjects == null ? false : _includeSubjects.remove(value); 246 } 247 248 public List<SelectSubjectById> getExcludeSubjects() { 249 return _excludeSubjects; 250 } 251 252 public void setExcludeSubjects(List<SelectSubjectById> value) { 253 _excludeSubjects = value; 254 } 255 256 /** 257 * Add a new {@link SelectSubjectById} item to the underlying collection. 258 * @param item the item to add 259 * @return {@code true} 260 */ 261 public boolean addExcludeSubject(SelectSubjectById item) { 262 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 263 if (_excludeSubjects == null) { 264 _excludeSubjects = new LinkedList<>(); 265 } 266 return _excludeSubjects.add(value); 267 } 268 269 /** 270 * Remove the first matching {@link SelectSubjectById} 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 removeExcludeSubject(SelectSubjectById item) { 275 SelectSubjectById value = ObjectUtils.requireNonNull(item,"item cannot be null"); 276 return _excludeSubjects == null ? false : _excludeSubjects.remove(value); 277 } 278 279 public MarkupMultiline getRemarks() { 280 return _remarks; 281 } 282 283 public void setRemarks(MarkupMultiline value) { 284 _remarks = value; 285 } 286 287 @Override 288 public String toString() { 289 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 290 } 291}