Search in sources :

Example 1 with ProfileHeader

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

the class MobileTest method header.

@Test
public void header() throws Exception {
    ProfileElement headerProfileElement = new ProfileElement();
    ServicesList servicesList = new ServicesList();
    ProfileHeader.EUICCMandatoryGFSTEList GFSTEList = new ProfileHeader.EUICCMandatoryGFSTEList();
    GFSTEList.seqOf = Arrays.asList(new BerObjectIdentifier(new int[] { 2, 23, 143, 1, 2, 1 }), new BerObjectIdentifier(new int[] { 2, 23, 143, 1, 2, 4 }));
    servicesList.usim = new BerNull();
    servicesList.milenage = new BerNull();
    servicesList.javacard = new BerNull();
    headerProfileElement.header = new ProfileHeader(new UInt8(2), new UInt8(0), new BerUTF8String("SIMalliance Sample Profile"), new BerOctetString(DatatypeConverter.parseHexBinary("89019990001234567893")), null, servicesList, GFSTEList, null);
    ReverseByteArrayOutputStream reverseByteArrayOutputStream = new ReverseByteArrayOutputStream(2048, true);
    headerProfileElement.encode(reverseByteArrayOutputStream);
    byte[] code = reverseByteArrayOutputStream.getArray();
    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 = "A0 48 80 01 02 81 01 00 82 1A 53494D616C6C69616E63652053616D706C652050726F66696C65 83 0A 89019990001234567893 A5 06 81 00 84 00 8B 00 A6 10 06 06 67810F010201 06 06 67810F010204".replaceAll("\\s", "");
    Assert.assertEquals(expected, DatatypeConverter.printHexBinary(code));
}
Also used : BerObjectIdentifier(org.openmuc.jasn1.ber.types.BerObjectIdentifier) BerUTF8String(org.openmuc.jasn1.ber.types.string.BerUTF8String) BerOctetString(org.openmuc.jasn1.ber.types.BerOctetString) BerUTF8String(org.openmuc.jasn1.ber.types.string.BerUTF8String) BerOctetString(org.openmuc.jasn1.ber.types.BerOctetString) ProfileElement(org.openmuc.jasn1.compiler.pedefinitions.ProfileElement) UInt8(org.openmuc.jasn1.compiler.pedefinitions.UInt8) ProfileHeader(org.openmuc.jasn1.compiler.pedefinitions.ProfileHeader) ReverseByteArrayOutputStream(org.openmuc.jasn1.ber.ReverseByteArrayOutputStream) ServicesList(org.openmuc.jasn1.compiler.pedefinitions.ServicesList) ByteArrayInputStream(java.io.ByteArrayInputStream) BerNull(org.openmuc.jasn1.ber.types.BerNull) 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 BerObjectIdentifier (org.openmuc.jasn1.ber.types.BerObjectIdentifier)1 BerOctetString (org.openmuc.jasn1.ber.types.BerOctetString)1 BerUTF8String (org.openmuc.jasn1.ber.types.string.BerUTF8String)1 ProfileElement (org.openmuc.jasn1.compiler.pedefinitions.ProfileElement)1 ProfileHeader (org.openmuc.jasn1.compiler.pedefinitions.ProfileHeader)1 ServicesList (org.openmuc.jasn1.compiler.pedefinitions.ServicesList)1 UInt8 (org.openmuc.jasn1.compiler.pedefinitions.UInt8)1