View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
6   import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
7   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
8   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
9   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
10  import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
11  import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
12  import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
13  import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
14  import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
15  import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
16  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLine;
17  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter;
18  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
19  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
20  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
21  import java.lang.Override;
22  import java.lang.String;
23  import java.util.LinkedList;
24  import java.util.List;
25  import java.util.UUID;
26  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
27  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
28  
29  /**
30   * A <a href="https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented">human-oriented</a> identifier reference to a resource. Use type to indicate whether the identified resource is a component, inventory item, location, user, or something else.
31   */
32  @MetaschemaAssembly(
33      formalName = "Identifies the Subject",
34      description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a resource. Use type to indicate whether the identified resource is a component, inventory item, location, user, or something else.",
35      name = "subject-reference",
36      metaschema = OscalAssessmentCommonMetaschema.class,
37      remarks = "The subject reference UUID could point to an item defined in the SSP, AP, or AR.\n"
38              + "\n"
39              + "Tools should check look for the ID in every file imported directly or indirectly."
40  )
41  public class SubjectReference {
42    @BoundFlag(
43        formalName = "Subject Universally Unique Identifier Reference",
44        description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a component, inventory-item, location, party, user, or resource using it's UUID.",
45        useName = "subject-uuid",
46        required = true,
47        typeAdapter = UuidAdapter.class
48    )
49    private UUID _subjectUuid;
50  
51    @BoundFlag(
52        formalName = "Subject Universally Unique Identifier Reference Type",
53        description = "Used to indicate the type of object pointed to by the `uuid-ref` within a subject.",
54        useName = "type",
55        required = true,
56        typeAdapter = TokenAdapter.class
57    )
58    @ValueConstraints(
59        allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "component", description = "Component"), @AllowedValue(value = "inventory-item", description = "Inventory Item"), @AllowedValue(value = "location", description = "Location"), @AllowedValue(value = "party", description = "Interview Party"), @AllowedValue(value = "user", description = "User"), @AllowedValue(value = "resource", description = "Resource or Artifact")})
60    )
61    private String _type;
62  
63    /**
64     * "The title or name for the referenced subject."
65     */
66    @BoundField(
67        formalName = "Subject Reference Title",
68        description = "The title or name for the referenced subject.",
69        useName = "title"
70    )
71    @BoundFieldValue(
72        typeAdapter = MarkupLineAdapter.class
73    )
74    private MarkupLine _title;
75  
76    @BoundAssembly(
77        formalName = "Property",
78        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
79        useName = "prop",
80        maxOccurs = -1
81    )
82    @GroupAs(
83        name = "props",
84        inJson = JsonGroupAsBehavior.LIST
85    )
86    private List<Property> _props;
87  
88    @BoundAssembly(
89        formalName = "Link",
90        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
91        useName = "link",
92        maxOccurs = -1
93    )
94    @GroupAs(
95        name = "links",
96        inJson = JsonGroupAsBehavior.LIST
97    )
98    private List<Link> _links;
99  
100   @BoundField(
101       formalName = "Remarks",
102       description = "Additional commentary about the containing object.",
103       useName = "remarks"
104   )
105   @BoundFieldValue(
106       typeAdapter = MarkupMultilineAdapter.class
107   )
108   private MarkupMultiline _remarks;
109 
110   public SubjectReference() {
111   }
112 
113   public UUID getSubjectUuid() {
114     return _subjectUuid;
115   }
116 
117   public void setSubjectUuid(UUID value) {
118     _subjectUuid = value;
119   }
120 
121   public String getType() {
122     return _type;
123   }
124 
125   public void setType(String value) {
126     _type = value;
127   }
128 
129   public MarkupLine getTitle() {
130     return _title;
131   }
132 
133   public void setTitle(MarkupLine value) {
134     _title = value;
135   }
136 
137   public List<Property> getProps() {
138     return _props;
139   }
140 
141   public void setProps(List<Property> value) {
142     _props = value;
143   }
144 
145   /**
146    * Add a new {@link Property} item to the underlying collection.
147    * @param item the item to add
148    * @return {@code true}
149    */
150   public boolean addProp(Property item) {
151     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
152     if (_props == null) {
153       _props = new LinkedList<>();
154     }
155     return _props.add(value);
156   }
157 
158   /**
159    * Remove the first matching {@link Property} item from the underlying collection.
160    * @param item the item to remove
161    * @return {@code true} if the item was removed or {@code false} otherwise
162    */
163   public boolean removeProp(Property item) {
164     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
165     return _props == null ? false : _props.remove(value);
166   }
167 
168   public List<Link> getLinks() {
169     return _links;
170   }
171 
172   public void setLinks(List<Link> value) {
173     _links = value;
174   }
175 
176   /**
177    * Add a new {@link Link} item to the underlying collection.
178    * @param item the item to add
179    * @return {@code true}
180    */
181   public boolean addLink(Link item) {
182     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
183     if (_links == null) {
184       _links = new LinkedList<>();
185     }
186     return _links.add(value);
187   }
188 
189   /**
190    * Remove the first matching {@link Link} item from the underlying collection.
191    * @param item the item to remove
192    * @return {@code true} if the item was removed or {@code false} otherwise
193    */
194   public boolean removeLink(Link item) {
195     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
196     return _links == null ? false : _links.remove(value);
197   }
198 
199   public MarkupMultiline getRemarks() {
200     return _remarks;
201   }
202 
203   public void setRemarks(MarkupMultiline value) {
204     _remarks = value;
205   }
206 
207   @Override
208   public String toString() {
209     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
210   }
211 }