001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 004import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 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.markup.MarkupLine; 009import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter; 010import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 011import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 012import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 013import java.lang.Override; 014import java.lang.String; 015import java.util.LinkedList; 016import java.util.List; 017import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 018import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 019 020/** 021 * Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege. 022 */ 023@MetaschemaAssembly( 024 formalName = "Privilege", 025 description = "Identifies a specific system privilege held by the user, along with an associated description and/or rationale for the privilege.", 026 name = "authorized-privilege", 027 metaschema = OscalImplementationCommonMetaschema.class 028) 029public class AuthorizedPrivilege { 030 /** 031 * "A human readable name for the privilege." 032 */ 033 @BoundField( 034 formalName = "Privilege Title", 035 description = "A human readable name for the privilege.", 036 useName = "title", 037 minOccurs = 1 038 ) 039 @BoundFieldValue( 040 typeAdapter = MarkupLineAdapter.class 041 ) 042 private MarkupLine _title; 043 044 /** 045 * "A summary of the privilege's purpose within the system." 046 */ 047 @BoundField( 048 formalName = "Privilege Description", 049 description = "A summary of the privilege's purpose within the system.", 050 useName = "description" 051 ) 052 @BoundFieldValue( 053 typeAdapter = MarkupMultilineAdapter.class 054 ) 055 private MarkupMultiline _description; 056 057 @BoundField( 058 formalName = "Functions Performed", 059 description = "Describes a function performed for a given authorized privilege by this user class.", 060 useName = "function-performed", 061 minOccurs = 1, 062 maxOccurs = -1 063 ) 064 @GroupAs( 065 name = "functions-performed", 066 inJson = JsonGroupAsBehavior.LIST 067 ) 068 private List<String> _functionsPerformed; 069 070 public AuthorizedPrivilege() { 071 } 072 073 public MarkupLine getTitle() { 074 return _title; 075 } 076 077 public void setTitle(MarkupLine value) { 078 _title = value; 079 } 080 081 public MarkupMultiline getDescription() { 082 return _description; 083 } 084 085 public void setDescription(MarkupMultiline value) { 086 _description = value; 087 } 088 089 public List<String> getFunctionsPerformed() { 090 return _functionsPerformed; 091 } 092 093 public void setFunctionsPerformed(List<String> value) { 094 _functionsPerformed = value; 095 } 096 097 /** 098 * Add a new {@link String} item to the underlying collection. 099 * @param item the item to add 100 * @return {@code true} 101 */ 102 public boolean addFunctionPerformed(String item) { 103 String value = ObjectUtils.requireNonNull(item,"item cannot be null"); 104 if (_functionsPerformed == null) { 105 _functionsPerformed = new LinkedList<>(); 106 } 107 return _functionsPerformed.add(value); 108 } 109 110 /** 111 * Remove the first matching {@link String} item from the underlying collection. 112 * @param item the item to remove 113 * @return {@code true} if the item was removed or {@code false} otherwise 114 */ 115 public boolean removeFunctionPerformed(String item) { 116 String value = ObjectUtils.requireNonNull(item,"item cannot be null"); 117 return _functionsPerformed == null ? false : _functionsPerformed.remove(value); 118 } 119 120 @Override 121 public String toString() { 122 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 123 } 124}