yFiles FLEX License Validation
Applies to: yFiles FLEX 1.6, 1.5, 1.4, 1.3 print article email article

Type: Troubleshooting

Categories this article belongs to:
yFiles FLEX > Licensing

This article describes how to setup license validation for a custom yFiles FLEX application.

Validation of the yFiles FLEX license file

It is possible to validate the license using either Actionscript or (from yFiles FLEX 1.3.1 on) MXML.

Using MXML (recommended):

To register the license using MXML code, yFiles Flex offers the com.yworks.mxml.LicenseTool:

<yworks:LicenseTool>
	<mx:XML id="licenseXML" source="license.xml" />
</yworks:LicenseTool>

You have to tell Flex where to find the LicenseTool by defining the namespace yworks in your <mx:Application> tag: add the xmlns:yworks="http://www.yworks.com/xml/yfiles-flex/1.3/mxml" property. If you used code completion to insert the LicenseTool tag, FlexBuilder inserted the definition already for you:

<mx:Application
  xmlns:mx="http://www.adobe.com/2006/mxml"
  xmlns:yworks="http://www.yworks.com/xml/yfiles-flex/1.3/mxml"
  layout="absolute">

Note
When developing a spark application, the <yworks:LicenseTool> tag has to be included in the declaration section:
<fx:Declarations>
<yworks:LicenseTool>
...
</fx:Declarations>

Instead of loading the license from a file you can alternatively paste the contents of the license file:

<yworks:LicenseTool>
  <mx:XML>
    <license>
      ...
    </license>
  </mx:XML>
</yworks:LicenseTool>
The LicenseTool registers the license automatically when the application starts.

Using ActionScript:

In order to validate a license via ActionScript, two steps need to be taken:

  1. The license file information needs to be available at runtime. This can be achieved either by using the <mx:XML> tag in an MXML file or by creating an XML object in an ActionScript section.
    1. Using the MXML tag:
      <mx:XML id="licenseXML" source="license.xml" />
    2. Using an XML object:
      var licenseXML:XML = new XML;
      licenseXML =
        <license>
         [paste license file content here]
        </license>
  2. The license validation function has to be called:
    com.yworks.util.Util.registerLicense( licenseXML );
    

A minimal MXML file that validates the yFiles FLEX license looks like this:

<mx:Application preinitialize="init()">
<mx:XML id="licenseXML" source="license.xml"/>
<mx:Script>
<![CDATA[
    import com.yworks.util.Util;

    private function init():void {
      Util.registerLicense( licenseXML );
    }
]]>
</mx:Script>
</mx:Application>

Why do I get the "Invalid license information" error message?

There are some possible reasons why this message can be shown:
  • The license validation function (com.yworks.util.Util.registerLicense) is not called at all. Make sure the function that contains the registerLicense call is called. For example, if the function is contained in a script block directly in the MXML file, don't forget to register the function as a listener of the Application's "preinitialize", "initialize", "applicationComplete" or "creationComplete" event:
    <mx:Application 
      ...
      preinitialize="myInitFunction()"
      ..
      >
  • The license registration takes to long (e.g. due to hight CPU load) and isn't finished early enough. Try to register the license using the preinitialize event or the LicenseTool component.
  • The design mode of the Adobe Flex Builder is used. Please see below for a workaround.
  • You used a license.xml file of yFiles FLEX 1.1 with an earlier version of the library. The license format has changed between versions 1.1-RC2 and 1.1.

yFiles FLEX domain license validation

For domain licenses, yFiles FLEX uses the domain name reported by the LocalConnection#domain property. The domain name corresponds to the domain of the URL shown in the location bar when a yFiles FLEX application is accessed by a browser. If the SWF is accessed using an IP address, the domain property will report the IP.

Because the server's IP adress is not known to the SWF when the SWF was accessed using a domain name, license validation based on an IP adress will only work if the SWF is accessed by entering the IP adress in the browser's location bar. This means that, assuming "exampledomain.com" is mapped to an IP adress allowed by the yFiles FLEX domain license, license validation will fail, if "exampledomain.com" is entered in the location bar instead of the IP adress (unless the license is also valid for "exampledomain.com").

If a yFiles FLEX domain license should be valid for a range of IP adresses, all individual IP adresses which are part of that range have to be specified explicitly for the license file.

If an evaluation license is used, validation will fail if the name of the swf file's originating host differs from "localhost". If you are unsure about the hostname that is reported for swf files delivered from your web server, you can check the domain name using one of the following two approaches:

  • Upload the DomainUtil.swf that is attached to this article as a resource to your web server and request the SWF in a browser. The SWF will report the domain name and it allows to enter domain name strings that will be matched against the reported domain.
  • Use the following small mxml application to print the host name that will be used for the yFiles FLEX license validation:
    <mx:Application 
    	xmlns:mx="http://www.adobe.com/2006/mxml" 
    	layout="absolute" applicationComplete="run()">
    	<mx:Script>
    		<![CDATA[
    			import mx.controls.Alert;
    			private function run():void {
    				Alert.show("Host: "+new LocalConnection().domain,"Host Test" );
    			}			
    		]]>
    	</mx:Script>
    </mx:Application>
    

Note that with the license validation procedure described in the readme file, it is not possible to replace the license information at runtime. If the license data for a yFiles FLEX application changes, the application has to be recompiled, so the new license data can be embedded into the swf at compile time.

It is not recommended to load the license XML file at runtime. If the license data is not embedded into the yFiles FLEX application at compile time, it won't be guaranteed that the license data is available when the license information is verified. Also, if the license is embedded at compile time, no license.xml file has to be deployed with the application.

Using the yFiles FLEX Graph Canvas in the Flex Builder Design View

In yFiles FLEX releases up to (and including) release 1.0.1, the license validation did not work correctly when the Flex Builder design mode was used. A workaround for this issue is to use an empty subclass implementation of com.yworks.ui.GraphCanvasComponent instead:

Create a file ui/MyCanvasComponent.as:

package ui
{
    import com.yworks.ui.GraphCanvasComponent;
    public class MyCanvasComponent extends GraphCanvasComponent {}
}
In order to use the subclass in an MXML file, a namespace needs to be bound to the corresponding package:
<mx:Application
  ...
  xmlns:ui="ui.*">
Now, the subclass component can be used in the MXML file:
<ui:MyCanvasComponent id="graphCanvas" ... />
Using this workaround, no "invalid license file" message should pop up anymore.

Testing a yFiles FLEX application locally with a domain license

Testing a yFiles FLEX application on the same machine that is used for development shouldn't be a problem, because all yFiles FLEX domain licenses allow running the application on localhost as well.

However, if a yFiles FLEX application has to be accessed from a different machine in the local area network, validation of a domain license will fail. This can be avoided easily by modifying the local hosts file accordingly. The hosts file is available on all operating systems at different locations and can be used to map IP addresses to domain names manually, taking precedence over the normal DNS lookup.

Assume that you own a yFiles FLEX license that is valid for the domain "mydomain.com", and that a yFiles FLEX application runs on a machine called flexbox with IP 192.168.0.3 in the LAN. If another machine (testbox) wants to acces that application, a line can be added to the hosts file on testbox that maps flexbox's IP to a subdomain of "mydomain.com", e.g.

192.168.0.3		flexbox.mydomain.com
Now, the yFiles FLEX application can be accessed from testbox using the mapped domain name, e.g. http://flexbox.mydomain.com/yfilesflexapp/.

The following table lists the default locations of the hosts file on some operation systems.

OS Location of hosts
Windows NT/2000/XP/2003/Vista %SystemRoot%\system32\drivers\etc\
Linux/*nix /etc
Mac OS X /private/etc


Keywords: license - licence - validation - activation - validate - invalid - Flex Builder - design view - design mode - domain - host - localhost - lan

Provide feedback:
How useful was this article?    less 1 2 3 4 5 more
Email address (optional):
COPYRIGHT © 2012 yWorks · ALL RIGHTS RESERVED imprint | terms of use | privacy policy | home