+

Search Tips | Advanced Search

Set up and using a JMS allowlist

This information tells you how an allowlist works, and how you set one up using the functionality contained in the IBM MQ classes for JMS to generate an allowlist file, containing a list of the types of ObjectMessages that an application can process.


Before you begin

Note: Wherever possible, the term allowlist has replaced the term whitelist. One exception is the Java™ system property names mentioned in this topic.

Before starting this task, make sure that we have read and understood Allowlisting concepts


About this task

When we have enabled the allowlisting functionality, the IBM MQ classes for JMS use that functionality in the following ways:

For example, suppose our application contains the following code to send an ObjectMessage containing an object of type java.net.URI:
java.net.URL testURL = new java.net.URL("http://www.ibm.com/");
ObjectMessage msg = session.createObjectMessage(testURL);
sender.send(msg);
As allowlisting is not enabled, the application is able to successfully put the message to the required destination. If you create a file called C:\allowlist.txt containing a single entry, java.net.URL, and you start the application again with the Java system property set:
-Dcom.ibm.mq.jms.whitelist=file:/C:/allowlist.txt
the allowlist functionality is enabled. The application is still able to create and send the ObjectMessage containing an object of type java.net.URI , as that type is specified in the allowlist. However, if you change the allowlist.txt file so that the file contains the single entry java.util.Calendar, as the allowlist functionality is still enabled, when the application calls:
ObjectMessage msg = session.createObjectMessage(testURL);
the IBM MQ classes for JMS check the allowlist and find that it does not contain an entry for java.net.URI.

As a result, a JMSException containing the JMSCC0052 message is thrown.

Similarly, suppose we have another application that receives ObjectMessages using this code:
ObjectMessage message = (ObjectMessage)receiver.receive(30000);
if (message != null) {
    Object messageBody = objectMessage.getObject();
    if (messageBody instanceof java.net.URI) {
      :    :    :    :    :    :    :

If allowlisting is not enabled, the application is able to receive ObjectMessages that contain an object of any type. The application then checks if the object is of type java.net.URL before performing the appropriate processing.

If you now start the application with the Java system property:
-Dcom.ibm.mq.jms.whitelist=java.net.URL
set, the allowlisting functionality is turned on. When the application calls:
Object messageBody = objectMessage.getObject();
the ObjectMessage.getObject() method only returns objects of type java.net.URL.

If the object contained within the ObjectMessage is not of this type, the ObjectMessage.getObject() method throws a JMSException containing the JMSCC0053 message. The application then needs to decide what do to with the message; for example, the message could be moved to the dead-letter queue for that queue manager.

The application only returns normally if the object inside the ObjectMessage is of the type java.net.URL.


Procedure

  1. Run the application which processes ObjectMessages, with the following Java system properties specified:
    -Dcom.ibm.mq.jms.whitelist.discover=true
    -Dcom.ibm.mq.jms.whitelist=file:/<path to your allowlist file>    
    
    When the application runs, the IBM MQ classes for JMS create a file which contained the types of objects that the application processed.
  2. After the application has processed a representative sample of ObjectMessages over a period of time, stop it. The allowlist file now contains a list of all of the types of objects contained within the ObjectMessages that the application processed while it was running. If we have run the application for a sufficient time, this list includes all the possible types of objects contained within ObjectMessages that the application is likely to handle.
  3. Restart the application with the following system property set:
    -Dcom.ibm.mq.jms.whitelist=file:/<path to your allowlist file>  
    This enables allowlisting, and if the IBM MQ classes for JMS detect an ObjectMessage of a type which is not in the allowlist, a JMSException containing either the JMSCC0052 or JMSCC0053 message is thrown.