PDA

View Full Version : How to load license from string



Temujin_12
07-28-2010, 10:38 AM
I'm using the 10.8 version of the Java API for FlexNet Publisher. The documentation states:


The following forms can be used to specify the license path:
- A single file ...
- port@host ...
- A redundant server configuration ...
- A license certificate in a string. Precede the license certificate string with the string
FlexlmConstants.LICENSE_STRING_PREFIX
and end it with the string
FlexlmConstants.LICENSE_STRING_SUFFIX

I've written the following Java code to do this:



protected com.macrovision.flexlm.License loadFlexlmLicenseFromString(String licenseStr) throws LicensingException {
com.macrovision.flexlm.License flexLicense = null;

try {
String licenseSource = FlexlmConstants.LICENSE_STRING_PREFIX
+ licenseStr
+ FlexlmConstants.LICENSE_STRING_SUFFIX;

log.info("loading flexlm license string");
flexLicense = new com.macrovision.flexlm.License(myFeature, licenseSource, myVendorInfo, null);

return flexLicense;
}
catch (Exception e) {
log.info("caught exception loading flexlm license: ", e);
throw new LicensingException(e);
}
}


However, this always returns the following error:

com.macrovision.flexlm.FlexlmListException: Error List Returned (-513,7) ; Error List Returned (-513,4052) ; Can't Find License File (-1,4042)

Does anyone know what is the proper way to load a license file from a String?

And no, using a newer version is not an option.

RobertDickau
07-29-2010, 05:33 PM
I don't have a 10.8 toolkit at hand, but in a quick test, a similar modification to the example from the FNP 11.8 toolkit seemed to work. In BasicExample.java, I replaced the existing lic = new License(...) line with this:

lic = new License(fs,
FlexlmConstants.LICENSE_STRING_PREFIX +
"INCREMENT F1 demo 1.0 1-jan-2012 uncounted " +
"VENDOR_STRING=\"Greetings from a license in a buffer!\" " +
"HOSTID=DEMO SIGN=\"...\"" +
FlexlmConstants.LICENSE_STRING_SUFFIX,
vInfo, connData);
Running java -cp jars BasicExample F1 then reported success with this hard-coded license in a string...