# getLicense method

**URL:** <https://forum.inductiveautomation.com/t/getlicense-method/78852>\
**Category:** Module Development\
**Tags:** ignition81\
**Created:** [September 7, 2023, 11:33am UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852 "2023-09-07T11:33:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnny.alvarado](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@johnny.alvarado](https://forum.inductiveautomation.com/u/johnny.alvarado)\
**Post date:** [September 7, 2023, 11:33am UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/1 "2023-09-07T11:33:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 7, 2023, 11:34am UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/2 "2023-09-07T11:34:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![johnny.alvarado](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@johnny.alvarado](https://forum.inductiveautomation.com/u/johnny.alvarado)\
**Post date:** [September 8, 2023, 11:25am UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/3 "2023-09-08T11:25:36Z")

</div>

Hi Kevin,

The error we get is

 ![IAF - Module Error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/cea9fb062b8f2c94a20f2bdc9372cf8cae29085d.jpeg)

and the code we are using is

 ![IAF - Code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/0/a04e1684e9158afb89e64eb67fcaa7260f394fa9.jpeg)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 8, 2023, 11:37am UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/4 "2023-09-08T11:37:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 8, 2023, 11:48am UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/5 "2023-09-08T11:48:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnny.alvarado](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@johnny.alvarado](https://forum.inductiveautomation.com/u/johnny.alvarado)\
**Post date:** [September 8, 2023, 8:04pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/6 "2023-09-08T20:04:41Z")

</div>

Hello,

I'm sorry for the confusion.

We do the call from the following statement

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

```

where the License object comes from

```auto
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.

```auto
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;
	}

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 8, 2023, 8:09pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/7 "2023-09-08T20:09:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 8, 2023, 8:12pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/8 "2023-09-08T20:12:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 8, 2023, 8:51pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/9 "2023-09-08T20:51:23Z")

</div>

> [@Kevin.Herron](#):
>
> issuing their own licensing blob

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.

---

<div class="post-metadata">

**Author:** ![johnny.alvarado](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@johnny.alvarado](https://forum.inductiveautomation.com/u/johnny.alvarado)\
**Post date:** [September 11, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/10 "2023-09-11T15:55:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pocewar](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pocewar/32/8186_2.png) [@pocewar](https://forum.inductiveautomation.com/u/pocewar)\
**Post date:** [October 2, 2023, 2:44pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/11 "2023-10-02T14:44:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 2, 2023, 2:48pm UTC](https://forum.inductiveautomation.com/t/getlicense-method/78852/12 "2023-10-02T14:48:24Z")

</div>

> [@pocewar](#):
>
> Is there a way

Likely.

> [@pturmel](#):
>
> I stopped doing that.

You'll need to poke around in the javadocs to figure out how to do this. Perhaps also some reflection. 🤷‍♂️

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