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 * A description of this system's authorization boundary, optionally supplemented by diagrams that illustrate the authorization boundary.
025 */
026@MetaschemaAssembly(
027    formalName = "Authorization Boundary",
028    description = "A description of this system's authorization boundary, optionally supplemented by diagrams that illustrate the authorization boundary.",
029    name = "authorization-boundary",
030    metaschema = OscalSspMetaschema.class
031)
032@AssemblyConstraints(
033    isUnique = @IsUnique(id = "unique-ssp-authorization-boundary-diagram", level = IConstraint.Level.ERROR, target = "diagram", keyFields = @KeyField(target = "@uuid"), remarks = "A given `uuid` must be assigned only once to a diagram.")
034)
035public class AuthorizationBoundary {
036  /**
037   * "A summary of the system's authorization boundary."
038   */
039  @BoundField(
040      formalName = "Authorization Boundary Description",
041      description = "A summary of the system's authorization boundary.",
042      useName = "description",
043      minOccurs = 1
044  )
045  @BoundFieldValue(
046      typeAdapter = MarkupMultilineAdapter.class
047  )
048  private MarkupMultiline _description;
049
050  @BoundAssembly(
051      formalName = "Property",
052      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
053      useName = "prop",
054      maxOccurs = -1
055  )
056  @GroupAs(
057      name = "props",
058      inJson = JsonGroupAsBehavior.LIST
059  )
060  private List<Property> _props;
061
062  @BoundAssembly(
063      formalName = "Link",
064      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
065      useName = "link",
066      maxOccurs = -1
067  )
068  @GroupAs(
069      name = "links",
070      inJson = JsonGroupAsBehavior.LIST
071  )
072  private List<Link> _links;
073
074  @BoundAssembly(
075      formalName = "Diagram",
076      description = "A graphic that provides a visual representation the system, or some aspect of it.",
077      useName = "diagram",
078      maxOccurs = -1,
079      remarks = "A visual depiction of the system's authorization boundary."
080  )
081  @GroupAs(
082      name = "diagrams",
083      inJson = JsonGroupAsBehavior.LIST
084  )
085  private List<Diagram> _diagrams;
086
087  @BoundField(
088      formalName = "Remarks",
089      description = "Additional commentary about the containing object.",
090      useName = "remarks"
091  )
092  @BoundFieldValue(
093      typeAdapter = MarkupMultilineAdapter.class
094  )
095  private MarkupMultiline _remarks;
096
097  public AuthorizationBoundary() {
098  }
099
100  public MarkupMultiline getDescription() {
101    return _description;
102  }
103
104  public void setDescription(MarkupMultiline value) {
105    _description = value;
106  }
107
108  public List<Property> getProps() {
109    return _props;
110  }
111
112  public void setProps(List<Property> value) {
113    _props = value;
114  }
115
116  /**
117   * Add a new {@link Property} item to the underlying collection.
118   * @param item the item to add
119   * @return {@code true}
120   */
121  public boolean addProp(Property item) {
122    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
123    if (_props == null) {
124      _props = new LinkedList<>();
125    }
126    return _props.add(value);
127  }
128
129  /**
130   * Remove the first matching {@link Property} item from the underlying collection.
131   * @param item the item to remove
132   * @return {@code true} if the item was removed or {@code false} otherwise
133   */
134  public boolean removeProp(Property item) {
135    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
136    return _props == null ? false : _props.remove(value);
137  }
138
139  public List<Link> getLinks() {
140    return _links;
141  }
142
143  public void setLinks(List<Link> value) {
144    _links = value;
145  }
146
147  /**
148   * Add a new {@link Link} item to the underlying collection.
149   * @param item the item to add
150   * @return {@code true}
151   */
152  public boolean addLink(Link item) {
153    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
154    if (_links == null) {
155      _links = new LinkedList<>();
156    }
157    return _links.add(value);
158  }
159
160  /**
161   * Remove the first matching {@link Link} item from the underlying collection.
162   * @param item the item to remove
163   * @return {@code true} if the item was removed or {@code false} otherwise
164   */
165  public boolean removeLink(Link item) {
166    Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
167    return _links == null ? false : _links.remove(value);
168  }
169
170  public List<Diagram> getDiagrams() {
171    return _diagrams;
172  }
173
174  public void setDiagrams(List<Diagram> value) {
175    _diagrams = value;
176  }
177
178  /**
179   * Add a new {@link Diagram} item to the underlying collection.
180   * @param item the item to add
181   * @return {@code true}
182   */
183  public boolean addDiagram(Diagram item) {
184    Diagram value = ObjectUtils.requireNonNull(item,"item cannot be null");
185    if (_diagrams == null) {
186      _diagrams = new LinkedList<>();
187    }
188    return _diagrams.add(value);
189  }
190
191  /**
192   * Remove the first matching {@link Diagram} item from the underlying collection.
193   * @param item the item to remove
194   * @return {@code true} if the item was removed or {@code false} otherwise
195   */
196  public boolean removeDiagram(Diagram item) {
197    Diagram value = ObjectUtils.requireNonNull(item,"item cannot be null");
198    return _diagrams == null ? false : _diagrams.remove(value);
199  }
200
201  public MarkupMultiline getRemarks() {
202    return _remarks;
203  }
204
205  public void setRemarks(MarkupMultiline value) {
206    _remarks = value;
207  }
208
209  @Override
210  public String toString() {
211    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
212  }
213}