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