View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
6   import gov.nist.secauto.metaschema.binding.model.annotations.Expect;
7   import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
8   import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
9   import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
10  import gov.nist.secauto.metaschema.model.common.datatype.adapter.NonNegativeIntegerAdapter;
11  import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
12  import java.lang.Override;
13  import java.lang.String;
14  import java.math.BigInteger;
15  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
16  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
17  
18  /**
19   * Where applicable this is the IPv4 port range on which the service operates.
20   */
21  @MetaschemaAssembly(
22      formalName = "Port Range",
23      description = "Where applicable this is the IPv4 port range on which the service operates.",
24      name = "port-range",
25      metaschema = OscalImplementationCommonMetaschema.class,
26      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."
27  )
28  @ValueConstraints(
29      expect = {
30          @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."),
31          @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."),
32          @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."),
33          @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.")
34      }
35  )
36  public class PortRange {
37    @BoundFlag(
38        formalName = "Start",
39        description = "Indicates the starting port number in a port range",
40        useName = "start",
41        typeAdapter = NonNegativeIntegerAdapter.class,
42        remarks = "Should be a number within a permitted range"
43    )
44    private BigInteger _start;
45  
46    @BoundFlag(
47        formalName = "End",
48        description = "Indicates the ending port number in a port range",
49        useName = "end",
50        typeAdapter = NonNegativeIntegerAdapter.class,
51        remarks = "Should be a number within a permitted range"
52    )
53    private BigInteger _end;
54  
55    @BoundFlag(
56        formalName = "Transport",
57        description = "Indicates the transport type.",
58        useName = "transport",
59        typeAdapter = TokenAdapter.class
60    )
61    @ValueConstraints(
62        allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "TCP", description = "Transmission Control Protocol"), @AllowedValue(value = "UDP", description = "User Datagram Protocol")})
63    )
64    private String _transport;
65  
66    public PortRange() {
67    }
68  
69    public BigInteger getStart() {
70      return _start;
71    }
72  
73    public void setStart(BigInteger value) {
74      _start = value;
75    }
76  
77    public BigInteger getEnd() {
78      return _end;
79    }
80  
81    public void setEnd(BigInteger value) {
82      _end = value;
83    }
84  
85    public String getTransport() {
86      return _transport;
87    }
88  
89    public void setTransport(String value) {
90      _transport = value;
91    }
92  
93    @Override
94    public String toString() {
95      return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
96    }
97  }