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