Author Topic: Creating valid keys for Add-In to distribute  (Read 4333 times)

meeert

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Creating valid keys for Add-In to distribute
« on: September 13, 2021, 09:28:26 pm »
Dear forum members, I've made an Add-In which I would like to distribute to different EA users. I would like to implement a license key mechanism to the Add-In so only the users which registered the key can actually use the Add-In. However, I couldn't find a guide for how to implement this functionality.

What I know so far is:

1. The licence management tool should be used to register the Add-In key (inside EA)
2. There's 2 kind of keys. A private and a shared key.
3. There's a tool called Sparx Systems Keystore Service (used to manage the keystore for floating licenses), but I'm not sure of this is the tool I should use

Ultimately, my question is: How can I generate a license key for my Add-In which other users can activate to access the Add-In?

I've also got questions regarding how to update an Add-In once distributed, but that will come later.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Creating valid keys for Add-In to distribute
« Reply #1 on: September 13, 2021, 09:41:00 pm »
At some point I had implemented this into one of my add-ins, but I took it out later (because licenses didn't sell, so I made it free)

This is the bit that is still left over (now commented out) in my add-in class: https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/blob/16329fa051540343c24be3710bcd183818779e38/EAScriptAddin/EAScriptAddinAddinClass.cs

Code: [Select]
        #region Add-In License Management Events
        // /// <summary>
        // /// When a user directly enters a license key that doesn't match a Sparx Systems key into the License Management dialog EA_AddInLicenseValidate is broadcast to all Enterprise Architect Add-Ins,
        // /// providing them with a chance to use the Add-In key to determine the level of functionality to provide.
        // /// When a key is retrieved from the Sparx Systems Keystore only the target Add-In will be called with the key.
        // /// For the Add-In to validate itself against this key, the Add-In's EA_AddinLicenseValidate handler should return true to confirm that the license has been validated.
        // /// As the EA_AddinLicenseValidate event is broadcast to all Add-Ins, one license can validate many Add-Ins.
        // /// If an Add-In elects to handle a license key by returning true to EA_AddinLicenseValidate, it is called upon to provide a description of the license key through the
        // /// EA_AddinLicenseGetDescription event.
        // /// If more than one Add-In elects to handle a license key, the first Add-In that returns true to EA_AddinLicenseValidate is queried for the license key description.
        // /// </summary>
        //        /// <param name="Repository">An EA.Repository object representing the currently open Enterprise Architect model.
        //        /// Poll its members to retrieve model data and user interface status information.</param>
        // /// <param name="AddinKey">The Add-in license key that has been entered in the License Management dialog.</param>
        // /// <returns>For the Add-in to validate against this key it should return true to indicate that the key is valid and has been handled.</returns>
        // public override bool EA_AddInLicenseValidate(EA.Repository Repository, string AddinKey)
        // {
        // License eaLicense = new License(AddinKey, publicKey);
        // if (eaLicense.isValid)
        // {
        // //the license is valid so replace the evaluation license with this one
        // this.license = eaLicense;
        // }
        // //debug
        // EAAddinFramework.Utilities.Logger.log("license.Isvalid = "+eaLicense.isValid.ToString()+" for license key: " + AddinKey);
        // return license.isValid;
        // }
        //
        // /// <summary>
        // /// Before the Enterprise Architect License Management dialog is displayed, EA_AddInLicenseGetDescription is sent once for each Add-In key to the first Add-In that elected to handle that key.
        // /// The value returned by EA_AddinLicenseGetDescription is used as the key's plain text description.
        // /// </summary>
        //        /// <param name="Repository">An EA.Repository object representing the currently open Enterprise Architect model.
        //        /// Poll its members to retrieve model data and user interface status information.</param>
        // /// <param name="AddinKey">The Add-In license key that Enterprise Architect requires a description for.</param>
        // /// <returns>A String containing a plain text description of the provided AddinKey.</returns>
        // public override string EA_AddinLicenseGetDescription(EA.Repository Repository, string AddinKey)
        // {
        // string licensedescription = string.Empty;
        // License license = new License(AddinKey, publicKey);
        // if (license.isValid)
        // {
        // licensedescription = "License for EA-Matic issued to " + license.client;
        // }
        // return licensedescription;
        // }
        //
        //
        // /// <summary>
        // /// As an add-in writer you can distribute keys to your add-in via the Enterprise Architect Keystore providing your
        // /// keys are generated using a prefix that allows Enterprise Architect to identify the add-in to which they belong.
        // /// EA_GetSharedAddinName is called by Enterprise Architect to determine what prefix an add-in is using.
        // /// If a matching key is found in the keystore the License Management dialog will display the name returned
        // /// by EA_AddinLicenseGetDescription to your users.
        // /// Finally, when the user selects a key, that key will be passed to your add-in to validate
        // /// by calling EA_AddinLicenseValidate.
        // /// </summary>
        //        /// <param name="Repository">An EA.Repository object representing the currently open Enterprise Architect model.
        //        /// Poll its members to retrieve model data and user interface status information.</param>
        // /// <returns>A String containing a product name code for the provided Add-In. This will be shown in plain text at the start of any keys added to the keystore. We recommend contacting Sparx Systems directly with proposed values to ensure you don't clash with any other add-ins.
        // /// eg. The following keys would all be interpreted as belonging to an add-in returning "MYADDIN" from this function:
        // /// · MYADDIN-Test
        // /// · MYADDIN-{7AC4D426-9083-4fa2-93B7-25E2B7FB8DC5}
        // /// · MYADDIN-7AC4D426-9083-4fa2-93B7
        // /// · MYADDIN-25E2B7FB8DC5
        // /// · MYADDIN-2hDfHKA5jf0GAjn92UvqAnxwC13dxQGJtH7zLHJ9Ym8=</returns>
        // public override string EA_GetSharedAddinName(EA.Repository Repository)
        // {
        // return "EAMatic";
        // }

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Creating valid keys for Add-In to distribute
« Reply #2 on: September 14, 2021, 09:05:44 am »
How can I generate a license key for my Add-In which other users can activate to access the Add-In?

I've also got questions regarding how to update an Add-In once distributed, but that will come later.
Both questions are general software development questions. EA doesn't place a lot of constraints or offer any help.

The private key can be anything users can enter into the field. The shared key is the same, but with a prefix so that the keystore knows which add-in it's for.

The easiest update mechanism is to simply distribute a new version of the software it being an add-in for EA doesn't change anything.