Skip to Content
Author's profile photo Jason Everly

How can I add a new license key to Business Objects Enterprise using the Enterprise SDK?

I had a customer with a requirement to be able to add a license key to an Enterprise installation from their application.  My first thought was “Nope, can’t be done” until I looked into it further and found that I was completely wrong 🙂

Using the Java Enterprise SDK you can add a keycode to Enterprise. As for .NET, there seems to be a setLicenseKey off the ILicenseKey in .NET, but it is not documented and I have not tested it.

Here is the code:

bq. Add Keycode<br /><textarea cols=”75″ rows=”10″><%@ page import = “com.crystaldecisions.sdk.occa.infostore.*,
                   com.crystaldecisions.sdk.plugin.desktop.common.*,
                   com.crystaldecisions.sdk.framework.*,
                   com.crystaldecisions.sdk.occa.security.*,
                   com.crystaldecisions.sdk.exception.SDKException,
                   com.crystaldecisions.sdk.occa.managedreports.IReportSourceFactory,
                   java.util.Locale,
                   javax.servlet.jsp.JspWriter,
                   com.crystaldecisions.sdk.occa.pluginmgr.*,
                   com.crystaldecisions.sdk.occa.report.reportsource.IReportSource,
                   com.crystaldecisions.sdk.plugin.desktop.licensekey.*”
%>

<%!
/** This function adds a license key to the CMS database.

‘ Parameters:

‘ IStore
‘     he InfoStore object.
‘LicenseKey
‘    The license key you want to add to the CMS database.

‘ Returns: Nothing.
*/
void AddLicenseKey (IInfoStore IStore, String LicenseKey, JspWriter out) throws java.io.IOException
{

    IPluginMgr PluginMgr;
    IPluginInfo LicenseKeyPlugin;
    IInfoObjects NewInfoObjects;
    ILicenseKey NewLicenseKey;

    PluginMgr = IStore.getPluginMgr();
    // Get the LicenseKey plugin.
    try{
         LicenseKeyPlugin = PluginMgr.getPluginInfo(“CrystalEnterprise.LicenseKey”);
         // Create a new InfoObjects collection. This will be used to store the new object
          // that will be committed later.
          NewInfoObjects  = IStore.newInfoObjectCollection();
          
          // Add the result of the plugin. This will create a new InfoObject that
          //represents a LicenseKey.
         NewLicenseKey = (ILicenseKey)NewInfoObjects.add (LicenseKeyPlugin);
         
         out.println(“Adding ” + LicenseKey + “<BR><BR>”);
         NewLicenseKey.setLicenseKey(LicenseKey);
         
         IStore.commit (NewInfoObjects);
    }
    catch (SDKException e)
    {
         out.println(e.toString() + “<BR><BR>”);
          out.println(e.getMessage());
     return;     
    } 
}
%>
<%!
/** This function checks to see if a license key already exists in the cmc.

‘ Parameters:

‘ IStore
‘     he InfoStore object.
‘LicenseKey
‘    The license key you want to add to the CMS database.

‘ Returns: true if the key is OK to be added, false if it is already in the system.
*/
boolean CheckLicenseKey (IInfoStore IStore, String LicenseKey, JspWriter out) throws java.io.IOException
{

    IPluginMgr PluginMgr;
    IPluginInfo LicenseKeyPlugin;
    IInfoObjects licenseKeys;
    ILicenseKey licenseKey;
    int i;

    PluginMgr = IStore.getPluginMgr();
    // Get the LicenseKey plugin.
    try{

         
         licenseKeys = IStore.query(“SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_PROGID = ‘crystalenterprise.licensekey'”);
         
         for(i = 0; i < licenseKeys.size(); i++)
         {
              licenseKey = (ILicenseKey)licenseKeys.get(i);
              //key is duplicated, dont add it
               if(licenseKey.getLicenseKey().equalsIgnoreCase(LicenseKey))
              {
                    out.println(licenseKey.getLicenseKey());
                   return true;
              }

         }         
    }
    catch (SDKException e)
    {
         out.println(e.toString() + “<BR><BR>”);
          out.println(e.getMessage());
     return true;     
    } 

    return false;
}
%>
<%
    IInfoStore iStore=null;
    IInfoObjects oInfoObjects=null;
    IInfoObject oInfoObject=null;
    IEnterpriseSession es = null;
    IReportSource reportSource=null;

    String user = “Administrator”;
    String password = “”;
    String cmsName = “localhost”;
    String cmsAuthType = “secEnterprise”;

    // Logon and obtain an Enterprise Session
  
    es = CrystalEnterprise.getSessionMgr().logon( user, password, cmsName, cmsAuthType);
        
     //Grab the InfoStore from the httpsession
    iStore = (IInfoStore) es.getService(“”, “InfoStore”);
  

    try
    {
          if(CheckLicenseKey(iStore, “Enter keycode here with dashes”, out))
         {
              out.println(“This is a duplicate key<BR><BR>”);
         }
         else
         {
               AddLicenseKey(iStore, “Enter keycode here with dashes”, out);
        }
    }
    catch(java.io.IOException e)
    {
         out.println(e.toString());
         out.println(e.getMessage());
     return;
    }
   
%>
</textarea>
<p>Good luck on your projects!</p><p>Jason</p>

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Gilles Crebassa
      Gilles Crebassa
      Hi,

      It's not already existing in javascript format with the installation ?

      Author's profile photo Gilles Crebassa
      Gilles Crebassa
      I have found in ./bobje/setup/jscripts/addlicensekey.js
      Author's profile photo Jason Everly
      Jason Everly
      Blog Post Author
      This customer wanted to add in this functionality into his jsp application, not javascript.

      This can be used to add a new key after the enterprise system is already in place and running.  It could be that you are adding more users, adding different type of user, etc.