Skip to content

HowTo decode a barcode

CGantert345 edited this page Oct 10, 2023 · 10 revisions

Decode the the content

The decoding can decode both types of frames and different versions of FCB and dynamic content. The decoding of the content is done by the Decoder in this step.

        Decoder decoder = new Decoder(byteArrayFromBarcode);

Validate the signature of level 1 (in case of the static frame the only signature)

Take the keyId from the static or dynamic frame and take the keyId to select the appropriate public key

      //with dynamic frame
      decoder.getDynamicHeader().getLevel2Data().getLevel1Data().getKeyId();

      //with static frame
      decoder.getStaticFrame().getSignatureKey()

      //planned for next version 
      String keyId = decoder.getLevel1KeyId();

Validate the level 1 signature (the only signature in a static frame barcode). Result codes are listed in class Constants.

       int signatureCheckResult = decoder.validateLevel1(<publicKey>,<signing Algorithm OID (not needed for dynamic frames)>);

       //using a specific Provider of the signature algorithm:
       int signatureCheckResult = decoder.validateLevel1(<publicKey>,<signing Algorithm OID (not needed for dynamic frames)>, <provider>);
  1. Get the content
	IUicRailTicket ticket = decoder.getUicTicket();
        TicketLayout layout =  decoder.getLayout();

        StaticFrame staticFrame = decoder.getStaticFrame() 
        IDynamicFrame dynamicHeader = decoder.getDynamicFrame()

Validate the signature of level 2 (in case of the dynamic frame only)

  1. (dynamic frame only) Get the dynamic content

Get the decoded content from the dynamic content part and the complete frame content.

 	IUicDynamicContent dynamicContent = decoder.getDynamicContent()
  1. (dynamic frame only) Validate the level 2 signature

Validate the level 2 signature (dynamic frame barcode only). Result codes are listed in class Constants.

        int signatureCheckResult = decoder.validateLevel2();

        //using a specific Provider of the signature algorithm:
        int signatureCheckResult = decoder.validateLevel2(<provider>);