001package gov.nist.secauto.oscal.lib.model;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter;
004import gov.nist.secauto.metaschema.core.model.IBoundObject;
005import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
006import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
007import gov.nist.secauto.metaschema.core.util.ObjectUtils;
008import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
009import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
010import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
011import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
012import java.lang.Override;
013import java.lang.String;
014import java.util.LinkedList;
015import java.util.List;
016import java.util.UUID;
017import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
018import org.apache.commons.lang3.builder.ToStringStyle;
019
020/**
021 * Each OSCAL profile is defined by a <code>profile</code> element.
022 */
023@MetaschemaAssembly(
024    formalName = "Profile",
025    description = "Each OSCAL profile is defined by a `profile` element.",
026    name = "profile",
027    moduleClass = OscalProfileModule.class,
028    rootName = "profile",
029    remarks = "An OSCAL document that describes a tailoring of controls from one or more catalogs, with possible modification of multiple controls. It provides mechanisms by which controls may be selected (`import`), merged or (re)structured (`merge`), and amended (`modify`). OSCAL profiles may select subsets of controls, set parameter values for them in application, and even adjust the representation of controls as given in and by a catalog. They may also serve as sources for further modification in and by other profiles, that import them."
030)
031public class Profile extends AbstractOscalInstance implements IBoundObject {
032  private final IMetaschemaData __metaschemaData;
033
034  /**
035   * "Provides a globally unique means to identify a given profile instance."
036   */
037  @BoundFlag(
038      formalName = "Profile Universally Unique Identifier",
039      description = "Provides a globally unique means to identify a given profile instance.",
040      name = "uuid",
041      required = true,
042      typeAdapter = UuidAdapter.class
043  )
044  private UUID _uuid;
045
046  @BoundAssembly(
047      formalName = "Document Metadata",
048      description = "Provides information about the containing document, and defines concepts that are shared across the document.",
049      useName = "metadata",
050      minOccurs = 1
051  )
052  private Metadata _metadata;
053
054  @BoundAssembly(
055      formalName = "Import Resource",
056      description = "Designates a referenced source catalog or profile that provides a source of control information for use in creating a new overlay or baseline.",
057      useName = "import",
058      minOccurs = 1,
059      maxOccurs = -1,
060      groupAs = @GroupAs(name = "imports", inJson = JsonGroupAsBehavior.LIST)
061  )
062  private List<ProfileImport> _imports;
063
064  @BoundAssembly(
065      formalName = "Merge Controls",
066      description = "Provides structuring directives that instruct how controls are organized after profile resolution.",
067      useName = "merge"
068  )
069  private Merge _merge;
070
071  @BoundAssembly(
072      formalName = "Modify Controls",
073      description = "Set parameters or amend controls in resolution.",
074      useName = "modify"
075  )
076  private Modify _modify;
077
078  @BoundAssembly(
079      formalName = "Back matter",
080      description = "A collection of resources that may be referenced from within the OSCAL document instance.",
081      useName = "back-matter"
082  )
083  private BackMatter _backMatter;
084
085  public Profile() {
086    this(null);
087  }
088
089  public Profile(IMetaschemaData data) {
090    this.__metaschemaData = data;
091  }
092
093  @Override
094  public IMetaschemaData getMetaschemaData() {
095    return __metaschemaData;
096  }
097
098  public UUID getUuid() {
099    return _uuid;
100  }
101
102  public void setUuid(UUID value) {
103    _uuid = value;
104  }
105
106  public Metadata getMetadata() {
107    return _metadata;
108  }
109
110  public void setMetadata(Metadata value) {
111    _metadata = value;
112  }
113
114  public List<ProfileImport> getImports() {
115    return _imports;
116  }
117
118  public void setImports(List<ProfileImport> value) {
119    _imports = value;
120  }
121
122  /**
123   * Add a new {@link ProfileImport} item to the underlying collection.
124   * @param item the item to add
125   * @return {@code true}
126   */
127  public boolean addImport(ProfileImport item) {
128    ProfileImport value = ObjectUtils.requireNonNull(item,"item cannot be null");
129    if (_imports == null) {
130      _imports = new LinkedList<>();
131    }
132    return _imports.add(value);
133  }
134
135  /**
136   * Remove the first matching {@link ProfileImport} item from the underlying collection.
137   * @param item the item to remove
138   * @return {@code true} if the item was removed or {@code false} otherwise
139   */
140  public boolean removeImport(ProfileImport item) {
141    ProfileImport value = ObjectUtils.requireNonNull(item,"item cannot be null");
142    return _imports != null && _imports.remove(value);
143  }
144
145  public Merge getMerge() {
146    return _merge;
147  }
148
149  public void setMerge(Merge value) {
150    _merge = value;
151  }
152
153  public Modify getModify() {
154    return _modify;
155  }
156
157  public void setModify(Modify value) {
158    _modify = value;
159  }
160
161  public BackMatter getBackMatter() {
162    return _backMatter;
163  }
164
165  public void setBackMatter(BackMatter value) {
166    _backMatter = value;
167  }
168
169  @Override
170  public String toString() {
171    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
172  }
173}