Snippets: Getting License Information from the Confluence API

May 6th, 2010 by

Sometimes one needs to look up license details of a running Confluence system .. perhaps for creating a commercial plugin or to display recommendations dependant from the license used. For this reason there are a few possibilities for receiving some license information from the Confluence API or the velocity context.

Note: This article is outdated since the Atlassian Marketplace was launched and a shiny new licensing API was added. Until this article is updated I strongly recommend to take a closer look at the detailed information that Atlassian is providing in the Developer Documentation.


Available Velocity/Sitemesh Objects

Parsing through the list of available velocity objects I found some useful objects/methods for handling license stuff:

  • GeneralUtil – available as $generalUtil in velocity
    static String checkPartnerDetails(com.atlassian.license.License license, String buildPartnerName)
    static String getVersionNumber()
    static boolean hasTooManyUsers()
    static boolean isLicenseExpired()
  • ConfluenceActionSupport – available as $action in velocity
    static String LICENSE_EXPIRED
    boolean isDevMode()

Confluence API

The entry point for getting license information is the LicenseManager – there is also a LicenseCalculator but I haven’t tested it yet. I’ve build a simple Velocity Context Module Plugin sample to display some information from the API in a velocity template – it’s just a simple class and some xml in the plugin descriptor:

  • The pom.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns=""
     <name> - Confluence License Snippets</name>
     <!-- Confluence version -->
     <!-- Confluence plugin functional test library version -->
     <!-- Confluence data version -->
     <description> - Confluence License Snippets</description>
  • The atlassian-plugin.xml
    <atlassian-plugin key="${atlassian.plugin.key}" name="license-snippets" pluginsVersion="2">
     <description> - License Demo Plugin</description>
     <vendor name="" url=""/>
     name="License Demo Helper"
  • The class VeloHelper in the package com.hascode.confluence.demo
    package com.hascode.confluence.demo;
    import com.atlassian.confluence.setup.ConfluenceBootstrapConstants;
    import com.atlassian.license.License;
    import com.atlassian.license.LicenseManager;
    import com.atlassian.license.LicenseType;
    import com.atlassian.license.applications.confluence.ConfluenceLicenseTypeStore;
    public class VeloHelper {
    	private LicenseManager licenseManager;
    	private License confluenceLicense;
    	public VeloHelper() {
    		licenseManager = LicenseManager.getInstance();
    		confluenceLicense = licenseManager.getLicense(ConfluenceBootstrapConstants.DEFAULT_LICENSE_REGISTRY_KEY);
    		// or: confluenceLicense = licenseManager.getLicense("CONF");
    	public LicenseManager getLicenseManager() {
    		return licenseManager;
    	public LicenseType getConfluenceLicenseType() {
    		return confluenceLicense.getLicenseType();
    	public long getConfluenceLicenseDuration() {
    		return confluenceLicense.getLicenseDuration();
    	public double getNumberofAllowedUsers() {
    		// return the number of allowed users for academic version
    		// for unlimited licenses License.getUsers() will return a value greater
    		// than 9999, typically 10000
    		// source:
    		return confluenceLicense.getUsers();
    	public boolean isAcademicLicense() {
    		if (confluenceLicense.getLicenseType().equals(ConfluenceLicenseTypeStore.ACADEMIC)) {
    			return true;
    		return false;
    	public boolean isEvaluationLicense() {
    		if (confluenceLicense.getLicenseType().equals(ConfluenceLicenseTypeStore.EVALUATION)) {
    			return true;
    		return false;
    	// [..]
  • Run the stuff
    mvn -Pplugin-debug

Available License Types

To evaluate which license is currently used simply compare the received license type to the types available in ConfluenceLicenseTypeStore as they are:


Third party software

The nice guys from Customware have created License Support Libraries and posted some helpful information about licensing a plugin – in addition you’re able to check out the libs from

I haven’t tested these tools – perhaps it is worth a look .. there is also an ongoing discussion about this topic in the Confluence Developer Forum from Atlassian..

Quick Testing the Examples above

If you want a quick test of the examples above using the existing- or created velocity objects just go to the Confluence Administration Area > Look & Feel > Layouts and change an existing decorator e.g. the page decorator and use the velocity objects.If you do so – be sure to have the standard Confluence theme activated..

Here some screenshots using the created velocity helper object in the page decorator and the output of the amount of allowed users in the page view


Tags: , , , , , , , ,