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 IPv4 port range on which the service operates. 022 */ 023@MetaschemaAssembly( 024 formalName = "Port Range", 025 description = "Where applicable this is the IPv4 port range on which the service operates.", 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-start-and-end-not-specified", level = IConstraint.Level.WARNING, test = "exists(@start) and exists(@end)", message = "If a protocol is defined, it should include a start and end port range. To define a single port, the start and end should be the same value."), @Expect(id = "port-range-start-specified-with-no-end", level = IConstraint.Level.WARNING, test = "exists(@start) and not(exists(@end))", message = "A start port exists, but an end point does not. To define a single port, the start and end should be the same value."), @Expect(id = "port-range-end-specified-with-no-start", level = IConstraint.Level.WARNING, test = "not(exists(@start)) and exists(@end)", message = "An end point exists, but a start port does not. To define a single port, the start and end should be the same value."), @Expect(id = "port-range-end-date-is-before-start-date", level = IConstraint.Level.WARNING, test = "@start <= @end", message = "The port range specified has an end port that is less than the start port.")}) 030) 031public class PortRange implements IBoundObject { 032 private final IMetaschemaData __metaschemaData; 033 034 /** 035 * "Indicates the starting port number in a port range" 036 */ 037 @BoundFlag( 038 formalName = "Start", 039 description = "Indicates the starting port number in a port range", 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" 048 */ 049 @BoundFlag( 050 formalName = "End", 051 description = "Indicates the ending port number in a port range", 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}