Class BeCPGLicenseManager

java.lang.Object
fr.becpg.repo.license.BeCPGLicenseManager

@Service("becpgLicenseManager") @DependsOn public class BeCPGLicenseManager extends Object

BeCPGLicenseManager class.

Version:
$Id: $Id
Author:
matthieu
  • Field Details

    • INVALID_LICENSE_FILE

      private static final String INVALID_LICENSE_FILE
      Constant INVALID_LICENSE_FILE="Invalid license file"
      See Also:
    • logger

      private static final org.apache.commons.logging.Log logger
      Constant logger
    • beCPGCacheService

      @Autowired private BeCPGCacheService beCPGCacheService
    • repoService

      @Autowired private RepoService repoService
    • nodeService

      @Autowired private org.alfresco.service.cmr.repository.NodeService nodeService
    • contentService

      @Autowired private org.alfresco.service.cmr.repository.ContentService contentService
    • authenticationService

      @Autowired private org.alfresco.repo.security.authentication.AbstractAuthenticationService authenticationService
    • authorityService

      @Autowired private org.alfresco.service.cmr.security.AuthorityService authorityService
    • showLicenseWarning

      @Value("${beCPG.licence.showWarning:true}") private boolean showLicenseWarning
    • concurrentUsersAllowedMap

      private final Map<UserLicense,Set<String>> concurrentUsersAllowedMap
  • Constructor Details

    • BeCPGLicenseManager

      public BeCPGLicenseManager()
  • Method Details

    • isShowLicenseWarning

      public boolean isShowLicenseWarning()

      isShowUnauthorizedWarning.

      Returns:
      a boolean.
    • getAllowedConcurrentRead

      public long getAllowedConcurrentRead()

      getAllowedConcurrentRead.

      Returns:
      a long.
    • getLicense

      private BeCPGLicense getLicense()

      getLicense.

      Returns:
      a BeCPGLicense object
    • getAllowedConcurrentWrite

      public long getAllowedConcurrentWrite()

      getAllowedConcurrentWrite.

      Returns:
      a long.
    • getAllowedConcurrentSupplier

      public long getAllowedConcurrentSupplier()

      getAllowedConcurrentSupplier.

      Returns:
      a long.
    • getAllowedNamedWrite

      public long getAllowedNamedWrite()

      getAllowedNamedWrite.

      Returns:
      a long.
    • getAllowedNamedRead

      public long getAllowedNamedRead()

      getAllowedNamedRead.

      Returns:
      a long.
    • getLicenseName

      public String getLicenseName()

      getLicenseName.

      Returns:
      a String object.
    • isLicenseValid

      public boolean isLicenseValid()

      isLicenseValid.

      Returns:
      a boolean
    • namedLicenseExceeded

      private boolean namedLicenseExceeded()

      namedLicenseExceeded.

      Returns:
      a boolean
    • countLicensedMembers

      public long countLicensedMembers(SystemGroup licenseGroup)
      Counts the members of a license group, sub-groups included, that consume a license.
      Parameters:
      licenseGroup - the license group to count
      Returns:
      the number of members, special license users excluded
    • countUsersByLicense

      public Map<UserLicense,Long> countUsersByLicense(Collection<String> userNames)
      Counts the given users by the single license each of them consumes.
      Parameters:
      userNames - the users to count, typically the connected ones
      Returns:
      the number of users per license, licenses without any user omitted
    • isValid

      public static boolean isValid(String licenseKey, BeCPGLicense license)

      isValid.

      Parameters:
      licenseKey - a String object.
      license - a BeCPGLicense object.
      Returns:
      a boolean.
    • computeLicenseKey

      public static String computeLicenseKey(BeCPGLicense license)

      computeLicenseKey.

      Parameters:
      license - a BeCPGLicense object.
      Returns:
      a String object.
    • getLicenseFile

      private org.json.JSONObject getLicenseFile()

      getLicenseFile.

      Returns:
      a JSONObject object
    • isConcurrentUserAllowed

      public boolean isConcurrentUserAllowed()
      Tells whether the current user may connect, consuming a floating token when their license is a concurrent one. A user that also holds a named license never consumes a floating token.
      Returns:
      false when all the floating tokens of the user's license are taken
    • acquireConcurrentToken

      private boolean acquireConcurrentToken(String userName, UserLicense userLicense)
    • getAllowedConcurrent

      private long getAllowedConcurrent(UserLicense userLicense)
    • isSpecialLicenceUser

      public boolean isSpecialLicenceUser()

      isSpecialLicenceUser.

      Returns:
      a boolean
    • isSpecialLicenseUser

      public boolean isSpecialLicenseUser(String runAsUser)

      isSpecialLicenseUser.

      Parameters:
      runAsUser - a String object
      Returns:
      a boolean
    • getUserLicenseGroup

      public String getUserLicenseGroup(String username)

      getUserLicenseGroup.

      Parameters:
      username - a String object
      Returns:
      a String containing the license group key identifier
    • getUserLicense

      public UserLicense getUserLicense(String username)
      Returns the single license a user consumes, the named licenses taking priority over the concurrent ones.
      Parameters:
      username - the user name, may be null
      Returns:
      the license of the user, UserLicense.SPECIAL_USER for admins and beCPG accounts
    • hasWriteLicense

      public boolean hasWriteLicense()

      hasWriteLicense.

      Returns:
      a boolean