unioffice/common/license/license.go

48 lines
17 KiB
Go
Raw Normal View History

2020-08-23 14:15:53 +00:00
//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
// Package license helps manage commercial licenses and check if they are valid for the version of unidoc used.
2020-08-31 22:58:25 +00:00
package license ;import (_fb "bytes";_ae "compress/gzip";_a "crypto";_aee "crypto/rand";_ag "crypto/rsa";_cf "crypto/sha256";_bf "crypto/sha512";_aeg "crypto/x509";_g "encoding/base64";_af "encoding/hex";_eb "encoding/json";_gc "encoding/pem";_bc "errors";_db "fmt";_cc "github.com/unidoc/unioffice/common";_e "io";_d "log";_b "regexp";_fe "strings";_c "time";);func _fg (_afd string ,_ab string ,_bfe string )(string ,error ){_gg :=_fe .Index (_bfe ,_afd );if _gg ==-1{return "",_db .Errorf ("\u0068\u0065a\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_abf :=_fe .Index (_bfe ,_ab );if _abf ==-1{return "",_db .Errorf ("\u0066\u006fo\u0074\u0065\u0072 \u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");};_ed :=_gg +len (_afd )+1;return _bfe [_ed :_abf -1],nil ;};
2020-08-23 14:15:53 +00:00
// LicenseKey represents a license key for UniOffice.
2020-08-31 22:58:25 +00:00
type LicenseKey struct{LicenseId string `json:"license_id"`;CustomerId string `json:"customer_id"`;CustomerName string `json:"customer_name"`;Tier string `json:"tier"`;CreatedAt _c .Time `json:"-"`;CreatedAtInt int64 `json:"created_at"`;ExpiresAt _c .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"`;};
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// 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 SetLegacyLicenseKey (s string )error {_efg :=_b .MustCompile ("\u005c\u0073");s =_efg .ReplaceAllString (s ,"");var _bab _e .Reader ;_bab =_fe .NewReader (s );_bab =_g .NewDecoder (_g .RawURLEncoding ,_bab );_bab ,_ad :=_ae .NewReader (_bab );if _ad !=nil {return _ad ;};_bea :=_eb .NewDecoder (_bab );_fa :=&LegacyLicense {};if _bdd :=_bea .Decode (_fa );_bdd !=nil {return _bdd ;};if _gd :=_fa .Verify (_be );_gd !=nil {return _bc .New ("\u006c\u0069\u0063en\u0073\u0065\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0069\u006e\u0020\u0065\u0072\u0072\u006f\u0072");};if _fa .Expiration .Before (_cc .ReleasedAt ){return _bc .New ("\u006ci\u0063e\u006e\u0073\u0065\u0020\u0065\u0078\u0070\u0069\u0072\u0065\u0064");};_efa :=_c .Now ().UTC ();_cga :=LicenseKey {};_cga .CreatedAt =_efa ;_cga .CustomerId ="\u004c\u0065\u0067\u0061\u0063\u0079";_cga .CustomerName =_fa .Name ;_cga .Tier =LicenseTierBusiness ;_cga .ExpiresAt =_fa .Expiration ;_cga .CreatorName ="\u0055\u006e\u0069\u0044\u006f\u0063\u0020\u0073\u0075p\u0070\u006f\u0072\u0074";_cga .CreatorEmail ="\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0040\u0075\u006e\u0069\u0064o\u0063\u002e\u0069\u006f";_cga .UniOffice =true ;_agb =&_cga ;return nil ;};func (_gce *LicenseKey )isExpired ()bool {return _gce .getExpiryDateToCompare ().After (_gce .ExpiresAt )};func _bg (_afe string ,_bce string )([]byte ,error ){_ebe :="\u000a\u002b\u000a";_dcd :="\u000d\u000a\u002b\r\u000a";_cgf :=_fe .Index (_bce ,_ebe );if _cgf ==-1{_cgf =_fe .Index (_bce ,_dcd );if _cgf ==-1{return nil ,_db .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u002c \u0073i\u0067n\u0061t\u0075\u0072\u0065\u0020\u0073\u0065\u0070\u0061\u0072\u0061\u0074\u006f\u0072");};};_df :=_bce [:_cgf ];_cbf :=_cgf +len (_ebe );_fbc :=_bce [_cbf :];if _df ==""||_fbc ==""{return nil ,_db .Errorf ("\u0069n\u0076\u0061l\u0069\u0064\u0020\u0069n\u0070\u0075\u0074,\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020or\u0069\u0067\u0069n\u0061\u006c \u006f\u0072\u0020\u0073\u0069\u0067n\u0061\u0074u\u0072\u0065");};_cge ,_gb :=_g .StdEncoding .DecodeString (_df );if _gb !=nil {return nil ,_db .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u006f\u0072\u0069\u0067\u0069\u006ea\u006c");};_dba ,_gb :=_g .StdEncoding .DecodeString (_fbc );if _gb !=nil {return nil ,_db .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0069\u006e\u0070\u0075\u0074\u0020\u0073\u0069\u0067\u006e\u0061\u0074\u0075\u0072\u0065");};_dge ,_ :=_gc .Decode ([]byte (_afe ));if _dge ==nil {return nil ,_db .Errorf ("\u0050\u0075\u0062\u004b\u0065\u0079\u0020\u0066\u0061\u0069\u006c\u0065\u0064");};_aff ,_gb :=_aeg .ParsePKIXPublicKey (_dge .Bytes );if _gb !=nil {return nil ,_gb ;};_bbd :=_aff .(*_ag .PublicKey );if _bbd ==nil {return nil ,_db .Errorf ("\u0050u\u0062\u004b\u0065\u0079\u0020\u0063\u006f\u006e\u0076\u0065\u0072s\u0069\u006f\u006e\u0020\u0066\u0061\u0069\u006c\u0065\u0064");};_eca :=_bf .New ();_eca .Write (_cge );_dbc :=_eca .Sum (nil );_gb =_ag .VerifyPKCS1v15 (_bbd ,_a .SHA512 ,_dbc ,_dba );if _gb !=nil {return nil ,_gb ;};return _cge ,nil ;};
// Verify verifies a license by checking the license content and signature
// against a public key.
func (_eaf LegacyLicense )Verify (pubKey *_ag .PublicKey )error {_gff :=_eaf ;_gff .Signature ="";_agd :=_fb .Buffer {};_efc :=_eb .NewEncoder (&_agd );if _fbg :=_efc .Encode (_gff );_fbg !=nil {return _fbg ;};_ga ,_cdb :=_af .DecodeString (_eaf .Signature );if _cdb !=nil {return _cdb ;};_dce :=_cf .Sum256 (_agd .Bytes ());_cdb =_ag .VerifyPKCS1v15 (pubKey ,_a .SHA256 ,_dce [:],_ga );return _cdb ;};
2020-08-23 14:15:53 +00:00
// IsLicensed returns true if the package is licensed.
2020-08-31 22:58:25 +00:00
func (_fc *LicenseKey )IsLicensed ()bool {return _fc .Tier !=LicenseTierUnlicensed };func _ce (_gf string )(LicenseKey ,error ){var _ecae LicenseKey ;_ea ,_gfa :=_fg (_bd ,_dg ,_gf );if _gfa !=nil {return _ecae ,_gfa ;};_da ,_gfa :=_bg (_bac ,_ea );if _gfa !=nil {return _ecae ,_gfa ;};_gfa =_eb .Unmarshal (_da ,&_ecae );if _gfa !=nil {return _ecae ,_gfa ;};_ecae .CreatedAt =_c .Unix (_ecae .CreatedAtInt ,0);_ecae .ExpiresAt =_c .Unix (_ecae .ExpiresAtInt ,0);return _ecae ,nil ;};func GetLicenseKey ()*LicenseKey {if _agb ==nil {return nil ;};_dd :=*_agb ;return &_dd ;};
2020-08-23 14:15:53 +00:00
// LegacyLicense holds the old-style unioffice license information.
2020-08-31 22:58:25 +00:00
type LegacyLicense struct{Name string ;Signature string `json:",omitempty"`;Expiration _c .Time ;LicenseType LegacyLicenseType ;};
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// TypeToString returns a string representation of the license type.
func (_fdcd *LicenseKey )TypeToString ()string {if _fdcd .Tier ==LicenseTierUnlicensed {return "\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";};if _fdcd .Tier ==LicenseTierCommunity {return "\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";};if _fdcd .Tier ==LicenseTierIndividual ||_fdcd .Tier =="\u0069\u006e\u0064i\u0065"{return "\u0043\u006f\u006dm\u0065\u0072\u0063\u0069a\u006c\u0020\u004c\u0069\u0063\u0065\u006es\u0065\u0020\u002d\u0020\u0049\u006e\u0064\u0069\u0076\u0069\u0064\u0075\u0061\u006c";};return "\u0043\u006fm\u006d\u0065\u0072\u0063\u0069\u0061\u006c\u0020\u004c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u002d\u0020\u0042\u0075\u0073\u0069ne\u0073\u0073";};var _ba =_c .Date (2010,1,1,0,0,0,0,_c .UTC );
2020-08-23 14:15:53 +00:00
// ToString returns a string representing the license information.
2020-08-31 22:58:25 +00:00
func (_bbb *LicenseKey )ToString ()string {_aa :=_db .Sprintf ("\u004ci\u0063e\u006e\u0073\u0065\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_bbb .LicenseId );_aa +=_db .Sprintf ("\u0043\u0075s\u0074\u006f\u006de\u0072\u0020\u0049\u0064\u003a\u0020\u0025\u0073\u000a",_bbb .CustomerId );_aa +=_db .Sprintf ("\u0043u\u0073t\u006f\u006d\u0065\u0072\u0020N\u0061\u006de\u003a\u0020\u0025\u0073\u000a",_bbb .CustomerName );_aa +=_db .Sprintf ("\u0054i\u0065\u0072\u003a\u0020\u0025\u0073\n",_bbb .Tier );_aa +=_db .Sprintf ("\u0043r\u0065a\u0074\u0065\u0064\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_cc .UtcTimeFormat (_bbb .CreatedAt ));_aa +=_db .Sprintf ("\u0045x\u0070i\u0072\u0065\u0073\u0020\u0041\u0074\u003a\u0020\u0025\u0073\u000a",_cc .UtcTimeFormat (_bbb .ExpiresAt ));_aa +=_db .Sprintf ("\u0043\u0072\u0065\u0061\u0074\u006f\u0072\u003a\u0020\u0025\u0073\u0020<\u0025\u0073\u003e\u000a",_bbb .CreatorName ,_bbb .CreatorEmail );return _aa ;};const _dgc ="\u0033\u0030\u0035\u0063\u0033\u0030\u0030\u00640\u0036\u0030\u0039\u0032\u0061\u0038\u00364\u0038\u0038\u0036\u0066\u0037\u0030d\u0030\u0031\u0030\u0031\u0030\u00310\u0035\u0030\u0030\u0030\u0033\u0034\u0062\u0030\u0030\u0033\u0030\u00348\u0030\u0032\u0034\u0031\u0030\u0030\u0062\u0038\u0037\u0065\u0061\u0066\u0062\u0036\u0063\u0030\u0037\u0034\u0039\u0039\u0065\u0062\u00397\u0063\u0063\u0039\u0064\u0033\u0035\u0036\u0035\u0065\u0063\u00663\u0031\u0036\u0038\u0031\u0039\u0036\u0033\u0030\u0031\u0039\u0030\u0037c\u0038\u0034\u0031\u0061\u0064\u0064c6\u0036\u0035\u0030\u0038\u0036\u0062\u0062\u0033\u0065\u0064\u0038\u0065\u0062\u0031\u0032\u0064\u0039\u0064\u0061\u0032\u0036\u0063\u0061\u0066\u0061\u0039\u0036\u00345\u0030\u00314\u0036\u0064\u0061\u0038\u0062\u0064\u0030\u0063c\u0066\u0031\u0035\u0035\u0066\u0063a\u0063\u0063\u00368\u0036\u0039\u0035\u0035\u0065\u0066\u0030\u0033\u0030\u0032\u0066\u0061\u0034\u0034\u0061\u0061\u0033\u0065\u0063\u0038\u0039\u0034\u0031\u0037\u0062\u0030\u0032\u0030\u0033\u0030\u0031\u0030\u0030\u0030\u0031";
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// Validate returns an error if the licenseis invalid, nil otherwise.
func (_ac *LicenseKey )Validate ()error {if len (_ac .LicenseId )< 10{return _db .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064 \u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020L\u0069\u0063\u0065n\u0073e\u0020\u0049\u0064");};if len (_ac .CustomerId )< 10{return _db .Errorf ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065:\u0020C\u0075\u0073\u0074\u006f\u006d\u0065\u0072 \u0049\u0064");};if len (_ac .CustomerName )< 1{return _db .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069c\u0065\u006e\u0073\u0065\u003a\u0020\u0043u\u0073\u0074\u006f\u006d\u0065\u0072\u0020\u004e\u0061\u006d\u0065");};if _ba .After (_ac .CreatedAt ){return _db .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0043\u0072\u0065\u0061\u0074\u0065\u0064 \u0041\u0074\u0020\u0069\u0073 \u0069\u006ev\u0061\u006c\u0069\u0064");};if _ac .CreatedAt .After (_ac .ExpiresAt ){return _db .Errorf ("i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0043\u0072\u0065\u0061\u0074\u0065\u0064\u0020\u0041\u0074 \u0063a\u006e\u006e\u006f\u0074 \u0062\u0065 \u0047\u0072\u0065\u0061\u0074\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0045\u0078\u0070\u0069\u0072\u0065\u0073\u0020\u0041\u0074");};if _ac .isExpired (){return _db .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020l\u0069\u0063\u0065ns\u0065\u003a\u0020\u0054\u0068\u0065 \u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0020\u0068\u0061\u0073\u0020\u0061\u006c\u0072e\u0061\u0064\u0079\u0020\u0065\u0078\u0070\u0069r\u0065\u0064");};if len (_ac .CreatorName )< 1{return _db .Errorf ("\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0043\u0072\u0065\u0061\u0074\u006f\u0072\u0020na\u006d\u0065");};if len (_ac .CreatorEmail )< 1{return _db .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069c\u0065\u006e\u0073\u0065\u003a\u0020\u0043r\u0065\u0061\u0074\u006f\u0072\u0020\u0065\u006d\u0061\u0069\u006c");};if !_ac .UniOffice {return _db .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u003a\u0020\u0054\u0068\u0069s\u0020\u0055\u006e\u0069\u0044\u006f\u0063\u0020\u006be\u0079\u0020\u0069\u0073\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020f\u006f\u0072\u0020\u0055\u006e\u0069O\u0066\u0066\u0069c\u0065\u002e");};return nil ;};const (_bd ="\u002d\u002d\u002d--\u0042\u0045\u0047\u0049\u004e\u0020\u0055\u004e\u0049D\u004fC\u0020L\u0049C\u0045\u004e\u0053\u0045\u0020\u004b\u0045\u0059\u002d\u002d\u002d\u002d\u002d";_dg ="\u002d\u002d\u002d\u002d\u002d\u0045\u004e\u0044\u0020\u0055\u004e\u0049\u0044\u004f\u0043 \u004cI\u0043\u0045\u004e\u0053\u0045\u0020\u004b\u0045\u0059\u002d\u002d\u002d\u002d\u002d";);
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// LegacyLicenseType is the type of license
type LegacyLicenseType byte ;const _bac ="\u000a\u002d\u002d\u002d\u002d\u002d\u0042\u0045\u0047\u0049\u004e \u0050\u0055\u0042\u004c\u0049\u0043\u0020\u004b\u0045Y\u002d\u002d\u002d\u002d\u002d\u000a\u004d\u0049I\u0042\u0049\u006a\u0041NB\u0067\u006b\u0071\u0068\u006b\u0069G\u0039\u0077\u0030\u0042\u0041\u0051\u0045\u0046A\u0041\u004f\u0043\u0041\u0051\u0038\u0041\u004d\u0049\u0049\u0042\u0043\u0067\u004b\u0043\u0041\u0051\u0045A\u006dF\u0055\u0069\u0079\u0064\u0037\u0062\u0035\u0058\u006a\u0070\u006b\u0050\u0035\u0052\u0061\u0070\u0034\u0077\u000a\u0044\u0063\u0031d\u0079\u007a\u0049\u0051\u0034\u004c\u0065\u006b\u0078\u0072\u0076\u0079\u0074\u006e\u0045\u004d\u0070\u004e\u0055\u0062\u006f\u0036i\u0041\u0037\u0034\u0056\u0038\u0072\u0075\u005a\u004f\u0076\u0072\u0053\u0063\u0073\u0066\u0032\u0051\u0065\u004e9\u002f\u0071r\u0055\u0047\u0038\u0071\u0045\u0062\u0055\u0057\u0064\u006f\u0045\u0059\u0071+\u000a\u006f\u0074\u0046\u004e\u0041\u0046N\u0078\u006c\u0047\u0062\u0078\u0062\u0044\u0048\u0063\u0064\u0047\u0056\u0061\u004d\u0030\u004f\u0058\u0064\u0058g\u0044y\u004c5\u0061\u0049\u0045\u0061\u0067\u004c\u0030\u0063\u0035\u0070\u0077\u006a\u0049\u0064\u0050G\u0049\u006e\u0034\u0036\u0066\u0037\u0038\u0065\u004d\u004a\u002b\u004a\u006b\u0064\u0063\u0070\u0044\n\u0044\u004a\u0061\u0071\u0059\u0058d\u0072\u007a5\u004b\u0065\u0073\u0068\u006aS\u0069\u0049\u0061\u0061\u0037\u006d\u0065\u006e\u0042\u0049\u0041\u0058\u0053\u0034\u0055\u0046\u0078N\u0066H\u0068\u004e\u0030\u0048\u0043\u0059\u005a\u0059\u0071\u0051\u0047\u0037\u0062K+\u0073\u0035\u0072R\u0048\u006f\u006e\u0079\u0064\u004eW\u0045\u0047\u000a\u0048\u0038M\u0079\u0076\u00722\u0070\u0079\u0061\u0032K\u0072\u004d\u0075m\u0066\u006d\u0041\u0078\u0055\u0042\u0036\u0066\u0065\u006e\u0043\u002f4\u004f\u0030\u0057\u00728\u0067\u0066\u0050\u004f\u0055\u0038R\u0069\u0074\u006d\u0062\u0044\u0076\u0051\u0050\u0049\u0052\u0058\u004fL\u0034\u0076\u0054B\u0072\u0042\u0064\u0062a\u0041\u000a9\u006e\u0077\u004e\u0050\u002b\u0069\u002f\u002f\u0032\u0030\u004d\u00542\u0062\u0078\u006d\u0065\u0057\u0042\u002b\u0067\u0070\u0063\u0045\u0068G\u0070\u0058\u005a7\u0033\u0033\u0061\u007a\u0051\u0078\u0072\u0043\u0033\u004a\u0034\u0076\u0033C\u005a\u006d\u0045\u004eS\u0074\u0044\u004b\u002f\u004b\u0044\u0053\u0050\u004b\u0055\u0047\u0066\u00756\u000a\u0066\u0077I\u0044\u0041\u0051\u0041\u0042\u000a\u002d\u002d\u002d\u002d\u002dE\u004e\u0044\u0020\u0050\u0055\u0042\u004c\u0049\u0043 \u004b\u0045Y\u002d\u002d\u002d\u002d\u002d\n";func init (){_afa ,_fce :=_af .DecodeString (_dgc );if _fce !=nil {_d .Fatalf ("e\u0072\u0072\u006f\u0072 r\u0065a\u0064\u0069\u006e\u0067\u0020k\u0065\u0079\u003a\u0020\u0025\u0073",_fce );};_ca ,_fce :=_aeg .ParsePKIXPublicKey (_afa );if _fce !=nil {_d .Fatalf ("e\u0072\u0072\u006f\u0072 r\u0065a\u0064\u0069\u006e\u0067\u0020k\u0065\u0079\u003a\u0020\u0025\u0073",_fce );};_be =_ca .(*_ag .PublicKey );};func (_cef *LicenseKey )getExpiryDateToCompare ()_c .Time {if _cef .Trial {return _c .Now ().UTC ();};return _cc .ReleasedAt ;};func _fd (_cd string ,_cb []byte )(string ,error ){_fdc ,_ :=_gc .Decode ([]byte (_cd ));if _fdc ==nil {return "",_db .Errorf ("\u0050\u0072\u0069\u0076\u004b\u0065\u0079\u0020\u0066a\u0069\u006c\u0065\u0064");};_bb ,_cg :=_aeg .ParsePKCS1PrivateKey (_fdc .Bytes );if _cg !=nil {return "",_cg ;};_ebb :=_bf .New ();_ebb .Write (_cb );_ecb :=_ebb .Sum (nil );_afc ,_cg :=_ag .SignPKCS1v15 (_aee .Reader ,_bb ,_a .SHA512 ,_ecb );if _cg !=nil {return "",_cg ;};_dc :=_g .StdEncoding .EncodeToString (_cb );_dc +="\u000a\u002b\u000a";_dc +=_g .StdEncoding .EncodeToString (_afc );return _dc ,nil ;};var _agb =MakeUnlicensedKey ();var _be *_ag .PublicKey ;const (LicenseTierUnlicensed ="\u0075\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";LicenseTierCommunity ="\u0063o\u006d\u006d\u0075\u006e\u0069\u0074y";LicenseTierIndividual ="\u0069\u006e\u0064\u0069\u0076\u0069\u0064\u0075\u0061\u006c";LicenseTierBusiness ="\u0062\u0075\u0073\u0069\u006e\u0065\u0073\u0073";);
2020-08-23 14:15:53 +00:00
// SetLicenseKey sets and validates the license key.
2020-08-31 22:58:25 +00:00
func SetLicenseKey (content string ,customerName string )error {_aaa ,_aeb :=_ce (content );if _aeb !=nil {return _aeb ;};if _fe .ToLower (_aaa .CustomerName )!=_fe .ToLower (customerName ){return _db .Errorf ("\u0063\u0075\u0073\u0074\u006fm\u0065\u0072\u0020\u006e\u0061\u006d\u0065\u0020\u006d\u0069\u0073\u006d\u0061t\u0063\u0068\u002c\u0020\u0065\u0078\u0070\u0065\u0063\u0074\u0065\u0064\u0020\u0027\u0025\u0073\u0027\u002c\u0020\u0062\u0075\u0074\u0020\u0067\u006f\u0074\u0020\u0027\u0025\u0073'",customerName ,_aaa .CustomerName );};_aeb =_aaa .Validate ();if _aeb !=nil {return _aeb ;};_agb =&_aaa ;return nil ;};
2020-08-23 14:15:53 +00:00
2020-08-31 22:58:25 +00:00
// MakeUnlicensedKey returns an unlicensed key.
func MakeUnlicensedKey ()*LicenseKey {_fef :=LicenseKey {};_fef .CustomerName ="\u0055\u006e\u006c\u0069\u0063\u0065\u006e\u0073\u0065\u0064";_fef .Tier =LicenseTierUnlicensed ;_fef .CreatedAt =_c .Now ().UTC ();_fef .CreatedAtInt =_fef .CreatedAt .Unix ();return &_fef ;};