...
Documentation
Documentation

# Package license

## Overview ▹

## Overview ▾

## Index ▹

## Index ▾

### Package files

crypto.go key.go license_legacy.go metered.go pubkeys.go util.go

## Constants

License tiers.

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

## func GenRefId ¶

    func GenRefId(prefix string) (string, error)

## func SetLicenseKey ¶

    func SetLicenseKey(content string, customerName string) error

SetLicenseKey sets and validates the license key.

## func SetMeteredKey ¶

    func SetMeteredKey(apiKey string) error

SetMeteredKey sets the metered License API key required for SaaS operation. Document usage is reported periodically for the product to function correctly.

## func SetMeteredKeyPersistentCache ¶

    func SetMeteredKeyPersistentCache(val bool)

SetMeteredKeyPersistentCache sets the current License API Key persistent cache status.

## func SetMeteredKeyUsageLogVerboseMode ¶

    func SetMeteredKeyUsageLogVerboseMode(val bool)

SetMeteredKeyUsageLogVerboseMode sets the current License API Key usage log verbose mode.

## func Track ¶

    func Track(docKey string, useKey string, docName string) error

## func TrackUse ¶

    func TrackUse(useKey string)

## 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 loaded license key.

    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"`
        CreatedBy    string    `json:"created_by"`
        CreatorName  string    `json:"creator_name"`
        CreatorEmail string    `json:"creator_email"`
        UniPDF       bool      `json:"unipdf"`
        UniOffice    bool      `json:"unioffice"`
        UniHTML      bool      `json:"unihtml"`
        Trial        bool      `json:"trial"` // For trial licenses.
        // contains filtered or unexported fields
    }

### func GetLicenseKey ¶

    func GetLicenseKey() *LicenseKey

### func MakeUnlicensedKey ¶

    func MakeUnlicensedKey() *LicenseKey

MakeUnlicensedKey returns a default key.

### func (*LicenseKey) IsLicensed ¶

    func (k *LicenseKey) IsLicensed() bool

IsLicensed returns true if the k is licensed.

### func (*LicenseKey) ToString ¶

    func (k *LicenseKey) ToString() string

ToString returns a string summary of the license key.

### func (*LicenseKey) TypeToString ¶

    func (k *LicenseKey) TypeToString() string

TypeToString returns a readable string representing the license key type.

### func (*LicenseKey) Validate ¶

    func (k *LicenseKey) Validate() error

Validate returns nil if the license key is valid, otherwise an error is returned.

## type MeteredStatus ¶

MeteredStatus represents the current document usage state.

    type MeteredStatus struct {
        OK      bool
        Credits int64
        Used    int64
    }

### func GetMeteredState ¶

    func GetMeteredState() (MeteredStatus, error)

GetMeteredState checks the currently used metered document usage status, documents used and credits available. If there are documents not reported, it reports them first.