Package license

Overview ▾

Package license helps manage commercial licenses and check if they are valid for the version of unidoc used.


License tiers.

const (
    LicenseTierUnlicensed = "unlicensed"
    LicenseTierCommunity  = "community"
    LicenseTierIndividual = "individual"
    LicenseTierBusiness   = "business"

func SetLegacyLicenseKey

func SetLegacyLicenseKey(s string) error

SetLegacyLicenseKey installs a legacy license code. License codes issued prior to June 2019. Will be removed at some point in a future major version.

func SetLicenseKey

func SetLicenseKey(content string, customerName string) error

SetLicenseKey sets and validates the license key.

type LegacyLicense

LegacyLicense holds the old-style unioffice license information.

type LegacyLicense struct {
    Name        string
    Signature   string `json:",omitempty"`
    Expiration  time.Time
    LicenseType LegacyLicenseType

func (LegacyLicense) Verify

func (l LegacyLicense) Verify(pubKey *rsa.PublicKey) error

Verify verifies a license by checking the license content and signature against a public key.

type LegacyLicenseType

LegacyLicenseType is the type of license

type LegacyLicenseType byte

type LicenseKey

LicenseKey represents a license key for UniOffice.

type LicenseKey struct {
    LicenseId    string    `json:"license_id"`
    CustomerId   string    `json:"customer_id"`
    CustomerName string    `json:"customer_name"`
    Tier         string    `json:"tier"`
    CreatedAt    time.Time `json:"-"`
    CreatedAtInt int64     `json:"created_at"`
    ExpiresAt    time.Time `json:"-"`
    ExpiresAtInt int64     `json:"expires_at"`
    CreatorName  string    `json:"creator_name"`
    CreatorEmail string    `json:"creator_email"`
    UniPDF       bool      `json:"unipdf"`
    UniOffice    bool      `json:"unioffice"`
    Trial        bool      `json:"trial"` // For trial licenses.

func GetLicenseKey

func GetLicenseKey() *LicenseKey

func MakeUnlicensedKey

func MakeUnlicensedKey() *LicenseKey

MakeUnlicensedKey returns an unlicensed key.

func (*LicenseKey) IsLicensed

func (k *LicenseKey) IsLicensed() bool

IsLicensed returns true if the package is licensed.

func (*LicenseKey) ToString

func (k *LicenseKey) ToString() string

ToString returns a string representing the license information.

func (*LicenseKey) TypeToString

func (k *LicenseKey) TypeToString() string

TypeToString returns a string representation of the license type.

func (*LicenseKey) Validate

func (k *LicenseKey) Validate() error

Validate returns an error if the licenseis invalid, nil otherwise.