Search in sources :

Example 1 with PEPUKCodes

use of org.openmuc.jasn1.compiler.pedefinitions.PEPUKCodes in project jasn1 by openmuc.

the class MobileTest method puk.

@Test
public void puk() throws Exception {
    ProfileElement pukProfileElement = new ProfileElement();
    PEPUKCodes.PukCodes pukCodes = new PEPUKCodes.PukCodes(Arrays.asList(createPUK((byte) 1, "3030303030303030", (byte) 9, (byte) 9), createPUK((byte) 2, "3132333435363738"), createPUK((byte) 0x81, "3132333435363738", (byte) 8, (byte) 8)));
    PEPUKCodes pepukCodes = new PEPUKCodes(new PEHeader(new BerNull(), new UInt15(2)), pukCodes);
    pukProfileElement.pukCodes = pepukCodes;
    ReverseByteArrayOutputStream reverseOutputStream = new ReverseByteArrayOutputStream(2048, true);
    pukProfileElement.encode(reverseOutputStream);
    byte[] code = reverseOutputStream.getArray();
    System.out.println(HexConverter.toShortHexString(code));
    ProfileElement rereadProfileElement = new ProfileElement();
    rereadProfileElement.decode(new ByteArrayInputStream(code), null);
    ReverseByteArrayOutputStream reverseOutputStream2 = new ReverseByteArrayOutputStream(2048, true);
    rereadProfileElement.encode(reverseOutputStream2);
    byte[] code2 = reverseOutputStream2.getArray();
    Assert.assertArrayEquals(code, code2);
    String expected = "A3 3F A0 05 80 00 81 01 02 A1 36 30 11 80 01 01 81 08 3030303030303030 82 02 0099 30 0D 80 01 02 81 08 3132333435363738 30 12 80 02 0081 81 08 3132333435363738 82 02 0088".replaceAll("\\s", "");
    Assert.assertEquals(expected, DatatypeConverter.printHexBinary(code));
}
Also used : PEPUKCodes(org.openmuc.jasn1.compiler.pedefinitions.PEPUKCodes) ByteArrayInputStream(java.io.ByteArrayInputStream) BerNull(org.openmuc.jasn1.ber.types.BerNull) PEHeader(org.openmuc.jasn1.compiler.pedefinitions.PEHeader) UInt15(org.openmuc.jasn1.compiler.pedefinitions.UInt15) BerUTF8String(org.openmuc.jasn1.ber.types.string.BerUTF8String) BerOctetString(org.openmuc.jasn1.ber.types.BerOctetString) ProfileElement(org.openmuc.jasn1.compiler.pedefinitions.ProfileElement) ReverseByteArrayOutputStream(org.openmuc.jasn1.ber.ReverseByteArrayOutputStream) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 Test (org.junit.Test)1 ReverseByteArrayOutputStream (org.openmuc.jasn1.ber.ReverseByteArrayOutputStream)1 BerNull (org.openmuc.jasn1.ber.types.BerNull)1 BerOctetString (org.openmuc.jasn1.ber.types.BerOctetString)1 BerUTF8String (org.openmuc.jasn1.ber.types.string.BerUTF8String)1 PEHeader (org.openmuc.jasn1.compiler.pedefinitions.PEHeader)1 PEPUKCodes (org.openmuc.jasn1.compiler.pedefinitions.PEPUKCodes)1 ProfileElement (org.openmuc.jasn1.compiler.pedefinitions.ProfileElement)1 UInt15 (org.openmuc.jasn1.compiler.pedefinitions.UInt15)1