Go License Client
Importing the License Client
import (
"gitlab.com/l3178/sdk-go/license_client"
"gitlab.com/l3178/sdk-go/core/auth"
core_request "gitlab.com/l3178/sdk-go/core/models/request"
)Create LicenseClient
The following function uses the default CryptoProvider and DataLocation to encrypt, store, and decrypt the license file. You can implement your custom CryptoProvider and DataLocation the interface structure.
config := license_client.NewLicenseClientConfiguration("apiKey", "sharedKey", "productCode")
client := license_client.NewLicenseClient(config)Create Custom LicenseClient
Implement the CryptoProvider and DataLocation interfaces to create custom implementations for these components, and use them to configure the license client.
// implement the interface:
//type CryptoProvider interface {
// Encrypt(core_models.LicenseFile, string) (interface{}, error)
// Decrypt(interface{}, string) (interface{}, error)
//}
type CustomCryptoProvider struct{}
func (d CustomCryptoProvider) Encrypt(license_file core_models.LicenseFile, password string) (interface{}, error) {
// your custom implementation
}
func (d CustomCryptoProvider) Decrypt(data interface{}, password string) (interface{}, error) {
// your custom implementation
}
// implement the interface:
//type DataLocation interface {
// DataDirectory() (string, error)
// LicenseFileName(string) string
//}
type CustomDataLocation struct{}
func (d CustomDataLocation) DataDirectory() (string, error) {
// your custom implementation
}
func (d CustomDataLocation) LicenseFileName(productCode string) string {
// your custom implementation
}
config := license_client.NewLicenseClientConfigurationCustom(CustomCryptoProvider, CustomDataLocation, "apiKey", "sharedKey", "productCode")
client := license_client.NewLicenseClient(config)Activate Key-Based License
After activating the license, this function saves the license file in the location specified by the DataLocation object. The file is securely encrypted using the implementation provided by the CryptoProvider.
Activate User-Based License
After activating the license, this function saves the license file in the location specified by the DataLocation object. The file is securely encrypted using the implementation provided by the CryptoProvider.
Deactivate Key-Based License
Deactivate User-Based License
Check Key-Based License
Check User-Based License
Activate Offline License
After activating the license, this function saves the license file in the location specified by the DataLocation object. The file is securely encrypted using the implementation provided by the CryptoProvider.
Deactivate Offline License
Local License Check
This function reads the license file from local memory, validates it by performing checks such as expiration and hardware ID matching, and returns the license object along with the results of these checks.
Local license check returns an object of the following type:
Add Consumption
Add Feature Consumption
Trial Key
Product Details
Track Device Variables
Get Device Variables
Floating Borrow
Floating Release
Change Password
Versions
Installation File
Customer License Users
SSO URL
Air-Gap Initialization
Air-Gap Activation
Was this helpful?