From ca0191d050b3dac6e65815ad5662ed8e796ef9d9 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Thu, 29 Oct 2020 12:44:07 +0100 Subject: fix for the Android Java SDK bug in getDeclaredFields nor providing the field order --- src/net/gcdc/asn1/datatypes/FieldOrder.java | 13 +++ src/net/gcdc/asn1/test/UperEncodeBooleanTest.java | 3 +- .../asn1/test/UperEncodeChoiceExtensionTest.java | 3 + src/net/gcdc/asn1/test/UperEncodeChoiceTest.java | 3 + .../asn1/test/UperEncodeEnumExtensionTest.java | 2 + src/net/gcdc/asn1/test/UperEncodeEnumTest.java | 2 + .../test/UperEncodeExtensionFieldOrderTest.java | 102 +++++++++++++++++++++ .../gcdc/asn1/test/UperEncodeFieldOrderTest.java | 68 ++++++++++++++ .../test/UperEncodeIntegerConstrainedTest.java | 4 + .../asn1/test/UperEncodeIntegerExtensionTest.java | 28 ++---- .../gcdc/asn1/test/UperEncodeIntegerSmallTest.java | 3 + src/net/gcdc/asn1/test/UperEncodeIntegerTest.java | 2 + .../asn1/test/UperEncodeObjectIdentifierTest.java | 4 + .../gcdc/asn1/test/UperEncodeOctetStringTest.java | 2 + .../UperEncodeOptionalSequenceExtensionTest.java | 3 + .../asn1/test/UperEncodeRestrictedIntegerTest.java | 2 + .../asn1/test/UperEncodeSequenceExtensionTest.java | 4 + .../asn1/test/UperEncodeSequenceOfIntegerTest.java | 3 +- .../UperEncodeSequenceOfRestrictedIntegerTest.java | 2 + .../test/UperEncodeSequenceOfStringListTest.java | 2 + .../asn1/test/UperEncodeSequenceOfStringTest.java | 3 +- .../test/UperEncodeSequenceOfUtf8StringTest.java | 3 +- .../asn1/test/UperEncodeStringDefaultTest.java | 3 + .../gcdc/asn1/test/UperEncodeStringLengthTest.java | 2 + src/net/gcdc/asn1/test/UperEncodeStringTest.java | 33 +++++-- src/net/gcdc/asn1/uper/UperEncoder.java | 29 +++++- 26 files changed, 297 insertions(+), 31 deletions(-) create mode 100644 src/net/gcdc/asn1/datatypes/FieldOrder.java create mode 100644 src/net/gcdc/asn1/test/UperEncodeExtensionFieldOrderTest.java create mode 100644 src/net/gcdc/asn1/test/UperEncodeFieldOrderTest.java (limited to 'src/net/gcdc') diff --git a/src/net/gcdc/asn1/datatypes/FieldOrder.java b/src/net/gcdc/asn1/datatypes/FieldOrder.java new file mode 100644 index 0000000..23fb8fa --- /dev/null +++ b/src/net/gcdc/asn1/datatypes/FieldOrder.java @@ -0,0 +1,13 @@ +package net.gcdc.asn1.datatypes; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface FieldOrder { + int order() default -1; +} + diff --git a/src/net/gcdc/asn1/test/UperEncodeBooleanTest.java b/src/net/gcdc/asn1/test/UperEncodeBooleanTest.java index 9716474..b9ca590 100644 --- a/src/net/gcdc/asn1/test/UperEncodeBooleanTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeBooleanTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -25,7 +26,7 @@ public class UperEncodeBooleanTest { @Sequence public static class TestRecord { - + @FieldOrder(order = 0) @Asn1Optional() Boolean value; public TestRecord() { diff --git a/src/net/gcdc/asn1/test/UperEncodeChoiceExtensionTest.java b/src/net/gcdc/asn1/test/UperEncodeChoiceExtensionTest.java index acbbd0b..19cdb63 100644 --- a/src/net/gcdc/asn1/test/UperEncodeChoiceExtensionTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeChoiceExtensionTest.java @@ -7,6 +7,7 @@ import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1Optional; import net.gcdc.asn1.datatypes.CharacterRestriction; import net.gcdc.asn1.datatypes.Choice; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.HasExtensionMarker; import net.gcdc.asn1.datatypes.IsExtension; import net.gcdc.asn1.datatypes.RestrictedString; @@ -30,9 +31,11 @@ public class UperEncodeChoiceExtensionTest { @HasExtensionMarker public static class TestRecordExtended { + @FieldOrder(order = 0) @RestrictedString(CharacterRestriction.IA5String) String value1 = null; + @FieldOrder(order = 1) @IsExtension @RestrictedString(CharacterRestriction.IA5String) String value2 = "extension"; diff --git a/src/net/gcdc/asn1/test/UperEncodeChoiceTest.java b/src/net/gcdc/asn1/test/UperEncodeChoiceTest.java index d35e717..8dc8ce1 100644 --- a/src/net/gcdc/asn1/test/UperEncodeChoiceTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeChoiceTest.java @@ -6,6 +6,7 @@ import java.util.logging.Level; import net.gcdc.asn1.datatypes.CharacterRestriction; import net.gcdc.asn1.datatypes.Choice; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.RestrictedString; import net.gcdc.asn1.uper.UperEncoder; @@ -31,9 +32,11 @@ public class UperEncodeChoiceTest { @Choice public static class TestRecord { + @FieldOrder(order = 0) @RestrictedString(CharacterRestriction.UTF8String) String valueUtf8; + @FieldOrder(order = 1) @RestrictedString(CharacterRestriction.IA5String) String valueIA5; diff --git a/src/net/gcdc/asn1/test/UperEncodeEnumExtensionTest.java b/src/net/gcdc/asn1/test/UperEncodeEnumExtensionTest.java index c098839..4b91f8e 100644 --- a/src/net/gcdc/asn1/test/UperEncodeEnumExtensionTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeEnumExtensionTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.HasExtensionMarker; import net.gcdc.asn1.datatypes.IsExtension; import net.gcdc.asn1.datatypes.Sequence; @@ -35,6 +36,7 @@ public class UperEncodeEnumExtensionTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @Asn1Optional EnumType value = EnumType.value1; public TestRecord() {} public void setValue(EnumType value) { diff --git a/src/net/gcdc/asn1/test/UperEncodeEnumTest.java b/src/net/gcdc/asn1/test/UperEncodeEnumTest.java index 66fbc05..ce41e7a 100644 --- a/src/net/gcdc/asn1/test/UperEncodeEnumTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeEnumTest.java @@ -6,6 +6,7 @@ import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1Default; import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -32,6 +33,7 @@ public class UperEncodeEnumTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @Asn1Default(value="value2") @Asn1Optional EnumType value = EnumType.value2; diff --git a/src/net/gcdc/asn1/test/UperEncodeExtensionFieldOrderTest.java b/src/net/gcdc/asn1/test/UperEncodeExtensionFieldOrderTest.java new file mode 100644 index 0000000..3c60e9c --- /dev/null +++ b/src/net/gcdc/asn1/test/UperEncodeExtensionFieldOrderTest.java @@ -0,0 +1,102 @@ +package net.gcdc.asn1.test; + +import static org.junit.Assert.assertEquals; + +import java.util.logging.Level; + +import net.gcdc.asn1.datatypes.Asn1BigInteger; +import net.gcdc.asn1.datatypes.FieldOrder; +import net.gcdc.asn1.datatypes.HasExtensionMarker; +import net.gcdc.asn1.datatypes.IsExtension; +import net.gcdc.asn1.datatypes.Sequence; + +import net.gcdc.asn1.uper.UperEncoder; + +import org.junit.Test; + + +public class UperEncodeExtensionFieldOrderTest { + + /** + * Example from the Standard on UPER. +
+ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { + number1 INTEGER, + ..., + number2 INTEGER, + number3 INTEGER + } + + value TestRecord ::= { + value1 12345678909999899, + value2 5555555555, + value3 32001 + } + +Encoding to the file 'data.uper' using PER UNALIGNED encoding rule... +TestRecord SEQUENCE [root fieldcount (not encoded) = 1] + value1 INTEGER [length = 7.0] + 12345678909999899 + value2 INTEGER [length = 5.0] + 5555555555 + value3 INTEGER [length = 2.0] + 32001 +Total encoded length = 20.2 +Encoded successfully in 21 bytes: +8395EE2A 2EF8858D 81C18140 52C8C338 C0C09F40 40 + + ++ */ + @Sequence + @HasExtensionMarker + public static class TestRecord { + + @FieldOrder(order = 0) + Asn1BigInteger value1; + + @FieldOrder(order = 1) + @IsExtension + Asn1BigInteger value2; + + @FieldOrder(order = 2) + @IsExtension + Asn1BigInteger value3; + + public TestRecord() { + value1 = new Asn1BigInteger(12345678909999899L); + value2 = new Asn1BigInteger(5555555555L); + value3 = new Asn1BigInteger(32001L); + } + + + } + + + @Test public void test() throws IllegalArgumentException, IllegalAccessException { + + TestRecord record = new TestRecord(); + byte[] encoded = UperEncoder.encode(record); + String hex = UperEncoder.hexStringFromBytes(encoded); + UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); + assertEquals("8395EE2A2EF8858D81C1814052C8C338C0C09F4040",hex); + + + } + + @Test public void testDecode() throws IllegalArgumentException, IllegalAccessException { + + TestRecord record = new TestRecord(); + byte[] encoded = UperEncoder.encode(record); + String hex = UperEncoder.hexStringFromBytes(encoded); + UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); + assertEquals("8395EE2A2EF8858D81C1814052C8C338C0C09F4040",hex); + + TestRecord result = UperEncoder.decode(encoded, TestRecord.class); + assertEquals(result.value1.longValue(),record.value1.longValue()); + assertEquals(result.value2.longValue(),record.value2.longValue()); + assertEquals(result.value3.longValue(),record.value3.longValue()); + + } + +} diff --git a/src/net/gcdc/asn1/test/UperEncodeFieldOrderTest.java b/src/net/gcdc/asn1/test/UperEncodeFieldOrderTest.java new file mode 100644 index 0000000..e535356 --- /dev/null +++ b/src/net/gcdc/asn1/test/UperEncodeFieldOrderTest.java @@ -0,0 +1,68 @@ +package net.gcdc.asn1.test; + +import static org.junit.Assert.assertEquals; + +import java.util.logging.Level; + +import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.FieldOrder; +import net.gcdc.asn1.datatypes.RestrictedString; +import net.gcdc.asn1.datatypes.Sequence; + +import net.gcdc.asn1.uper.UperEncoder; + +import org.junit.Test; + + +public class UperEncodeFieldOrderTest { + + /** + * Example from the Standard on UPER. +
+ World-Schema DEFINITIONS AUTOMATIC TAGS ::= + BEGIN + TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { + testString1 UTF8String OPTIONAL, + testString2 IA5String OPTIONAL + } + END ++ */ + @Sequence + public static class TestRecord { + + @FieldOrder(order = 1) + @RestrictedString(CharacterRestriction.IA5String) + @Asn1Optional() String string2; + + @FieldOrder(order = 0) + @RestrictedString(CharacterRestriction.UTF8String) + @Asn1Optional() String string1; + + + public TestRecord() { + } + + public TestRecord(String utf8, String ia5) { + this.string1 = utf8; + this.string2 = ia5; + } + } + + + @Test public void test() throws IllegalArgumentException, IllegalAccessException { + + TestRecord record = new TestRecord("String1", "String2"); + byte[] encoded = UperEncoder.encode(record); + + TestRecord result = UperEncoder.decode(encoded, TestRecord.class); + assertEquals(result.string1,"String1"); + assertEquals(result.string2,"String2"); + } + + + + + +} diff --git a/src/net/gcdc/asn1/test/UperEncodeIntegerConstrainedTest.java b/src/net/gcdc/asn1/test/UperEncodeIntegerConstrainedTest.java index 9450406..6c6a4af 100644 --- a/src/net/gcdc/asn1/test/UperEncodeIntegerConstrainedTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeIntegerConstrainedTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.IntRange; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -26,12 +27,15 @@ public class UperEncodeIntegerConstrainedTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @IntRange(minValue=1, maxValue=999) public Long value1; + @FieldOrder(order = 1) @IntRange(minValue=0, maxValue=999) public Long value2; + @FieldOrder(order = 2) @IntRange(minValue=63, maxValue=999) public Long value3; diff --git a/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java b/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java index 5a33368..4c87bae 100644 --- a/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1BigInteger; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.HasExtensionMarker; import net.gcdc.asn1.datatypes.IsExtension; import net.gcdc.asn1.datatypes.Sequence; @@ -51,14 +52,17 @@ Encoded successfully in 21 bytes: @HasExtensionMarker public static class TestRecord { - + @FieldOrder(order = 0) Asn1BigInteger value1; + @FieldOrder(order = 2) + @IsExtension + Asn1BigInteger value3; + + @FieldOrder(order = 1) @IsExtension Asn1BigInteger value2; - @IsExtension - Asn1BigInteger value3; public TestRecord() { value1 = new Asn1BigInteger(12345678909999899L); @@ -74,26 +78,14 @@ Encoded successfully in 21 bytes: TestRecord record = new TestRecord(); byte[] encoded = UperEncoder.encode(record); - String hex = UperEncoder.hexStringFromBytes(encoded); - UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); - assertEquals("8395EE2A2EF8858D81C1814052C8C338C0C09F4040",hex); - - - } - - @Test public void testDecode() throws IllegalArgumentException, IllegalAccessException { - - TestRecord record = new TestRecord(); - byte[] encoded = UperEncoder.encode(record); - String hex = UperEncoder.hexStringFromBytes(encoded); - UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); - assertEquals("8395EE2A2EF8858D81C1814052C8C338C0C09F4040",hex); - TestRecord result = UperEncoder.decode(encoded, TestRecord.class); assertEquals(result.value1.longValue(),record.value1.longValue()); assertEquals(result.value2.longValue(),record.value2.longValue()); assertEquals(result.value3.longValue(),record.value3.longValue()); + } + + } diff --git a/src/net/gcdc/asn1/test/UperEncodeIntegerSmallTest.java b/src/net/gcdc/asn1/test/UperEncodeIntegerSmallTest.java index 9ad0e63..c34918f 100644 --- a/src/net/gcdc/asn1/test/UperEncodeIntegerSmallTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeIntegerSmallTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -25,8 +26,10 @@ public class UperEncodeIntegerSmallTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) public Long value1; + @FieldOrder(order = 1) public Integer value2; public TestRecord() { diff --git a/src/net/gcdc/asn1/test/UperEncodeIntegerTest.java b/src/net/gcdc/asn1/test/UperEncodeIntegerTest.java index 4eab78a..f4f56f6 100644 --- a/src/net/gcdc/asn1/test/UperEncodeIntegerTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeIntegerTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1BigInteger; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -25,6 +26,7 @@ public class UperEncodeIntegerTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) Asn1BigInteger value; public TestRecord() { diff --git a/src/net/gcdc/asn1/test/UperEncodeObjectIdentifierTest.java b/src/net/gcdc/asn1/test/UperEncodeObjectIdentifierTest.java index c46751d..d36cfe6 100644 --- a/src/net/gcdc/asn1/test/UperEncodeObjectIdentifierTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeObjectIdentifierTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import net.gcdc.asn1.datatypes.Asn1Optional; import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.RestrictedString; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -34,12 +35,15 @@ class UperEncodeObjectIdentifierTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @RestrictedString(CharacterRestriction.ObjectIdentifier) String value1 = "2.16.840.1.101.3.4.3.1"; //DSA SHA224 + @FieldOrder(order = 1) @RestrictedString(CharacterRestriction.ObjectIdentifier) String value2 = "2.16.840.1.101.3.4.3.2"; //DSA SHA248 + @FieldOrder(order = 2) @RestrictedString(CharacterRestriction.ObjectIdentifier) String value3 = "1.2.840.10045.3.1.7"; //ECC diff --git a/src/net/gcdc/asn1/test/UperEncodeOctetStringTest.java b/src/net/gcdc/asn1/test/UperEncodeOctetStringTest.java index 7604d6a..eb92373 100644 --- a/src/net/gcdc/asn1/test/UperEncodeOctetStringTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeOctetStringTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.datatypesimpl.OctetString; @@ -39,6 +40,7 @@ public class UperEncodeOctetStringTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) OctetString value; public TestRecord() { diff --git a/src/net/gcdc/asn1/test/UperEncodeOptionalSequenceExtensionTest.java b/src/net/gcdc/asn1/test/UperEncodeOptionalSequenceExtensionTest.java index 1b2fa09..4e82a82 100644 --- a/src/net/gcdc/asn1/test/UperEncodeOptionalSequenceExtensionTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeOptionalSequenceExtensionTest.java @@ -6,6 +6,7 @@ import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1Optional; import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.HasExtensionMarker; import net.gcdc.asn1.datatypes.IsExtension; import net.gcdc.asn1.datatypes.RestrictedString; @@ -32,9 +33,11 @@ public class UperEncodeOptionalSequenceExtensionTest { @HasExtensionMarker public static class TestRecordExtended { + @FieldOrder(order = 0) @RestrictedString(CharacterRestriction.IA5String) String value1; + @FieldOrder(order = 1) @IsExtension @RestrictedString(CharacterRestriction.IA5String) @Asn1Optional() String value2; diff --git a/src/net/gcdc/asn1/test/UperEncodeRestrictedIntegerTest.java b/src/net/gcdc/asn1/test/UperEncodeRestrictedIntegerTest.java index 27dc5f4..7463214 100644 --- a/src/net/gcdc/asn1/test/UperEncodeRestrictedIntegerTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeRestrictedIntegerTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.IntRange; import net.gcdc.asn1.datatypes.Sequence; @@ -25,6 +26,7 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @IntRange(maxValue = 63000, minValue = 33000) Long value; diff --git a/src/net/gcdc/asn1/test/UperEncodeSequenceExtensionTest.java b/src/net/gcdc/asn1/test/UperEncodeSequenceExtensionTest.java index 7934354..8c5131b 100644 --- a/src/net/gcdc/asn1/test/UperEncodeSequenceExtensionTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeSequenceExtensionTest.java @@ -6,6 +6,7 @@ import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1Optional; import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.HasExtensionMarker; import net.gcdc.asn1.datatypes.IsExtension; import net.gcdc.asn1.datatypes.RestrictedString; @@ -29,13 +30,16 @@ public class UperEncodeSequenceExtensionTest { @HasExtensionMarker public static class TestRecordExtended { + @FieldOrder(order = 0) @RestrictedString(CharacterRestriction.IA5String) @Asn1Optional() String value1 = "regular"; + @FieldOrder(order = 1) @IsExtension @RestrictedString(CharacterRestriction.IA5String) @Asn1Optional() String value2 = "extension"; + public TestRecordExtended() { } } diff --git a/src/net/gcdc/asn1/test/UperEncodeSequenceOfIntegerTest.java b/src/net/gcdc/asn1/test/UperEncodeSequenceOfIntegerTest.java index 6028a29..40a3772 100644 --- a/src/net/gcdc/asn1/test/UperEncodeSequenceOfIntegerTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeSequenceOfIntegerTest.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Level; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.datatypesimpl.SequenceOfUnrestrictedLong; @@ -27,7 +28,7 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Sequence public static class TestRecord { - + @FieldOrder(order = 0) SequenceOfUnrestrictedLong numbers; public TestRecord() { diff --git a/src/net/gcdc/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java b/src/net/gcdc/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java index 5ac9834..c1feece 100644 --- a/src/net/gcdc/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.IntRange; import net.gcdc.asn1.datatypes.Sequence; @@ -25,6 +26,7 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @IntRange(minValue=9500000,maxValue=99900001) TestSequenceOfLong numbers = null;; diff --git a/src/net/gcdc/asn1/test/UperEncodeSequenceOfStringListTest.java b/src/net/gcdc/asn1/test/UperEncodeSequenceOfStringListTest.java index 1a8f68e..4bc0cb9 100644 --- a/src/net/gcdc/asn1/test/UperEncodeSequenceOfStringListTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeSequenceOfStringListTest.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.logging.Level; import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.RestrictedString; import net.gcdc.asn1.datatypes.Sequence; import net.gcdc.asn1.uper.UperEncoder; @@ -27,6 +28,7 @@ public class UperEncodeSequenceOfStringListTest { @Sequence public static class TestRecord { + @FieldOrder(order = 0) @RestrictedString(CharacterRestriction.IA5String) ArrayList