com.atlassian.crowd.manager.license
Class CrowdLicenseManagerImpl

java.lang.Object
  extended by com.atlassian.crowd.manager.license.CrowdLicenseManagerImpl
All Implemented Interfaces:
CrowdLicenseManager

public class CrowdLicenseManagerImpl
extends Object
implements CrowdLicenseManager


Constructor Summary
CrowdLicenseManagerImpl()
           
 
Method Summary
 int getCurrentResourceUsageTotal()
          This will calculate the number of unique Principals currently being used by Crowd.
 com.atlassian.extras.api.crowd.CrowdLicense getLicense()
          This will retrieve the license for the currently running Crowd instance.
 boolean isBuildWithinMaintenancePeriod()
           
 boolean isBuildWithinMaintenancePeriod(com.atlassian.extras.api.crowd.CrowdLicense license)
          Return's true if the current Build is within the maintenance period for the Crowd license
 boolean isBuildWithinMaintenancePeriod(String key)
           
 boolean isLicenseKeyValid(String key)
          Will validate that a given License key is valid
 boolean isLicenseValid()
          This will evaluate against the current license stored in Crowd LicenseStore
 boolean isLicenseValid(com.atlassian.extras.api.crowd.CrowdLicense license)
          Same logic as CrowdLicenseManager.isLicenseValid()
 boolean isResourceTotalOverLimit(float limit, int currentResourceCount)
          Calculates the percentage of currentResourceCount over the user limit on a license and returns true or false if the percentage is above the passed in limit.
 boolean isSetupLicenseKeyValid(String key)
          Checks if a license key valid for set up.
 void setApplicationManager(ApplicationManager applicationManager)
          Sets the application manager which is used to get the configurated applications.
 void setDirectoryManager(DirectoryManager directoryManager)
          Sets the directory manager which is used to lookup principals.
 void setLicenseStore(CrowdLicenseStore licenseStore)
           
 void setPropertyManager(PropertyManager propertyManager)
          Sets the property manager which is used to get and set the server license resource totals.
 com.atlassian.extras.api.crowd.CrowdLicense storeLicense(String license)
          This will store the license in the LicenseStore for the currently running Crowd instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrowdLicenseManagerImpl

public CrowdLicenseManagerImpl()
Method Detail

getLicense

public com.atlassian.extras.api.crowd.CrowdLicense getLicense()
Description copied from interface: CrowdLicenseManager
This will retrieve the license for the currently running Crowd instance.

Specified by:
getLicense in interface CrowdLicenseManager
Returns:
com.atlassian.license.License or null if not set.
See Also:
CrowdLicenseManager.getLicense()

storeLicense

public com.atlassian.extras.api.crowd.CrowdLicense storeLicense(String license)
Description copied from interface: CrowdLicenseManager
This will store the license in the LicenseStore for the currently running Crowd instance.

Specified by:
storeLicense in interface CrowdLicenseManager

isLicenseValid

public boolean isLicenseValid()
Description copied from interface: CrowdLicenseManager
This will evaluate against the current license stored in Crowd LicenseStore

Will return true if the License has not gone beyond its resource total and if the user is not running an evaluation version and it has not expired. This is an overriding method to @see isLicenseValid(License license), so will call getLicense() internally.

Specified by:
isLicenseValid in interface CrowdLicenseManager
Returns:
true if License has not gone beyond resource limit or is not an evalution and is expired.
See Also:
CrowdLicenseManager.isLicenseValid()

isSetupLicenseKeyValid

public boolean isSetupLicenseKeyValid(String key)
Description copied from interface: CrowdLicenseManager
Checks if a license key valid for set up. In particular, it does not check the current user count as there are no users configured when initially entering a license in the setup process.

Specified by:
isSetupLicenseKeyValid in interface CrowdLicenseManager
Parameters:
key - the String to validate.
Returns:
true if an only if the licene is valid, otherwise false.

isLicenseValid

public boolean isLicenseValid(com.atlassian.extras.api.crowd.CrowdLicense license)
Description copied from interface: CrowdLicenseManager
Same logic as CrowdLicenseManager.isLicenseValid()

Specified by:
isLicenseValid in interface CrowdLicenseManager

isLicenseKeyValid

public boolean isLicenseKeyValid(String key)
Description copied from interface: CrowdLicenseManager
Will validate that a given License key is valid

Specified by:
isLicenseKeyValid in interface CrowdLicenseManager
Parameters:
key - the String to validate
Returns:
true if an only if the licene is valid, otherwise false

getCurrentResourceUsageTotal

public int getCurrentResourceUsageTotal()
                                 throws CrowdLicenseManagerException
Description copied from interface: CrowdLicenseManager
This will calculate the number of unique Principals currently being used by Crowd. Please note: this is an expensive call and is actually stored in the database by a Quartz process LicenseResourceJob. Please use consider using PropertyManager.getCurrentLicenseResourceTotal() Note: Do not call this method from the web layer, as this is wrapped in a Spring managed transaction

Specified by:
getCurrentResourceUsageTotal in interface CrowdLicenseManager
Returns:
the number of users/principals.
Throws:
CrowdLicenseManagerException
See Also:
CrowdLicenseManager.getCurrentResourceUsageTotal()

isResourceTotalOverLimit

public boolean isResourceTotalOverLimit(float limit,
                                        int currentResourceCount)
Description copied from interface: CrowdLicenseManager
Calculates the percentage of currentResourceCount over the user limit on a license and returns true or false if the percentage is above the passed in limit.

Specified by:
isResourceTotalOverLimit in interface CrowdLicenseManager
Parameters:
limit - the percentage limit to test against
currentResourceCount - the current number of resources in the system.
Returns:
true if over limit, false otherwise.
See Also:
CrowdLicenseManager.isResourceTotalOverLimit(float,int)

isBuildWithinMaintenancePeriod

public boolean isBuildWithinMaintenancePeriod(com.atlassian.extras.api.crowd.CrowdLicense license)
Description copied from interface: CrowdLicenseManager
Return's true if the current Build is within the maintenance period for the Crowd license

Specified by:
isBuildWithinMaintenancePeriod in interface CrowdLicenseManager

isBuildWithinMaintenancePeriod

public boolean isBuildWithinMaintenancePeriod()
Specified by:
isBuildWithinMaintenancePeriod in interface CrowdLicenseManager

isBuildWithinMaintenancePeriod

public boolean isBuildWithinMaintenancePeriod(String key)
Specified by:
isBuildWithinMaintenancePeriod in interface CrowdLicenseManager

setPropertyManager

public void setPropertyManager(PropertyManager propertyManager)
Sets the property manager which is used to get and set the server license resource totals. This method is set by Spring.

Parameters:
propertyManager - Property manager implementation.

setApplicationManager

public void setApplicationManager(ApplicationManager applicationManager)
Sets the application manager which is used to get the configurated applications. This method is set by Spring.

Parameters:
applicationManager - APplications manager implementation.

setDirectoryManager

public void setDirectoryManager(DirectoryManager directoryManager)
Sets the directory manager which is used to lookup principals. This method is set by Spring.

Parameters:
directoryManager - Directory manager implementation.

setLicenseStore

public void setLicenseStore(CrowdLicenseStore licenseStore)


Copyright © 2012 Atlassian. All Rights Reserved.