Enum Class UserLicense

java.lang.Object
java.lang.Enum<UserLicense>
fr.becpg.repo.license.UserLicense
All Implemented Interfaces:
Serializable, Comparable<UserLicense>, Constable

public enum UserLicense extends Enum<UserLicense>
The single license a user consumes, whatever the number of license groups they belong to. The license groups are declared by priority: the first one the user belongs to wins.
Author:
valentin
  • Enum Constant Details

    • WRITE_NAMED

      public static final UserLicense WRITE_NAMED
    • WRITE_CONCURRENT

      public static final UserLicense WRITE_CONCURRENT
    • READ_NAMED

      public static final UserLicense READ_NAMED
    • READ_CONCURRENT

      public static final UserLicense READ_CONCURRENT
    • SUPPLIER_CONCURRENT

      public static final UserLicense SUPPLIER_CONCURRENT
    • SPECIAL_USER

      public static final UserLicense SPECIAL_USER
    • NO_LICENSE

      public static final UserLicense NO_LICENSE
  • Field Details

    • licenseGroup

      private final SystemGroup licenseGroup
    • concurrent

      private final boolean concurrent
    • key

      private final String key
  • Constructor Details

    • UserLicense

      private UserLicense(SystemGroup licenseGroup, boolean concurrent, String key)
  • Method Details

    • values

      public static UserLicense[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static UserLicense valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • resolve

      public static UserLicense resolve(Set<String> userAuthorities)
      Resolves the license consumed by a user from all the authorities they belong to, sub-groups included.
      Parameters:
      userAuthorities - the authorities of the user, as returned by AuthorityService.getAuthoritiesForUser
      Returns:
      the license of highest priority, or NO_LICENSE when the user is in no license group
    • isGrantedBy

      private boolean isGrantedBy(Set<String> userAuthorities)
    • isConcurrent

      public boolean isConcurrent()
      Tells whether this license consumes a floating token while the user is connected.
      Returns:
      true for the concurrent licenses
    • getKey

      public String getKey()
      Returns the key displayed by the admin console for this license.
      Returns:
      the license key