Openbravo Issue Tracking System - Retail Modules
View Issue Details
0046301Retail ModulesWeb POS Hardware Managerpublic2021-04-19 22:552021-04-27 17:52
rtoledano 
rqueralta 
highmajoralways
closedfixed 
30Ubuntu 18.04.5 LTS
RR20Q3.4 
RR20Q3.4RR21Q3 
No
0046301: Printing of images referring to URLs with authentication is not supported in HWM
We have a client (Weldom), who has a custom module, which during the synchronization of a ticket consults an external service that can return a list of URLs referring to bonds (in image format) as royalties for the purchase made.

The requirement is to be able to print on the printer in addition to the ticket, the generated bonds to be able to give them to the buyer.

Each URL refers to an image so it is possible, for example, to send the following template to print on the printer:

      <? xml version = "1.0" encoding = "UTF-8"?>
      <output>
        <ticket>
          <line>
            <image type = "url">https://wspreprod.be-one.fr/BEOneDataWeldom/tickets/tickets-a645-1617941657970.bmp</image> [^]
          </line>
        </ticket>
       </output>

Which works fine if this URL is not protected by some HTTP authentication method. But this URL is protected with a basic HTTP authentication method. If we try to send the following template to print:
    
      <? xml version = "1.0" encoding = "UTF-8"?>
      <output>
        <ticket>
          <line>
            <image type = "url"> https://<user>:<password>@wspreprod.be-one.fr/BEOneDataWeldom/tickets/tickets-a645-1617941657970.bmp</image> [^]
          </line>
        </ticket>
       </output>
    
    replacing <user> and <password> with the authentication credentials, the image is still not possible to print, due to the way the HWM tries to download this image for printing. The other drawback of trying to solve the problem in this way is that we would be exposing unencrypted authentication data.

     Currently in the source file of the HWM, com.openbravo.pos.printer.TicketParser is where the way to read this image is implemented:
       
        image = ImageIO.read (new URL (text.toString ()));
     
     where text is the URL.

     The use of the java URL class is what prevents the authentication data from being taken into account.
1- Start HWM
2- Using Postman or similar tool Create a HTTP POST request to the printer(http://localhost:8090/printer [^])
3- In Body send a xml print template like the example show. But with an URL protected by a basic HTTP authentication
4- Check that the image is not printed
1- A proposal could be to add other attributes to the image tag of the xml template, for example:
     
       <? xml version = "1.0" encoding = "UTF-8"?>
       <output>
         <ticket>
           <line>
             <image type = "url" user = "usr" password = "encrypted_password" authType = "Basic"> https://wspreprod.be-one.fr/BEOneDataWeldom/tickets/tickets-a645-1617941657970.bmp [^] </image>
           </line>
         </ticket>
        </output>
      
      In this way, in the com.openbravo.pos.printer.TicketParser class, the new authentication attributes would be managed, as well as the suitable java APIs to read the image. The method that the class will use to decrypt the password must be defined.

2- Another proposal, would be to support the base-64 encoded image in the printing template. In this way, the developer would be in charge of downloading the image and generating the xml printing template with the base-64 encoded image. This could be a proposed code to add in TicketParser.endElement method:

  if ("data".equals(imgtype)) {
    image = ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode(text.toString())));
  }
    
No tags attached.
patch 0001-Fixes-ISSUE-46301-Support-is-added-to-print-embedded.patch (1,616) 2021-04-22 19:03
https://issues.openbravo.com/file_download.php?file_id=15567&type=bug
xml testdata.xml (53,037) 2021-04-22 19:03
https://issues.openbravo.com/file_download.php?file_id=15568&type=bug
Issue History
2021-04-19 22:55rtoledanoNew Issue
2021-04-19 22:55rtoledanoAssigned To => Retail
2021-04-19 22:55rtoledanoTriggers an Emergency Pack => No
2021-04-19 23:04rtoledanoDescription Updatedbug_revision_view_page.php?rev_id=22337#r22337
2021-04-20 17:03rtoledanoProposed Solution updated
2021-04-20 17:03rtoledanoProposed Solution updated
2021-04-20 18:37rtoledanoProposed Solution updated
2021-04-20 20:16rtoledanoProposed Solution updated
2021-04-22 17:13rtoledanoResolution time => 1620079200
2021-04-22 17:20rtoledanoTypefeature request => design defect
2021-04-22 17:21rtoledanoTypedesign defect => defect
2021-04-22 19:03rtoledanoFile Added: 0001-Fixes-ISSUE-46301-Support-is-added-to-print-embedded.patch
2021-04-22 19:03rtoledanoFile Added: testdata.xml
2021-04-22 21:34rqueraltaAssigned ToRetail => rqueralta
2021-04-22 21:35rqueraltaStatusnew => scheduled
2021-04-22 21:48hgbotNote Added: 0127474
2021-04-27 17:12hgbotNote Added: 0127590
2021-04-27 17:22hgbotNote Added: 0127591
2021-04-27 17:24hgbotNote Added: 0127592
2021-04-27 17:52hgbotResolutionopen => fixed
2021-04-27 17:52hgbotStatusscheduled => closed
2021-04-27 17:52hgbotFixed in Version => RR21Q3
2021-04-27 17:52hgbotNote Added: 0127594
2021-04-27 17:52hgbotNote Added: 0127595
2021-04-27 17:52hgbotNote Added: 0127596
2021-04-27 17:52hgbotNote Added: 0127597

Notes
(0127474)
hgbot   
2021-04-22 21:48   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager.sources/-/merge_requests/21 [^]
(0127590)
hgbot   
2021-04-27 17:12   
Merge request closed: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager.sources/-/merge_requests/21 [^]
(0127591)
hgbot   
2021-04-27 17:22   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager.sources/-/merge_requests/23 [^]
(0127592)
hgbot   
2021-04-27 17:24   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager/-/merge_requests/16 [^]
(0127594)
hgbot   
2021-04-27 17:52   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager [^]
Changeset: 9e247136c80f83d0f62ad0a8f316b76d9ad629aa
Author: Rafael Queralta <rafaelcuba81@gmail.com>
Date: 2021-04-27T11:20:46-04:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager/-/commit/9e247136c80f83d0f62ad0a8f316b76d9ad629aa [^]

Fixed BUG-46301: Support is added to print embedded images, encoded in base 64

---
M bin/poshw.jar
M bin/rev.id
---
(0127595)
hgbot   
2021-04-27 17:52   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager/-/merge_requests/16 [^]
(0127596)
hgbot   
2021-04-27 17:52   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager.sources/-/merge_requests/23 [^]
(0127597)
hgbot   
2021-04-27 17:52   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager.sources [^]
Changeset: 885c104c6c0339f974a87b88ac98ed5c932b848b
Author: Rafael Queralta <rafaelcuba81@gmail.com>
Date: 2021-04-27T11:13:37-04:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.poshwmanager.sources/-/commit/885c104c6c0339f974a87b88ac98ed5c932b848b [^]

Fixed BUG-46301: Support is added to print embedded images, encoded in base 64

---
M project/src/com/openbravo/pos/printer/TicketParser.java
---