getLicense method

Hello,

A few years ago, we developed a module for Ignition 7.9. We are now trying to make it compatible with Ignition 8.1. However, when we upgrade the application and attempt to use the module, we encounter an error: "no such method error for com.inductiveautomation.ignition.common.licensing.License com.inductiveautomation.ignition.gateway.licensing.LicenseManager.getLicense()".

Could you advise us on the correct method to use as a replacement for the outdated one? Additionally, please share any important considerations we should be aware of during this transition.

Kind regards,

Johnny

Any replacement will depend on what you were trying to achieve with the previous LicenseManager::getLicense call.

Tell us more about what you're trying to do.

Hi Kevin,

The error we get is

and the code we are using is

Post code - not pictures of code! That way it can be easily tested and edited into answers by others.

The sin of providing pictures of code aside, this code doesn't even call the API you mentioned.

1 Like

Hello,

I'm sorry for the confusion.

We do the call from the following statement

License license = LicenseDataManager.getInstance().GetContext().getLicenseManager().getLicense();

where the License object comes from

import com.inductiveautomation.ignition.common.licensing.License;

The LicenseDataManager is a class we built. It is a singleton for which we have the GetContext method returning the context object of GatewayContext type.

The context object has the GetLicenseManager from Inductive Automation.

Check the class below if you need it.

import com.inductiveautomation.ignition.gateway.model.GatewayContext;
import com.inductiveautomation.ignition.common.licensing.License;
import com.inductiveautomation.ignition.common.licensing.LicenseDetails;
import com.inductiveautomation.ignition.common.licensing.LicenseState;
import com.inductiveautomation.ignition.common.licensing.TrialLicenseState;

	private boolean checkIgnitionServerLicense () throws Exception {
		boolean ok = true;
		
		try {
			License license = LicenseDataManager.getInstance().GetContext().getLicenseManager().getLicense();
			LicenseDetails licenseDetails = license != null ? license.getPlatformLicense() : null;
			ok = license != null && licenseDetails != null;

			if (!ok) {
				logger.fatal("LicenseChecker: Error validando la licencia Ignition del servidor en módulo de licencia IPG-Ignition: no hay licencia instalada");
			}
			else {
				LicenseState licenseStateSQLBridge = LicenseDataManager.getInstance().GetContext().getLicenseManager().getLicenseState(Constants.MODULE_ID_SQL_BRIDGE);
				if (licenseStateSQLBridge instanceof TrialLicenseState) {
					ok = false;
					logger.fatal("LicenseChecker: Error validando la licencia Ignition del servidor en módulo de licencia IPG-Ignition: SQL Bridge se encuentra en modo Trial");
				}
				else {
					NodeList nodes = LicenseDataManager.getInstance().GetLicenseDataElements(Constants.XPATH_IGNITION_CD_KEY);
					ok = (nodes == null ||
						  nodes.getLength() == 0 ||
						  (((Element) nodes.item(0)).getTextContent().trim().length() == 0) ||
							((Element) nodes.item(0)).getTextContent().toUpperCase().replace(" ","").replace("-", "").equals(
									license.getCDKey().getCDKey().toUpperCase().replace(" ","").replace("-", ""))
						  ); 

					if (!ok) {
						logger.fatal("LicenseChecker: Error validando la licencia Ignition del servidor en módulo de licencia IPG-Ignition: no hay correspondencia de CD-Keys.");
					}
				}
			}
		}
		catch (Exception e) {
			ok = false;
			logger.fatal("Error validando la licencia Ignition del servidor en módulo de licencia IPG-Ignition. ", e);
		}

		notes = notes + " Ignition license status: " + (ok ? Constants.OK : Constants.FAIL) + ". ";
		
		return ok;
	}

I'm a bit confused why you are doing any of this, instead of simply handling license information when the module subsystem calls the various hook methods. Why do you care if the gateway and/or SQL bridge are in trial mode?

I haven't quite pieced it together yet either, but I think they may have been issuing their own licensing blob that referenced an Ignition licensing/CD key, and then making sure that the Ignition Gateway running the module actually has a key that matches the one in their blob?

I don't know.

I used to do something similar with the "feature code" for my EtherNet/IP driver, just tied to the module licence key. It was ugly. I stopped doing that.

Yes, it is correct. We have our own licensing schema, and part of our validation is to check whether there's a valid Ignition license installed.

For doing that we use the methods I mentioned before, related LicenseManager.getLicense(). It quite obvious that this method is not available anymore in the latest version. Then how can we check if there is a valid Ignition license installed for version 8.1?

Is there a way in 8.1 to get installed license's CD Key through SDK? If so, could you please indicate here how to do it? Thanks in advance

Likely.

You'll need to poke around in the javadocs to figure out how to do this. Perhaps also some reflection. :man_shrugging:

It's not a supported operation. You should be looking at your own module license, not the platform license.