001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue; 004import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 007import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 008import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 009import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints; 010import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 011import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 012import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter; 013import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter; 014import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 015import java.lang.Override; 016import java.lang.String; 017import java.util.LinkedList; 018import java.util.List; 019import java.util.UUID; 020import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 021import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 022 023/** 024 * The actor that produces an observation, a finding, or a risk. One or more actor type can be used to specify a person that is using a tool. 025 */ 026@MetaschemaAssembly( 027 formalName = "Originating Actor", 028 description = "The actor that produces an observation, a finding, or a risk. One or more actor type can be used to specify a person that is using a tool.", 029 name = "origin-actor", 030 metaschema = OscalAssessmentCommonMetaschema.class 031) 032public class OriginActor { 033 @BoundFlag( 034 formalName = "Actor Type", 035 description = "The kind of actor.", 036 useName = "type", 037 required = true, 038 typeAdapter = TokenAdapter.class 039 ) 040 @ValueConstraints( 041 allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "tool", description = "A reference to a tool component defined with the assessment assets."), @AllowedValue(value = "assessment-platform", description = "A reference to an assessment-platform defined with the assessment assets."), @AllowedValue(value = "party", description = "A reference to a party defined within the document metadata.")}) 042 ) 043 private String _type; 044 045 @BoundFlag( 046 formalName = "Actor Universally Unique Identifier Reference", 047 description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to the tool or person based on the associated type.", 048 useName = "actor-uuid", 049 required = true, 050 typeAdapter = UuidAdapter.class 051 ) 052 private UUID _actorUuid; 053 054 @BoundFlag( 055 formalName = "Actor Role", 056 description = "For a party, this can optionally be used to specify the role the actor was performing.", 057 useName = "role-id", 058 typeAdapter = TokenAdapter.class 059 ) 060 private String _roleId; 061 062 @BoundAssembly( 063 formalName = "Property", 064 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 065 useName = "prop", 066 maxOccurs = -1 067 ) 068 @GroupAs( 069 name = "props", 070 inJson = JsonGroupAsBehavior.LIST 071 ) 072 private List<Property> _props; 073 074 @BoundAssembly( 075 formalName = "Link", 076 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 077 useName = "link", 078 maxOccurs = -1 079 ) 080 @GroupAs( 081 name = "links", 082 inJson = JsonGroupAsBehavior.LIST 083 ) 084 private List<Link> _links; 085 086 public OriginActor() { 087 } 088 089 public String getType() { 090 return _type; 091 } 092 093 public void setType(String value) { 094 _type = value; 095 } 096 097 public UUID getActorUuid() { 098 return _actorUuid; 099 } 100 101 public void setActorUuid(UUID value) { 102 _actorUuid = value; 103 } 104 105 public String getRoleId() { 106 return _roleId; 107 } 108 109 public void setRoleId(String value) { 110 _roleId = value; 111 } 112 113 public List<Property> getProps() { 114 return _props; 115 } 116 117 public void setProps(List<Property> value) { 118 _props = value; 119 } 120 121 /** 122 * Add a new {@link Property} item to the underlying collection. 123 * @param item the item to add 124 * @return {@code true} 125 */ 126 public boolean addProp(Property item) { 127 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 128 if (_props == null) { 129 _props = new LinkedList<>(); 130 } 131 return _props.add(value); 132 } 133 134 /** 135 * Remove the first matching {@link Property} item from the underlying collection. 136 * @param item the item to remove 137 * @return {@code true} if the item was removed or {@code false} otherwise 138 */ 139 public boolean removeProp(Property item) { 140 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 141 return _props == null ? false : _props.remove(value); 142 } 143 144 public List<Link> getLinks() { 145 return _links; 146 } 147 148 public void setLinks(List<Link> value) { 149 _links = value; 150 } 151 152 /** 153 * Add a new {@link Link} item to the underlying collection. 154 * @param item the item to add 155 * @return {@code true} 156 */ 157 public boolean addLink(Link item) { 158 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 159 if (_links == null) { 160 _links = new LinkedList<>(); 161 } 162 return _links.add(value); 163 } 164 165 /** 166 * Remove the first matching {@link Link} item from the underlying collection. 167 * @param item the item to remove 168 * @return {@code true} if the item was removed or {@code false} otherwise 169 */ 170 public boolean removeLink(Link item) { 171 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 172 return _links == null ? false : _links.remove(value); 173 } 174 175 @Override 176 public String toString() { 177 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 178 } 179}