001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.NonNegativeIntegerAdapter; 004import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter; 005import gov.nist.secauto.metaschema.core.model.IBoundObject; 006import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 007import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 008import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue; 009import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues; 010import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 011import gov.nist.secauto.metaschema.databind.model.annotations.Expect; 012import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 013import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 014import java.lang.Override; 015import java.lang.String; 016import java.math.BigInteger; 017import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 018import org.apache.commons.lang3.builder.ToStringStyle; 019 020/** 021 * Where applicable this is the transport layer protocol port range an IPv4-based or IPv6-based service uses. 022 */ 023@MetaschemaAssembly( 024 formalName = "Port Range", 025 description = "Where applicable this is the transport layer protocol port range an IPv4-based or IPv6-based service uses.", 026 name = "port-range", 027 moduleClass = OscalImplementationCommonModule.class, 028 remarks = "To be validated as a natural number (integer \\>= 1). A single port uses the same value for start and end. Use multiple 'port-range' entries for non-contiguous ranges.", 029 valueConstraints = @ValueConstraints(expect = {@Expect(id = "port-range-has-start", level = IConstraint.Level.WARNING, test = "exists(@start)", message = "A port range should have a start port given."), @Expect(id = "port-range-has-end", level = IConstraint.Level.WARNING, test = "exists(@end)", message = "A port range should have an end port given. To define a single port, the start and end should be the same value."), @Expect(id = "port-range-starts-before-end", level = IConstraint.Level.WARNING, test = "not(@start > @end)", message = "The port range start should not be after its end.")}) 030) 031public class PortRange implements IBoundObject { 032 private final IMetaschemaData __metaschemaData; 033 034 /** 035 * "Indicates the starting port number in a port range for a transport layer protocol" 036 */ 037 @BoundFlag( 038 formalName = "Start", 039 description = "Indicates the starting port number in a port range for a transport layer protocol", 040 name = "start", 041 typeAdapter = NonNegativeIntegerAdapter.class, 042 remarks = "Should be a number within a permitted range" 043 ) 044 private BigInteger _start; 045 046 /** 047 * "Indicates the ending port number in a port range for a transport layer protocol" 048 */ 049 @BoundFlag( 050 formalName = "End", 051 description = "Indicates the ending port number in a port range for a transport layer protocol", 052 name = "end", 053 typeAdapter = NonNegativeIntegerAdapter.class, 054 remarks = "Should be a number within a permitted range" 055 ) 056 private BigInteger _end; 057 058 /** 059 * "Indicates the transport type." 060 */ 061 @BoundFlag( 062 formalName = "Transport", 063 description = "Indicates the transport type.", 064 name = "transport", 065 typeAdapter = TokenAdapter.class, 066 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "TCP", description = "Transmission Control Protocol"), @AllowedValue(value = "UDP", description = "User Datagram Protocol")})) 067 ) 068 private String _transport; 069 070 public PortRange() { 071 this(null); 072 } 073 074 public PortRange(IMetaschemaData data) { 075 this.__metaschemaData = data; 076 } 077 078 @Override 079 public IMetaschemaData getMetaschemaData() { 080 return __metaschemaData; 081 } 082 083 public BigInteger getStart() { 084 return _start; 085 } 086 087 public void setStart(BigInteger value) { 088 _start = value; 089 } 090 091 public BigInteger getEnd() { 092 return _end; 093 } 094 095 public void setEnd(BigInteger value) { 096 _end = value; 097 } 098 099 public String getTransport() { 100 return _transport; 101 } 102 103 public void setTransport(String value) { 104 _transport = value; 105 } 106 107 @Override 108 public String toString() { 109 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 110 } 111}