Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

MAS 9 - zebra-label - BadPaddingException

  • 1.  MAS 9 - zebra-label - BadPaddingException

    Posted Sun September 29, 2024 11:35 PM
    Edited by Alexey Potanin Sun September 29, 2024 11:37 PM

    Hi guys,

    I am trying to deploy zebra-label solution (version zebra-label-1.1.2.zip) to MAS 9.0.

    After updating the configuration masinst pod would finish fine and build of ui, mea, cron, report images would be done successfully.

    Unfortunately Manage would be not working. Checking logs of the ui pod shows following error (full stack is below):

    [err] javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

    I tried:

    • download zip file to my local server and point the customization to it
    • Point directly to zebra-label-1.1.2.zip at the github
    • Used version 1.1.0

    No issues with the build but it fails on the ui start :( Nothing helped.

    30 Sep 2024 03:17:19:015 [INFO ] [maximo] BMXAA6453I - The server is connecting to database version: V9000-127
    [err] javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
    [err]     at java.base/com.sun.crypto.provider.CipherCore.unpad(CipherCore.java:1065)
    [err]     at java.base/com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1145)
    [err]     at java.base/com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:919)
    [err]     at java.base/com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
    [err]     at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2202)
    [err]     at psdi.util.MXCipher.decData(MXCipher.java:293)
    [err]     at psdi.server.MXServer.getPkgFromJar(MXServer.java:2251)
    [err]     at psdi.server.MXServer.packagingCheck(MXServer.java:1867)
    [err]     at psdi.server.MXServer.boot(MXServer.java:1685)
    [err]     at psdi.server.MXServer.start(MXServer.java:3905)
    [err]     at psdi.servlet.MAXIMOStartupServlet.init(MAXIMOStartupServlet.java:116)
    [err]     at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:301)
    [err]     at [internal classes]
    [err]     at com.ibm.ws.webcontainer.osgi.WebContainer.access$100(WebContainer.java:113)
    [err]     at com.ibm.ws.webcontainer.osgi.WebContainer$3.run(WebContainer.java:996)
    [err]     at [internal classes]
    [err]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    [err]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    [err]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    [err]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    [err]     at java.base/java.lang.Thread.run(Thread.java:839)

    Would much appreciate your help!



    ------------------------------
    Alexey Potanin
    ------------------------------



  • 2.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Mon September 30, 2024 02:12 AM

    Hi Alexey,

    it sounds like some kind of incompatibility of your CRYPTO/CRYPTOX keys that your'e experiencing.
    I quickly reviewed zebra-label-1.1.2.zip package content and I can't see any script called V9000-127.* there. It's quite hard then to point out what might be the other cause.
    Could you please provide wider context of the error so that we can see what product scripts are actually being executed when this error occurs?
    Did you by any chance did any other change in this environment?



    ------------------------------
    Andrzej Więcław
    Maximo Technical Consultant
    AFRY
    Wrocław, Poland
    ------------------------------



  • 3.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Mon September 30, 2024 02:27 AM

    Hi Andrzey,

    I believe V9000-127 is just a version of MAS or Manage. We are subscribed to the latest release channel, so it must be it.

    I followed the instruction here: https://github.com/sharptree/zebra-label/tree/main?tab=readme-ov-file

    Build was fine, no issues. UpdateDB run fine, no issue.

    But when one of the server bundles start it fails with this error.



    ------------------------------
    Alexey Potanin
    ------------------------------



  • 4.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Mon September 30, 2024 04:47 PM
      |   view attached

    Hi Alexey,

    I'm sorry, I indeed missed the fact that the error is being reported in runtime, rather than during the build process.
    I must admit that have never used this Sharptree's product but I did some investigations during the day and this is what I came up with.

    The long story short - you cannot use Github release archive directly with MAS Manage, but you should rather build your own customization archive, first adjusting few things.

    First of all it looks like Github repository contains STLABEL.key which is required by Maximo framework to load STLABEL custom application. This file contains STLABEL, value encrypted using Maximo 7.6.1.x version of the psdi.util.MXCipher utility.  The thing is that it looks like static encryption keys (don't mix them with MAS Manage CRYPTO/CRYPTOX keys used to encrypt database values like I originally suggested) have been changed between Maximo 7.6.1.x and MAS Manage 8+ and therefore STLABEL.key cannot be properly deciphered by MAS Manage during boot time. The trick here is to cipher STLABEL, value using MAS Manage version of the  psdi.util.MXCipherX.encData(String) method and save result to file. Please check whether attached STLABEL.txt works for you. After downloading simply rename it to STLABEL.key and replace the file located under <repo-root>/src/main/dist/applications/maximo/businessobjects/classes/psdi/app/signature/apps.

    Secondly, it looks like this Zebra Label extension package out of the box it supports single all server bundle deployment (ref. adjustments to the maximo-all.xml and maximouiweb web.xml files). If you're running any other server bundle types (ui, mea, cron, report) then you need to add buildmaximoui-war.xml, buildmaximomea-ear.xml, buildmaximocron-war.xml, buildmaximoreport-war.xml under <repo-root>/src/main/dist/deployment/was-liberty-default and adjust them in a similar manner like @Jason VenHuizen did that with maximo-all.xml. To understand what changes are required I highly recommend you to extract your current maximo-all.xml file from the maxinst POD and compare it with the Github version of the same file. 
    Furthermore for each server bundle type you need to update maximouiweb module's web.xml files located under /opt/IBM/SMP/maximo/deployment/was-liberty-default/config-deployment-descriptors/[maximo-all|maximo-ui|etc.] directories and include the same changes as were applied to the web.xml in the Github repository (same comparison procedure as with maximo-all.xml).

    It sounds like a lot but I believe it's still worth all great @Jason VenHuizen's and Sharptree's work. I tried it in my MAS Manage environment and I succeeded installing and running Zebra Label extension. I guess up to some point mentioned changes can be turned into the code and included in the Github repository, especially generating STLABEL.key file dynamically. With all those XML files it's not so easy though as they evolve frequently. I can imagine though implementing a kind of build time hook, similar to the one I described in my LinkedIn article IBM MAS Manage - Automatic Root Context Redirect (ref. MAS Manage Build Time Hook section) which would adjust XML files during container image build process and therefore relax dependency on keeping copies of specific MAS Manage version XML files which need to be updated



    ------------------------------
    Andrzej Więcław
    Maximo Technical Consultant
    AFRY
    Wrocław, Poland
    ------------------------------

    Attachment(s)

    txt
    STLABEL.txt   32 B 1 version


  • 5.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Mon September 30, 2024 07:00 PM

    OMG, Andrzej. Thanks so much for the explanation and especially for the file. It all makes sense.

    Will give it a go and report back to the forum.



    ------------------------------
    Alexey Potanin
    ------------------------------



  • 6.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Mon September 30, 2024 07:07 PM

    Andrzej,

     

    That is amazing work on your part.  Thanks for pointing that out and providing a clear path to fix it. 

     

    It has been a while since I revisited the label printing and have a number of updates for it so I will wrap that into the updates as well.


    Thanks again for digging into this.

    Jason






  • 7.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Tue October 01, 2024 12:30 AM

    Hi guy, to confirm, the attached STLABEL file worked with MAS 9.

    I followed the steps suggested by Andrzej and it worked like a charm!

    Here is the summary (for other people...):

    1. Download the zebra-label-1.1.2.zip package. Unzip to a folder
    2. Update the STLABLE file with a new version
      1. Location: applications\maximo\businessobjects\classes\psdi\app\signature\apps
    3. Extract maximo-all.xml (ui/report/cron/mea) and web.xml files from admin image. Locations:
      1. /opt/IBM/SMP/maximo/deployment/was-liberty-default
      2. /opt/IBM/SMP/maximo/deployment/was-liberty-default/config-deployment-descriptors/
    4. Modify these files to incorporate Zebra-label files:
      1. maximo-all.xml: (line 44-45) add lib/zebra-label.jar lib/guava-31.0.1-jre.jar files
        1.  <property name="maximo.businessobjectsclasspath"

                          value="${maximo.propertiesjarfile} lib/ldapbp.jar lib/log4j-1.2-api-2.17.1.jar lib/log4j-api-2.17.1.jar lib/log4j-core-2.17.1.jar lib/log4j-web-2.17.1.jar lib/db2jcc.jar lib/db2jcc_license_cu.jar lib/oraclethin.jar lib/sqljdbc.jar lib/sqlite-jdbc-3.42.0.0.jar lib/httpclient-4.5.13.jar lib/joda-time-2.8.1.jar lib/aws-java-sdk-core-1.12.651.jar  lib/aws-java-sdk-kms-1.12.651.jar lib/aws-java-sdk-s3-1.12.651.jar lib/jackson-dataformat-cbor-2.12.6.jar lib/jmespath-java-1.12.651.jar lib/ion-java-1.10.5.jar lib/softlayer-api-client-0.2.3.jar lib/httpcore-4.4.13.jar lib/httpmime-4.5.13.jar lib/commons-net-3.9.0.jar lib/commons-pool-1.5.4.jar lib/commons-compress-1.26.jar lib/jsr181.jar lib/remoteaccess.jar lib/platform-model.jar lib/ssh.jar /lib/api-client.jar /lib/api-dep.jar /lib/oal-api.jar /lib/oal-topomgr.jar /lib/oal-common.jar lib/edm-server.jar /lib/api-dl.jar  /lib/maxcom.jar /lib/icu4j.jar /lib/json4j.jar /lib/jviews-chart.jar /lib/jviews-gantt.jar /lib/jviews-diagrammer.jar lib/jviews-framework-lib.jar lib/jhbasic-2.0_05.jar lib/contentloader.jar lib/oslcquery.jar lib/oauth.jar lib/tdb-0.8.7-patched.jar lib/jena-2.6.3-patched.jar lib/slf4j-log4j12-1.6.4.jar lib/slf4j-api-2.0.11.jar lib/iri-0.8.jar lib/sdb-1.3.2.jar lib/gson-2.8.9.jar lib/freemarker-2.3.22.jar lib/antisamy-1.7.5.jar lib/batik-constants-1.17.jar lib/batik-css-1.17.jar lib/batik-i18n-1.17.jar lib/batik-util-1.17.jar lib/httpclient5-5.3.1.jar lib/httpcore5-5.2.4.jar lib/httpcore5-h2-5.2.4.jar lib/neko-htmlunit-3.11.1.jar lib/xml-apis-ext-1.3.04.jar lib/xmlgraphics-commons-2.9.jar lib/commons-io-2.15.1.jar lib/commons-logging-1.2.jar lib/sac.jar lib/commons-math3-3.6.1.jar lib/groupdocs-conversion-22.8-part1.jar lib/groupdocs-conversion-22.8-part2.jar lib/groupdocs-conversion-22.8-part3.jar lib/poi-4.1.2.jar lib/poi-excelant-4.1.2.jar lib/poi-ooxml-4.1.2.jar lib/poi-ooxml-schemas-4.1.2.jar lib/jackson-core-2.15.1.jar lib/jackson-databind-2.15.1.jar lib/jackson-annotations-2.15.1.jar lib/kafka-clients-3.6.0.jar lib/snappy-java-1.1.10.4.jar lib/lz4-java-1.7.1.jar lib/docloud_api_java_client-1.0-STABLE-b277.jar lib/commons-collections4-4.1.jar lib/xmlbeans-3.1.0.jar lib/rcl_ibmratl.jar lib/ical4j-3.0.18.jar lib/commons-lang3-3.4.jar lib/mof-api-java.jar lib/graphql-java-20.1.jar lib/antlr4-runtime-4.8.jar lib/reactive-streams-1.0.3.jar lib/java-dataloader-3.2.0.jar lib/spatiotemporal-core-1.6.0.jar lib/vertx-core-4.1.0.jar lib/mas-data-dictionary-lib-1.0.0.jar lib/jackson-dataformat-yaml-2.11.3.jar lib/annotations-16.0.2.jar lib/cognos-axis.jar lib/cognosClient.jar lib/jsch.jar lib/curvesapi-1.06.jar lib/zebra-label.jar lib/guava-31.0.1-jre.jar"/>
      2. web.xml file - 2 changes:
        1. (line 297) 
              <!--Zebra Label Printing Dispatch Servlet-->
              <servlet>
                  <servlet-name>ZebraLabelDispatch</servlet-name>
                  <servlet-class>io.sharptree.maximo.webclient.servlet.ZebraLabelPrintDispatchServlet</servlet-class>
                  <load-on-startup>1</load-on-startup>
              </servlet>
          2. (line 549) 
              <!--Zebra Label Printing Dispatch Servlet Mapping-->
              <servlet-mapping>
                  <servlet-name>ZebraLabelDispatch</servlet-name>
                  <url-pattern>/labeldispatch/*</url-pattern>
              </servlet-mapping>

     - Zip the folder

    - Deploy the customization to Manage as per instruction: https://github.com/sharptree/zebra-label/tree/main



    ------------------------------
    Alexey Potanin
    ------------------------------



  • 8.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Tue October 01, 2024 12:33 AM

    guys (@Andrzej Więcław and @Jason VenHuizen), can you please explain the purpose of the STLABEL.key file?
    I've never seen this solution and would be glad to learn about it.

    Thank you in advance!



    ------------------------------
    Alexey Potanin
    ------------------------------



  • 9.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Tue October 01, 2024 02:52 AM
    Edited by Andrzej Więcław Wed October 02, 2024 03:19 AM

    Alexey,

    I have quite long history with Maximo but my experiences with these *.key files are as old as one day ;-) 
    I have never seen any piece of documentation about this myself, therefore whatever I say further down is based on experimenting and yet, it still covers only a fraction of the full picture.

    It looks like MXServer during boot time scans for *.class, *.license and *.key files located under psdi/app/signature/apps/ package and deciphers them using psdi.util.MXCipher but it doesn't use CRYPTO/CRYPTOX keys that are environment specific as of MAS Manage, but rather uses static set of keys. 

    Decryption result is expected to be of type String and contain comma-separated entries. I will not get into more details as I'm not 100% sure about that, but what I'm sure of is that entries other than ISPERMANENT, EVALUATION, MAXIMOPRODUCT, TIVOLIPRODUCT, LICENSEKEY, PRODUCTKEY and FORINTERNALUSEONLY are considered as valid application names. Therefore the STLABEL.key file contains STLABEL, as it's the internal name of the custom Label Configuration application. 

    Why is all that? Apparently Maximo/MAS Manage by default filters out applications which haven't been created as clones of one of standard apps (MAXAPPS.ORIGINALAPP is NULLand are not in the list of valid application names. Having said, since STLABEL application is being created as "standalone" (without any original app reference, see V1000_02.dbc), therefore valid *.key file need to be provided in order to enable this custom application.

    You may ask: why don't I need any *.key file when creating completely new application directly in Maximo using Application Designer?
    The answer is quite simple - whenever you create application using Application Designer then MAXAPPS.ORIGINALAPP is set either to the name of the app which you're cloning or to CUSTAPP, in case you're adding brand new custom application. 

    Just by looking at this case we might have fixed the problem by providing re-encrypted STLABEL.key file or simply removing the STLABEL.key file and running following update statement:
    update maxapps set originalapp = 'CUSTAPP' where app = 'STLABEL';

    I hope that helps. I must admit that it's been really interesting challenge!



    ------------------------------
    Andrzej Więcław
    Maximo Technical Consultant
    AFRY
    Wrocław, Poland
    ------------------------------



  • 10.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Wed October 02, 2024 02:57 AM

    The STLABEL.key file in IBM Maximo Application Suite (MAS) 9 is a critical component related to license enforcement and security. It plays a role in the tracking and validation of software usage to ensure compliance with IBM's licensing policies. Here's an overview of its purpose and how it fits within the MAS ecosystem:

    Purpose of the STLABEL.key File

    1. License Key Management:

      • The STLABEL.key file is associated with the management of licensing within MAS 9. It ensures that the system can validate the license provided for different Maximo components and services, such as Maximo Manage, Maximo Monitor, and Maximo Predict. By managing licenses through this file, IBM can enforce correct usage based on the purchased entitlements.
    2. Software Entitlement Tracking:

      • MAS 9 is deployed using a cloud-native architecture, where IBM tracks the entitlements (number of users, deployment types, features, etc.). The STLABEL.key file is one of the mechanisms used to map these entitlements to the actual software usage within your environment. It helps Maximo monitor compliance by ensuring that the system is operating within the constraints defined by your license agreement.
    3. Security and Integrity:

      • The STLABEL.key file is also a form of protection against unauthorized usage of the software. It acts as a unique identifier for your specific environment and ensures that only legitimate, licensed deployments can operate the suite components.
    4. Integration with Licensing Services:

      • MAS 9 uses a licensing service to communicate with IBM's cloud-based entitlement systems. The STLABEL.key file is read by the MAS license management services during startup or at specific intervals to validate the usage. This file contains encrypted information, which corresponds to the license and entitlement data stored on IBM's servers.

    How It Works in MAS 9

    • During Installation:

      • When installing or configuring a Maximo Application Suite instance, the STLABEL.key file is deployed as part of the license management system. It must match the entitlements associated with your IBM account, ensuring that the MAS installation can only run the components and features for which you are licensed.
    • Regular Validation:

      • The system periodically checks the STLABEL.key file to verify that the current usage is in compliance with the purchased licenses. This ensures that if additional components are added, or more users are provisioned, the appropriate licenses are in place.
    • When a License Violation Occurs:

      • If the system detects that the usage has exceeded the entitlements (e.g., too many users or overuse of a component), MAS may generate alerts or restrict access to certain features. This is governed by the license enforcement policy, and the STLABEL.key file plays a role in these checks.

    Key Points to Note

    • Unique to Your Environment: The STLABEL.key file is tied to your specific Maximo environment and license. You cannot simply copy it to another environment or instance as it would invalidate the license.

    • Automatic Updates: As your licensing changes (e.g., you purchase additional modules or users), IBM may provide an updated STLABEL.key file, or the MAS licensing service may update it automatically if connected to the cloud.

    • Critical to System Operations: Without a valid STLABEL.key, your MAS deployment may not function correctly, or you may face restrictions based on the licensing agreements.

    Conclusion

    The STLABEL.key file is an essential part of managing and enforcing licenses within IBM Maximo Application Suite (MAS) 9. It ensures that your organization is operating within the agreed-upon entitlements and provides security by preventing unauthorized use of Maximo components. If you're unfamiliar with this solution, it's key to ensuring compliance with IBM's licensing model, especially as MAS transitions to more cloud-centric and entitlement-based management.



    ------------------------------
    Rakesh Ghoshal
    Principal Solution Architect

    Gulf Business Machines
    E-Mail: rghshal@gbmme.com
    Linkedin: www.linkedin.com/in/rkg-kw
    PO Box 4175, Safat, Kuwait
    General Marketing & Services Representative for IBM WTC
    www.gbmme.com
    ------------------------------



  • 11.  RE: MAS 9 - zebra-label - BadPaddingException

    Posted Wed October 02, 2024 03:15 AM

    ChatGPT entered the chat....

    STLABEL.key has nothing to do with MAS licenses.



    ------------------------------
    Witold Wierzchowski
    Solution Architect
    Cohesive Poland
    ------------------------------