PDA

View Full Version : License.getFeature() returning null



Temujin_12
08-11-2010, 12:17 PM
Using the 10.8 Java toolkit, I am loading a License object. However, when I try to get the feature information (ie: expiration date, VENDOR_STRING, NOTICE, etc.) License.getFeature() returns null.

Here's my license (sensitive information removed):


myVendor
FEATURE myfeatureName myVendor 1.0 29-jul-2011 uncounted \
VENDOR_STRING=myVendorString
NOTICE="myNotice" SIGN=...


I am loading the license as follows:



FeatureSpecifier feature = new FeatureSpecifier("myFeatureName", "1.0");
VendorInfo vendoInfo = new myVendorInfo();

String licenseSource = "@localhost@" + licenseFileStr;
License flexLicense = new License(feature, licenseSource, vendorInfo, null);

// this is null
Feature f = flexLicense.getFeature();

// this is not null but doesn't have the info i need
FeatureSpecifier fs = flexLicense.getFeatureSpecifier();


Why is the Feature object null?

RobertDickau
08-11-2010, 12:44 PM
Does anything change if you check out the license between creating the License object and before calling getFeature?

License flexLicense = new License(feature, licenseSource, vendorInfo, null);

flexLicense.checkout(1); // add this

Feature f = flexLicense.getFeature( );

Temujin_12
08-11-2010, 12:50 PM
Hmmm... adding flexLicense.checkout(1) throws this exception:



FlexlmException: Can't Connect to License Server (-15,3002) (localhost@[MY LICENSE FILE LOCATION])


Note that [MY LICENSE FILE LOCATION] is the "licenseFileStr" value concatenated to the licenseSource variable in my previous code snippet.

Also, I've noticed that I can tamper with the license file and it doesn't complain about it. Is the signature only validated on checkout?

EDIT: Thanks for the quick reply RobertDickau!

RobertDickau
08-11-2010, 12:58 PM
That excerpt you posted is for an unserved license because of the "uncounted" keyword, so perhaps put a count (of 1 or something) in that field and add the SERVER and VENDOR lines if necessary, and then re-sign the license and restart the server?
SERVER this_host ANY
VENDOR myVendor
INCREMENT myfeatureName myVendor 1.0 29-jul-2011 1 \
VENDOR_STRING=myVendorString \
NOTICE="myNotice" SIGN=...

The license server should complain if a license it's meant to serve has a bad signature, but for an uncounted license the client API is the first thing that notices.

P.S. For a server, which licenses to serve from is specified when you launch lmgrd or lmadmin. In the Java code, just use "@server" without the file name in the license source...

Temujin_12
08-11-2010, 01:12 PM
I'm trying to do this all without any license server at all. All I want to do is 1) load the information contained in the license and 2) validate the signature.

In reading the documentation, I got the impression that that can all be done "offline" (so to speak) using uncounted licenses stored locally on disk.

Am I confusing how to do this perhaps (assuming it is possible)?

PS: Thanks again for working through this with me.

RobertDickau
08-11-2010, 01:23 PM
From an unserved, node-locked license, perhaps sign this in a file test.lic:

INCREMENT myFeatureName myVendor 1.0 1-jan-2012 uncounted \
HOSTID=DEMO VENDOR_STRING="Greetings from a license file!" \
SIGN=0In your Java code, then, just use the file name "test.lic" (including its path, if it's in a different directory from your application) in the license source. (You won't need the "@server" part, which is used only for counted/served licenses).

(It's my pleasure to help---you caught me during my lunch break, so good timing...)

Temujin_12
08-11-2010, 01:30 PM
Nice, now I get this error (missing jar is easier to deal with than internal flex errors):


java.lang.NoClassDefFoundError: com/certicom/ecc/jcae/Certicom

I'll track this down (unless you know off-hand what jar this is in).


It's my pleasure to help---you caught me during my lunch break, so good timing...

You should take lunch breaks more often. ;-)

Temujin_12
08-11-2010, 01:33 PM
I'll track this down (unless you know off-hand what jar this is in).


Found it:


$ jar -tvf EccpressoAll.jar | grep Certicom
466 Tue Mar 12 03:22:02 PST 2002 com/certicom/ecc/jcae/Certicom$1.class
6389 Tue Mar 12 03:22:02 PST 2002 com/certicom/ecc/jcae/Certicom.class

RobertDickau
08-11-2010, 01:34 PM
Hmmm, I'm pretty sure that class is in EccpressoAll.jar.

Robert

P.S. Thanks for posting the confirmation... Onward!

Temujin_12
08-11-2010, 01:57 PM
Almost there...

Now with the EccpressoAll.jar added, I get the following exception (note I haven't changed the license format at all yet):



FlexlmListException: Error list Returned (-513,4050) ; Authentication Failed (-8,4048)
at com.macrovision.flexlm.lictext.LicenseGroup.aggregate(LicenseGroup.java:308)
at com.macrovision.flexlm.lictext.LicenseGroup.<init>(LicenseGroup.java:133)
at com.macrovision.flexlm.licsource.LicenseFile.<init>(LicenseFile.java:79)
at com.macrovision.flexlm.License.<init>(License.java:217)
...


... when the following line is executed:



String licenseSource = licenseFileStr; // note "@localhost@" is now removed
License flexLicense = new License(feature, licenseSource, vendorInfo, null); // exception above thrown here



Is it trying to authenticate with a server here, or is this the expected error when the signature fails?

RobertDickau
08-11-2010, 02:09 PM
Right, that exception is expected when the signature authentication fails; I see it if I sign a license file and then modify its contents without re-signing.

Temujin_12
08-24-2010, 02:17 PM
Are there any other issues that may cause this error to occur? I can't seem to be able to get past it.

I've tried on both a mac (powerbook) and pc (ubuntu).

RobertDickau
08-24-2010, 03:44 PM
Does the simple lmflex example from the native toolkit work on these systems? Does the BasicExample sample from the Java toolkit work?

Temujin_12
08-24-2010, 10:53 PM
I believe my license format indicates that it is supposed to use a license server.

So, if I change the license format to:



SERVER this_host ANY
VENDOR myVendor
FEATURE myFeature myVendor 1.0 31-aug-2011 uncounted \
VENDOR_STRING=myVendorString HOSTID=ANY \
NOTICE="myNotice" SIGN=0123456789AB


... then it loads, but now the signature seems to no longer be checked (ie: I can modify anything, including the signature itself, and it still loads.

I also noticed that:


flexLicense.getFeature()

is still null. Also that:


flexLicense.getFeatureSpecifier()

... only seems to contain the FEATURENAME and the VERSION.

One step forward, two steps back it seems.

RobertDickau
08-25-2010, 01:38 PM
If you have the BasicExample from the Java toolkit, compiling and running that might be the easiest way to verify that the general system works.

Create the unsigned license file j.lic (replacing "demo" with your publisher name):
INCREMENT jtest demo 1.0 1-jan-2020 uncounted HOSTID=DEMO \
VENDOR_STRING=OK? SIGN=0

Sign j.lic with lmcrypt; verify SIGN= looks like a signature.

Run java -cp .:flexlm.jar:EccpressoAll.jar BasicExample jtest 1.0 j.lic

Should print something like:

jtest checked out (VS: OK?)
Hit return to check in:
Does that do it? It's not surprising that getFeature returns null if checkout hasn't succeeded beforehand...