-
Notifications
You must be signed in to change notification settings - Fork 4
/
lexactivator.go
1676 lines (1293 loc) · 50.6 KB
/
lexactivator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2023 Cryptlex, LLC. All rights reserved.
package lexactivator
/*
#cgo linux,!arm64 LDFLAGS: -Wl,-Bstatic -L${SRCDIR}/libs/linux_amd64 -lLexActivator -Wl,-Bdynamic -lm -lstdc++ -lpthread
#cgo linux,arm64 LDFLAGS: -Wl,-Bstatic -L${SRCDIR}/libs/linux_arm64 -lLexActivator -Wl,-Bdynamic -lm -lstdc++ -lpthread
#cgo darwin LDFLAGS: -L${SRCDIR}/libs/darwin_amd64 -lLexActivator -lc++ -framework CoreFoundation -framework SystemConfiguration -framework Security
#cgo windows LDFLAGS: -L${SRCDIR}/libs/windows_amd64 -lLexActivator
#include "lexactivator/LexActivator.h"
#include <stdlib.h>
void licenseCallbackCgoGateway(int status);
void releaseUpdateCallbackCgoGateway(int status);
#ifdef _WIN32
void newReleaseUpdateCallbackCgoGateway(int status, unsigned short* releaseJson, void* unused);
#else
void newReleaseUpdateCallbackCgoGateway(int status, const char* releaseJson, void* unused);
#endif
*/
import "C"
import (
"encoding/json"
"strings"
"unsafe"
)
type callbackType func(int)
type releaseCallbackType func(int, *Release, interface{})
const (
LA_USER uint = 1
LA_SYSTEM uint = 2
LA_ALL_USERS uint = 3
LA_IN_MEMORY uint = 4
)
const (
LA_RELEASES_ALL uint = 1
LA_RELEASES_ALLOWED uint = 2
)
var licenseCallbackFuncion callbackType
var legacyReleaseCallbackFunction callbackType
var releaseCallbackFunction releaseCallbackType
var releaseCallbackFunctionUserData interface {}
//export licenseCallbackWrapper
func licenseCallbackWrapper(status int) {
if licenseCallbackFuncion != nil {
licenseCallbackFuncion(status)
}
}
//export releaseUpdateCallbackWrapper
func releaseUpdateCallbackWrapper(status int) {
if legacyReleaseCallbackFunction != nil {
legacyReleaseCallbackFunction(status)
}
}
/*
FUNCTION: SetProductFile()
PURPOSE: Sets the absolute path of the Product.dat file.
This function must be called on every start of your program
before any other functions are called.
PARAMETERS:
* filePath - absolute path of the product file (Product.dat)
RETURN CODES: LA_OK, LA_E_FILE_PATH, LA_E_PRODUCT_FILE
NOTE: If this function fails to set the path of product file, none of the
other functions will work.
*/
func SetProductFile(filePath string) int {
cFilePath := goToCString(filePath)
status := C.SetProductFile(cFilePath)
freeCString(cFilePath)
return int(status)
}
/*
FUNCTION: SetProductData()
PURPOSE: Embeds the Product.dat file in the application.
It can be used instead of SetProductFile() in case you want
to embed the Product.dat file in your application.
This function must be called on every start of your program
before any other functions are called.
PARAMETERS:
* productData - content of the Product.dat file
RETURN CODES: LA_OK, LA_E_PRODUCT_DATA
NOTE: If this function fails to set the product data, none of the
other functions will work.
*/
func SetProductData(productData string) int {
cProductData := goToCString(productData)
status := C.SetProductData(cProductData)
freeCString(cProductData)
return int(status)
}
/*
FUNCTION: SetProductId()
PURPOSE: Sets the product id of your application.
This function must be called on every start of your program before
any other functions are called, with the exception of SetProductFile()
or SetProductData() function.
PARAMETERS:
* productId - the unique product id of your application as mentioned
on the product page in the dashboard.
* flags - depending on your application's requirements, choose one of
the following values: LA_USER, LA_SYSTEM, LA_IN_MEMORY, LA_ALL_USERS.
LA_USER: This flag indicates that the application does not require
admin or root permissions to run.
LA_SYSTEM: This flag indicates that the application must be run with admin or
root permissions.
LA_IN_MEMORY: This flag will store activation data in memory. Thus, requires
re-activation on every start of the application and should only be used in floating
licenses.
LA_ALL_USERS: This flag is specifically designed for Windows and should be used
for system-wide activations.
RETURN CODES: LA_OK, LA_E_WMIC, LA_E_PRODUCT_FILE, LA_E_PRODUCT_DATA, LA_E_PRODUCT_ID,
LA_E_SYSTEM_PERMISSION
NOTE: If this function fails to set the product id, none of the other
functions will work.
*/
func SetProductId(productId string, flags uint) int {
cProductId := goToCString(productId)
cFlags := (C.uint)(flags)
status := C.SetProductId(cProductId, cFlags)
freeCString(cProductId)
return int(status)
}
/*
FUNCTION: SetDataDirectory()
PURPOSE: In case you want to change the default directory used by LexActivator to
store the activation data on Linux and macOS, this function can be used to
set a different directory.
If you decide to use this function, then it must be called on every start of
your program before calling SetProductFile() or SetProductData() function.
Please ensure that the directory exists and your app has read and write
permissions in the directory.
PARAMETERS:
* directoryPath - absolute path of the directory.
RETURN CODES: LA_OK, LA_E_FILE_PERMISSION
*/
func SetDataDirectory(directoryPath string) int {
cDirectoryPath := goToCString(directoryPath)
status := C.SetDataDirectory(cDirectoryPath)
freeCString(cDirectoryPath)
return int(status)
}
/*
FUNCTION: SetDebugMode()
PURPOSE: Enables network logs.
This function should be used for network testing only in case of network errors.
By default logging is disabled.
This function generates the lexactivator-logs.log file in the same directory
where the application is running.
PARAMETERS :
*enable - 0 or 1 to disable or enable logging.
RETURN CODES : LA_OK
*/
func SetDebugMode(enable uint) int {
cEnable := (C.uint)(enable)
status := C.SetDebugMode(cEnable)
return int(status)
}
/*
FUNCTION: SetCacheMode()
PURPOSE: Enables or disables in-memory caching for LexActivator.
This function is designed to control caching
behavior to suit specific application requirements. Caching is enabled by default to enhance performance.
Disabling caching is recommended in environments where multiple processes access the same license on a
single machine and require real-time updates to the license state.
PARAMETERS :
* enable - false or true to disable or enable in-memory caching.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID
*/
func SetCacheMode(enable bool) int {
var cEnable C.uint
if enable {
cEnable = 1
} else {
cEnable = 0
}
status := C.SetCacheMode(cEnable)
return int(status)
}
/*
FUNCTION: SetCustomDeviceFingerprint()
PURPOSE: In case you don't want to use the LexActivator's advanced
device fingerprinting algorithm, this function can be used to set a custom
device fingerprint.
If you decide to use your own custom device fingerprint then this function must be
called on every start of your program immediately after calling SetProductFile()
or SetProductData() function.
The license fingerprint matching strategy is ignored if this function is used.
PARAMETERS:
* fingerprint - string of minimum length 64 characters and maximum length 256 characters.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_CUSTOM_FINGERPRINT_LENGTH
*/
func SetCustomDeviceFingerprint(fingerprint string) int {
cFingerprint := goToCString(fingerprint)
status := C.SetCustomDeviceFingerprint(cFingerprint)
freeCString(cFingerprint)
return int(status)
}
/*
FUNCTION: SetLicenseKey()
PURPOSE: Sets the license key required to activate the license.
PARAMETERS:
* licenseKey - a valid license key.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY
*/
func SetLicenseKey(licenseKey string) int {
cLicenseKey := goToCString(licenseKey)
status := C.SetLicenseKey(cLicenseKey)
freeCString(cLicenseKey)
return int(status)
}
/*
FUNCTION: SetLicenseUserCredential()
PURPOSE: Sets the license user email and password for authentication.
This function must be called before ActivateLicense() or IsLicenseGenuine()
function if 'requireAuthentication' property of the license is set to true.
PARAMETERS:
* email - user email address.
* password - user password.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY
*/
func SetLicenseUserCredential(email string, password string) int {
cEmail := goToCString(email)
cPassword := goToCString(password)
status := C.SetLicenseUserCredential(cEmail, cPassword)
freeCString(cEmail)
freeCString(cPassword)
return int(status)
}
/*
FUNCTION: SetLicenseCallback()
PURPOSE: Sets server sync callback function.
Whenever the server sync occurs in a separate thread, and server returns the response,
license callback function gets invoked with the following status codes:
LA_OK, LA_EXPIRED, LA_SUSPENDED,
LA_E_REVOKED, LA_E_ACTIVATION_NOT_FOUND, LA_E_MACHINE_FINGERPRINT
LA_E_AUTHENTICATION_FAILED, LA_E_COUNTRY, LA_E_INET, LA_E_SERVER,
LA_E_RATE_LIMIT, LA_E_IP
PARAMETERS:
* callback - name of the callback function
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY
*/
func SetLicenseCallback(callbackFunction func(int)) int {
status := C.SetLicenseCallback((C.CallbackType)(unsafe.Pointer(C.licenseCallbackCgoGateway)))
licenseCallbackFuncion = callbackFunction
return int(status)
}
/*
FUNCTION: SetActivationLeaseDuration()
PURPOSE: Sets the lease duration for the activation.
The activation lease duration is honoured when the allow client
lease duration property is enabled.
PARAMETERS:
* leaseDuration - value of the lease duration. A value of -1 indicates unlimited
lease duration.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY
*/
func SetActivationLeaseDuration(leaseDuration int64) int {
cLeaseDuration := (C.int64_t)(leaseDuration)
status := C.SetActivationLeaseDuration(cLeaseDuration)
return int(status)
}
/*
FUNCTION: SetActivationMetadata()
PURPOSE: Sets the activation metadata.
The metadata appears along with the activation details of the license
in dashboard.
PARAMETERS:
* key - string of maximum length 256 characters with utf-8 encoding.
* value - string of maximum length 4096 characters with utf-8 encoding.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_METADATA_KEY_LENGTH,
LA_E_METADATA_VALUE_LENGTH, LA_E_ACTIVATION_METADATA_LIMIT
*/
func SetActivationMetadata(key string, value string) int {
cKey := goToCString(key)
cValue := goToCString(value)
status := C.SetActivationMetadata(cKey, cValue)
freeCString(cKey)
freeCString(cValue)
return int(status)
}
/*
FUNCTION: SetTrialActivationMetadata()
PURPOSE: Sets the trial activation metadata.
The metadata appears along with the trial activation details of the product
in dashboard.
PARAMETERS:
* key - string of maximum length 256 characters with utf-8 encoding.
* value - string of maximum length 4096 characters with utf-8 encoding.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_METADATA_KEY_LENGTH,
LA_E_METADATA_VALUE_LENGTH, LA_E_TRIAL_ACTIVATION_METADATA_LIMIT
*/
func SetTrialActivationMetadata(key string, value string) int {
cKey := goToCString(key)
cValue := goToCString(value)
status := C.SetTrialActivationMetadata(cKey, cValue)
freeCString(cKey)
freeCString(cValue)
return int(status)
}
/*
FUNCTION: SetAppVersion()
PURPOSE: Sets the current app version of your application.
The app version appears along with the activation details in dashboard. It
is also used to generate app analytics.
PARAMETERS:
* appVersion - string of maximum length 256 characters with utf-8 encoding.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_APP_VERSION_LENGTH
*/
func SetAppVersion(appVersion string) int {
cAppVersion := goToCString(appVersion)
status := C.SetAppVersion(cAppVersion)
freeCString(cAppVersion)
return int(status)
}
/*
FUNCTION: SetReleaseVersion()
PURPOSE: Sets the current release version of your application.
The release version appears along with the activation details in dashboard.
PARAMETERS:
* releaseVersion - string in following allowed formats: x.x, x.x.x, x.x.x.x
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_RELEASE_VERSION_FORMAT
*/
func SetReleaseVersion(releaseVersion string) int {
cReleaseVersion := goToCString(releaseVersion)
status := C.SetReleaseVersion(cReleaseVersion)
freeCString(cReleaseVersion)
return int(status)
}
/*
FUNCTION: SetReleasePublishedDate()
PURPOSE: Sets the release published date of your application.
PARAMETERS:
* releasePublishedDate - unix timestamp of release published date.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID
*/
func SetReleasePublishedDate(releasePublishedDate uint) int {
cReleasePublishedDate := (C.uint)(releasePublishedDate)
status := C.SetReleasePublishedDate(cReleasePublishedDate)
return int(status)
}
/*
FUNCTION: SetReleasePlatform()
PURPOSE: Sets the release platform e.g. windows, macos, linux
The release platform appears along with the activation details in dashboard.
PARAMETERS:
* releasePlatform - release platform e.g. windows, macos, linux
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_RELEASE_PLATFORM_LENGTH
*/
func SetReleasePlatform(releasePlatform string) int {
cReleasePlatform := goToCString(releasePlatform)
status := C.SetReleasePlatform(cReleasePlatform)
freeCString(cReleasePlatform)
return int(status)
}
/*
FUNCTION: SetReleaseChannel()
PURPOSE: Sets the release channel e.g. stable, beta
The release channel appears along with the activation details in dashboard.
PARAMETERS:
* channel - release channel e.g. stable
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_RELEASE_CHANNEL_LENGTH
*/
func SetReleaseChannel(releaseChannel string) int {
cReleaseChannel := goToCString(releaseChannel)
status := C.SetReleaseChannel(cReleaseChannel)
freeCString(cReleaseChannel)
return int(status)
}
/*
FUNCTION: SetOfflineActivationRequestMeterAttributeUses()
PURPOSE: Sets the meter attribute uses for the offline activation request.
This function should only be called before GenerateOfflineActivationRequest()
function to set the meter attributes in case of offline activation.
PARAMETERS:
* name - name of the meter attribute
* uses - the uses value
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY
*/
func SetOfflineActivationRequestMeterAttributeUses(name string, uses uint) int {
cName := goToCString(name)
cUses := (C.uint)(uses)
status := C.SetOfflineActivationRequestMeterAttributeUses(cName, cUses)
freeCString(cName)
return int(status)
}
/*
FUNCTION: SetNetworkProxy()
PURPOSE: Sets the network proxy to be used when contacting Cryptlex servers.
The proxy format should be: [protocol://][username:password@]machine[:port]
Following are some examples of the valid proxy strings:
- http://127.0.0.1:8000/
- http://user:pass@127.0.0.1:8000/
- socks5://127.0.0.1:8000/
PARAMETERS:
* proxy - proxy string having correct proxy format
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_NET_PROXY
NOTE: Proxy settings of the computer are automatically detected. So, in most of the
cases you don't need to care whether your user is behind a proxy server or not.
*/
func SetNetworkProxy(proxy string) int {
cProxy := goToCString(proxy)
status := C.SetNetworkProxy(cProxy)
freeCString(cProxy)
return int(status)
}
/*
FUNCTION: SetCryptlexHost()
PURPOSE: In case you are running Cryptlex on-premise, you can set the
host for your on-premise server.
PARAMETERS:
* host - the address of the Cryptlex on-premise server
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_HOST_URL
*/
func SetCryptlexHost(host string) int {
cHost := goToCString(host)
status := C.SetCryptlexHost(cHost)
freeCString(cHost)
return int(status)
}
/*
FUNCTION: SetTwoFactorAuthenticationCode()
PURPOSE: Sets the two-factor authentication code for the user authentication.
PARAMETERS:
* twoFactorAuthenticationCode - the 2FA code
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_TWO_FACTOR_AUTHENTICATION_CODE_INVALID
*/
func SetTwoFactorAuthenticationCode(twoFactorAuthenticationCode string) int {
cTwoFactorAuthenticationCode := goToCString(twoFactorAuthenticationCode)
status := C.SetTwoFactorAuthenticationCode(cTwoFactorAuthenticationCode)
freeCString(cTwoFactorAuthenticationCode)
return int(status)
}
/*
FUNCTION: GetProductMetadata()
PURPOSE: Gets the product metadata as set in the dashboard.
This is available for trial as well as license activations.
PARAMETERS:
* key - metadata key to retrieve the value
* value - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_METADATA_KEY_NOT_FOUND, LA_E_BUFFER_SIZE
*/
func GetProductMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetProductMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)
}
/*
FUNCTION: GetProductVersionName()
PURPOSE: Gets the product version name.
PARAMETERS:
* name - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the name parameter
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_PRODUCT_VERSION_NOT_LINKED,
LA_E_BUFFER_SIZE
*/
func GetProductVersionName(name *string) int {
var cName = getCArray()
status := C.GetProductVersionName(&cName[0], maxCArrayLength)
*name = ctoGoString(&cName[0])
return int(status)
}
/*
FUNCTION: GetProductVersionDisplayName()
PURPOSE: Gets the product version display name.
PARAMETERS:
* displayName - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the displayName parameter
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_PRODUCT_VERSION_NOT_LINKED,
LA_E_BUFFER_SIZE
*/
func GetProductVersionDisplayName(displayName *string) int {
var cDisplayName = getCArray()
status := C.GetProductVersionDisplayName(&cDisplayName[0], maxCArrayLength)
*displayName = ctoGoString(&cDisplayName[0])
return int(status)
}
/*
FUNCTION: GetProductVersionFeatureFlag()
PURPOSE: Gets the product version feature flag.
PARAMETERS:
* name - name of the feature flag
* enabled - pointer to the integer that receives the value - 0 or 1
* data - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the data parameter
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_PRODUCT_VERSION_NOT_LINKED,
LA_E_FEATURE_FLAG_NOT_FOUND, LA_E_BUFFER_SIZE
*/
func GetProductVersionFeatureFlag(name string, enabled *bool, data *string) int {
cName := goToCString(name)
var cEnabled C.uint
var cData = getCArray()
status := C.GetProductVersionFeatureFlag(cName, &cEnabled, &cData[0], maxCArrayLength)
freeCString(cName)
*enabled = cEnabled > 0
*data = ctoGoString(&cData[0])
return int(status)
}
/*
FUNCTION: GetLicenseMetadata()
PURPOSE: Gets the license metadata as set in the dashboard.
PARAMETERS:
* key - metadata key to retrieve the value
* value - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_METADATA_KEY_NOT_FOUND, LA_E_BUFFER_SIZE
*/
func GetLicenseMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetLicenseMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)
}
/*
FUNCTION: GetLicenseMeterAttribute()
PURPOSE: Gets the license meter attribute allowed uses, total and gross uses.
PARAMETERS:
* name - name of the meter attribute
* allowedUses - pointer to the integer that receives the value. A value of -1 indicates unlimited allowed uses.
* totalUses - pointer to the integer that receives the value
* grossUses - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_METER_ATTRIBUTE_NOT_FOUND
*/
func GetLicenseMeterAttribute(name string, allowedUses *int64, totalUses *uint64, grossUses *uint64) int {
cName := goToCString(name)
var cAllowedUses C.int64_t
var cTotalUses C.uint64_t
var cGrossUses C.uint64_t
status := C.GetLicenseMeterAttribute(cName, &cAllowedUses, &cTotalUses, &cGrossUses)
*allowedUses = int64(cAllowedUses)
*totalUses = uint64(cTotalUses)
*grossUses = uint64(cGrossUses)
freeCString(cName)
return int(status)
}
/*
FUNCTION: GetLicenseKey()
PURPOSE: Gets the license key used for activation.
PARAMETERS:
* licenseKey - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_BUFFER_SIZE
*/
func GetLicenseKey(licenseKey *string) int {
var cLicenseKey = getCArray()
status := C.GetLicenseKey(&cLicenseKey[0], maxCArrayLength)
*licenseKey = ctoGoString(&cLicenseKey[0])
return int(status)
}
/*
FUNCTION: GetLicenseAllowedActivations()
PURPOSE: Gets the allowed activations of the license.
PARAMETERS:
* allowedActivations - pointer to the integer that receives the value.
A value of -1 indicates unlimited number of activations.
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseAllowedActivations(allowedActivations *int64) int {
var cAllowedActivations C.int64_t
status := C.GetLicenseAllowedActivations(&cAllowedActivations)
*allowedActivations = int64(cAllowedActivations)
return int(status)
}
/*
FUNCTION: GetLicenseTotalActivations()
PURPOSE: Gets the total activations of the license.
PARAMETERS:
* totalActivations - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseTotalActivations(totalActivations *uint) int {
var cTotalActivations C.uint
status := C.GetLicenseTotalActivations(&cTotalActivations)
*totalActivations = uint(cTotalActivations)
return int(status)
}
/*
FUNCTION: GetLicenseAllowedDeactivations()
PURPOSE: Gets the allowed deactivations of the license.
PARAMETERS:
* allowedDeactivations - pointer to the integer that receives the value.
A value of -1 indicates unlimited number of deactivations.
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseAllowedDeactivations(allowedDeactivations *int64) int {
var cAllowedDeactivations C.int64_t
status := C.GetLicenseAllowedDeactivations(&cAllowedDeactivations)
*allowedDeactivations = int64(cAllowedDeactivations)
return int(status)
}
/*
FUNCTION: GetLicenseTotalDeactivations()
PURPOSE: Gets the total deactivations of the license.
PARAMETERS:
* totalDeactivations - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseTotalDeactivations(totalDeactivations *uint) int {
var cTotalDeactivations C.uint
status := C.GetLicenseTotalDeactivations(&cTotalDeactivations)
*totalDeactivations = uint(cTotalDeactivations)
return int(status)
}
/*
FUNCTION: GetLicenseCreationDate()
PURPOSE: Gets the license creation date timestamp.
PARAMETERS:
* creationDate - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseCreationDate(creationDate *uint) int {
var cCreationDate C.uint
status := C.GetLicenseCreationDate(&cCreationDate)
*creationDate = uint(cCreationDate)
return int(status)
}
/*
FUNCTION: GetLicenseActivationDate()
PURPOSE: Gets the activation creation date timestamp.
PARAMETERS:
* activationDate - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseActivationDate(activationDate *uint) int {
var cActivationDate C.uint
status := C.GetLicenseActivationDate(&cActivationDate)
*activationDate = uint(cActivationDate)
return int(status)
}
/*
FUNCTION: GetLicenseExpiryDate()
PURPOSE: Gets the license expiry date timestamp.
PARAMETERS:
* expiryDate - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseExpiryDate(expiryDate *uint) int {
var cExpiryDate C.uint
status := C.GetLicenseExpiryDate(&cExpiryDate)
*expiryDate = uint(cExpiryDate)
return int(status)
}
/*
FUNCTION: GetLicenseMaintenanceExpiryDate()
PURPOSE: Gets the license maintenance expiry date timestamp.
PARAMETERS:
* maintenanceExpiryDate - pointer to the integer that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED
*/
func GetLicenseMaintenanceExpiryDate(maintenanceExpiryDate *uint) int {
var cMaintenanceExpiryDate C.uint
status := C.GetLicenseMaintenanceExpiryDate(&cMaintenanceExpiryDate)
*maintenanceExpiryDate = uint(cMaintenanceExpiryDate)
return int(status)
}
/*
FUNCTION: GetLicenseMaxAllowedReleaseVersion()
PURPOSE: Gets the maximum allowed release version of the license.
PARAMETERS:
* maxAllowedReleaseVersion - pointer to a buffer that receives the value of the string.
* length - size of the buffer pointed to by the maxAllowedReleaseVersion parameter.
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_BUFFER_SIZE
*/
func GetLicenseMaxAllowedReleaseVersion(maxAllowedReleaseVersion *string) int {
var cMaxAllowedReleaseVersion = getCArray()
status := C.GetLicenseMaxAllowedReleaseVersion(&cMaxAllowedReleaseVersion[0], maxCArrayLength)
*maxAllowedReleaseVersion = ctoGoString(&cMaxAllowedReleaseVersion[0])
return int(status)
}
/*
FUNCTION: GetLicenseUserEmail()
PURPOSE: Gets the email associated with license user.
PARAMETERS:
* email - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE
*/
func GetLicenseUserEmail(email *string) int {
var cEmail = getCArray()
status := C.GetLicenseUserEmail(&cEmail[0], maxCArrayLength)
*email = ctoGoString(&cEmail[0])
return int(status)
}
/*
FUNCTION: GetLicenseUserName()
PURPOSE: Gets the name associated with the license user.
PARAMETERS:
* name - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE
*/
func GetLicenseUserName(name *string) int {
var cName = getCArray()
status := C.GetLicenseUserName(&cName[0], maxCArrayLength)
*name = ctoGoString(&cName[0])
return int(status)
}
/*
FUNCTION: GetLicenseUserCompany()
PURPOSE: Gets the company associated with the license user.
PARAMETERS:
* company - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE
*/
func GetLicenseUserCompany(company *string) int {
var cCompany = getCArray()
status := C.GetLicenseUserCompany(&cCompany[0], maxCArrayLength)
*company = ctoGoString(&cCompany[0])
return int(status)
}
/*
FUNCTION: GetLicenseUserMetadata()
PURPOSE: Gets the metadata associated with the license user.
PARAMETERS:
* key - metadata key to retrieve the value
* value - pointer to a string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_METADATA_KEY_NOT_FOUND, LA_E_BUFFER_SIZE
*/
func GetLicenseUserMetadata(key string, value *string) int {
cKey := goToCString(key)
var cValue = getCArray()
status := C.GetLicenseUserMetadata(cKey, &cValue[0], maxCArrayLength)
*value = ctoGoString(&cValue[0])
freeCString(cKey)
return int(status)
}
/*
FUNCTION: GetLicenseOrganizationName()
PURPOSE: Gets the organization name associated with the license.
PARAMETERS:
* organizationName - pointer to the string that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE
*/
func GetLicenseOrganizationName(organizationName *string) int {
var cOrganizationName = getCArray()
status := C.GetLicenseOrganizationName(&cOrganizationName[0], maxCArrayLength)
*organizationName = ctoGoString(&cOrganizationName[0])
return int(status)
}
/*
FUNCTION: GetLicenseOrganizationAddress()
PURPOSE: Gets the organization address associated with the license.
PARAMETERS:
* organizationAddress - pointer to the OrganizationAddress struct that receives the value
RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE
*/
func GetLicenseOrganizationAddress(organizationAddress *OrganizationAddress) int {
var cOrganizationAddress = getCArray()
organizationAddressJson := ""
status := C.GetLicenseOrganizationAddressInternal(&cOrganizationAddress[0], maxCArrayLength)
organizationAddressJson = strings.TrimRight(ctoGoString(&cOrganizationAddress[0]), "\x00")
if organizationAddressJson != "" {
address := []byte(organizationAddressJson)
json.Unmarshal(address, organizationAddress)
}
return int(status)
}
/*
FUNCTION: GetUserLicenses()
PURPOSE: Gets the user licenses for the product.
This function sends a network request to Cryptlex servers to get the licenses.
Make sure AuthenticateUser() function is called before calling this function.
PARAMETERS:
* userLicenses - pointer to the array of UserLicense struct that receives the values of the user's licenses.
RETURN CODES: LA_OK, LA_E_PRODUCT_ID, LA_E_INET, LA_E_SERVER, LA_E_RATE_LIMIT
LA_E_USER_NOT_AUTHENTICATED, LA_E_BUFFER_SIZE
*/