Class LocalSubscriptionKey

java.lang.Object
com.vaadin.pro.licensechecker.LocalSubscriptionKey

public final class LocalSubscriptionKey extends Object
Subscription key loader.

A subscription key can be provided in several ways, to fit different needs and environments. The priority order is Java system property, environment variable, file in Vaadin home folder.
  1. System property with vaadin.subscriptionKey key
  2. Environment variable named VAADIN_SUBSCRIPTION_KEY
  3. File named subscriptionKey placed in the $HOME/.vaadin folder
For consistency and backward compatibility, the vaadin.key system property and VAADIN_KEY environment variable ara also supported. In this case the key must start with the sub- prefix.
  • Constructor Details

    • LocalSubscriptionKey

      public LocalSubscriptionKey()
  • Method Details

    • get

      public static SubscriptionKey get()
      Gets the current subscription key, if found.

      A valid subscription key is searched in system properties, environment variables and filesystem. See class level Javadoc for details on how the key can be provided.
      Returns:
      the subscription key, or null if the key cannot be found.
    • fromString

      public static Optional<SubscriptionKey> fromString(String key)
      Creates a new SubscriptionKey based on the given string representation.
      Parameters:
      key - The string representation of the subscription.
      Returns:
      a SubscriptionKey, or an empty Optional if the given string does not represent a valid subscription key.
    • getOrFail

      public static SubscriptionKey getOrFail()
      Gets the current subscription key or throws an exception if not available.

      A valid subscription key is searched in system properties, environment variables and filesystem. See class level Javadoc for details on how the key can be provided.
      Returns:
      the subscription key.
      Throws:
      LicenseException - if the subscription key cannot be found.