Skip to content

HowTo encode a bar code with Static Frame

CGantert345 edited this page Jan 4, 2024 · 8 revisions

1. Preparing the content of the ticket

Two ticket data formats are supported:

TLB Ticket Layout Barcode - a format description for text describing the ticket to be displayed FCB Flexible Content Barcode - a structured ticket data format

TLB

        TicketLayout layout = new TicketLayout();
        // add your content to the ticket layout

FCB

        IUicRailTicket ticket = new SimpleUicRailTicket();
    	// add your content to the FBC ticket description

2. Create an Encoder and add the ticket data and/or ticket layout data and the version of the frame and the version of the FCB ticket data

        Encoder encoder = new Encoder(ticket, layout, Encoder.UIC_BARCODE_TYPE_CLASSIC, <frame version>, <FCB version>);

Add proprietary data to the static frame

       ArrayList<DataRecord> dataRecords = encoder.getStaticFrame().getDataRecords();
       dataRecords.add(<myProprietaryDataRecord>)

3. Add data for the static frame parameter

        encoder.setStaticHeaderParams(<ticketId>, <Language>);

4. Sign the data

The data can be signed. The Provider of the signature algorithm can be provided to use a dedicated provider for the signature. If no provider is indicated the first provider that might be able to the signature algorithm is used. There needs to be a provider registered which can handle the signature.

       encoder.signLevel1(<SecurityProvider RICS code>, keyPair.getPrivate(), <algorithm OID>, <keyId>, <provider>);
       deprecated
       encoder.signLevel1(<SecurityProvider RICS code>, keyPair.getPrivate(), <algorithm OID>, <keyId>);

5. Encode the data

       byte[] encoded = encoder.encode();