Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use License API?

Admin Kanoah April 2, 2015

Hi,

I'm trying to use the license API for a plugin I'm developing. I could add some features as enabling all license management though "Manage add-ons" section, following this tutorial: https://developer.atlassian.com/market/add-on-licensing-for-developers/tutorial-adding-licensing-support-to-your-add-on

In spite of this, the rest of documentation is very confusing, showing another way to add licensing support, including an automatic control to disable the plugin when license is invalid. I ran into an error trying to use the atlas-create-jira-plugin-module as this documentation shows: https://developer.atlassian.com/market/add-on-licensing-for-developers/licensing-api-overview

What is the best way to add licensing support and check if it's valid? Why is this documentation so confusing and controversial? Am I missing something?

Thanks in advance!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 7, 2015

Hi Admin!

The article under the first link is sufficient so you can ignore rest of the documentation. When you have upm dependencies in your pom you can use flowing code snippet for checking the license:

/**
   * LicenseManager
   */
  @Autowired // or inject through the constructor params
  private PluginLicenseManager licenseManager;
 
 ...
 
  private boolean isLicenseOk() {
    if (licenseManager.getLicense().isDefined()) {
      PluginLicense pluginLicense = licenseManager.getLicense().get();
      /* Check and see if the stored license has an error. */
      if (pluginLicense.getError().isDefined()) {
        /* A license is currently stored, however, it is invalid (e.g. expired or user count mismatch) */
        licenseError = i18nHelper.getText("work-calendar.license.errors.invalid");
        return false;
      } else {
        return true;
      }
    } else {
      /* No license */
      licenseError = i18nHelper.getText("work-calendar.license.errors.noLicense");
      return false;
    }
  }

Here are licenses you can use for testing: https://developer.atlassian.com/market/add-on-licensing-for-developers/timebomb-licenses-for-testing

Admin Kanoah April 28, 2015

Your are totally right! I figure this out some weeks ago. I just think the documentation must be clearer. :)

Tomasz Kustrzynski May 2, 2015

Related question: Is there any recommended way of developing and testing your plugin while licensing is enabled? There is no infinite test license, so it gets disabled after 3 hours. I'd prefer not to have to disable and enable bits of code responsible for license validation.

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2015

For new plugin you have to disable/enable. For published plugin that on the marketplace I generate trial license.

Tomasz Kustrzynski May 2, 2015

Cheers @Volodymyr Krupach !

Tomasz Kustrzynski May 2, 2015

Actually, do you mean disable/enable licensing manually in the code, or something else? Also, I haven't published the plugin yet (as you can tell from the questions), but I assume there's a way of generating trial licenses from the atlassian console.

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2015

Hi @Tomek Klas ! I comment/uncomment in the code. Please let me know if you find out how to generate the license in the console.

Tomasz Kustrzynski May 4, 2015

Thanks. I now have service that checks the license and a magic variable that disables licensing, so it should be fine as long as I'll remember to change it before final testing and release :)

TAGS
AUG Leaders

Atlassian Community Events