Search in sources :

Example 1 with PEPUKCodes

use of com.beanit.asn1bean.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)));
    pukProfileElement.pukCodes = new PEPUKCodes(new PEHeader(new BerNull(), new UInt15(2)), pukCodes);
    ReverseByteArrayOutputStream reverseOutputStream = new ReverseByteArrayOutputStream(2048, true);
    pukProfileElement.encode(reverseOutputStream);
    byte[] code = reverseOutputStream.getArray();
    ProfileElement rereadProfileElement = new ProfileElement();
    rereadProfileElement.decode(new ByteArrayInputStream(code), null);
    ReverseByteArrayOutputStream reverseOutputStream2 = new ReverseByteArrayOutputStream(2048, true);
    rereadProfileElement.encode(reverseOutputStream2);
    byte[] code2 = reverseOutputStream2.getArray();
    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", "");
    assertEquals(expected, HexString.fromBytes(code));
}
Also used : PEPUKCodes(com.beanit.asn1bean.compiler.pedefinitions.PEPUKCodes) ByteArrayInputStream(java.io.ByteArrayInputStream) BerNull(com.beanit.asn1bean.ber.types.BerNull) PEHeader(com.beanit.asn1bean.compiler.pedefinitions.PEHeader) UInt15(com.beanit.asn1bean.compiler.pedefinitions.UInt15) BerUTF8String(com.beanit.asn1bean.ber.types.string.BerUTF8String) BerOctetString(com.beanit.asn1bean.ber.types.BerOctetString) HexString(com.beanit.asn1bean.util.HexString) ProfileElement(com.beanit.asn1bean.compiler.pedefinitions.ProfileElement) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Aggregations

ReverseByteArrayOutputStream (com.beanit.asn1bean.ber.ReverseByteArrayOutputStream)1 BerNull (com.beanit.asn1bean.ber.types.BerNull)1 BerOctetString (com.beanit.asn1bean.ber.types.BerOctetString)1 BerUTF8String (com.beanit.asn1bean.ber.types.string.BerUTF8String)1 PEHeader (com.beanit.asn1bean.compiler.pedefinitions.PEHeader)1 PEPUKCodes (com.beanit.asn1bean.compiler.pedefinitions.PEPUKCodes)1 ProfileElement (com.beanit.asn1bean.compiler.pedefinitions.ProfileElement)1 UInt15 (com.beanit.asn1bean.compiler.pedefinitions.UInt15)1 HexString (com.beanit.asn1bean.util.HexString)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Test (org.junit.jupiter.api.Test)1