LicenseSpring C++ SDK
Easily add Software Licensing to your application
Loading...
Searching...
No Matches
ExtendedOptions.h
Go to the documentation of this file.
1#ifndef LS_EXTENDED_OPTIONS_H
2#define LS_EXTENDED_OPTIONS_H
3
4#ifdef _MSC_VER
5#pragma once
6#pragma warning( push )
7#pragma warning( disable : 4251 )
8#endif
9
10#include <vector>
11#include "APIDef.h"
12#include "CryptoProvider.h"
13#include "PODTypes.h"
14
15namespace LicenseSpring
16{
20 {
21 public:
23 NetworkInfo() = default;
24
27
30 void setIp( const std::string& ip );
31
34 const std::string& ip() const;
35
38 void setMac( const std::string& mac );
39
42 const std::string& mac() const;
43
46 void setHostName( const std::string& hostName );
47
50 const std::string& hostName() const;
51
52 private:
53 std::string m_localIP;
54 std::string m_hostName;
55 std::string m_macAddress;
56 };
57
60 {
61 public:
62
64 ProxySettings() = default;
65
70 ProxySettings( const std::string& proxy, const std::string& user, const std::string& password );
71
74
85 bool fetchProxySettings( const std::string& serviceURL, const std::string& credentialTarget, bool throwExceptions = false );
86
89 void setProxyUri( const std::string& uri );
90
93 const std::string& getProxyUri() const;
94
97 void setUser( const std::string& user );
98
101 const std::string& getUser() const;
102
105 void setPassword( const std::string& password );
106
109 const std::string& getPassword() const;
110
113 bool isValid() const;
114
115 private:
116 std::string m_proxyUri; // e.g. "http://local.example.com:1080"
117 std::string m_user;
118 std::string m_password;
119 };
120
123 {
124 public:
125
128
131 ExtendedOptions( const std::wstring& licenseFilePath );
132
137 ExtendedOptions( const std::wstring& licenseFilePath,
138 const std::string& hardwareID,
139 const ProxySettings& proxy = ProxySettings() );
140
143
147 void setLicenseFilePath( const std::wstring& filePath );
148
152 const std::wstring& getLicenseFilePath() const;
153
156 void setHardwareID( const std::string& ID );
157
160 const std::string& getHardwareID() const;
161
165
170
175 void collectNetworkInfo( bool collect );
176
180
187 void enableLogging( bool enable );
188
191 bool isLoggingEnabled() const;
192
197 void enableGuardFile( bool enable );
198
201 bool isGuardFileEnabled() const;
202
207 void enableVMDetection( bool enable );
208
212
217 void enableSSLCheck( bool enable );
218
221 bool isSSLCheckEnabled() const;
222
229 void setUseNativeTLS( bool value );
230
234 bool isNativeTLSEnabled() const;
235
240 void enableLicenseCorruptionCheck( bool enable );
241
246
251 void setGracePeriod( uint32_t value );
252
255 uint32_t getGracePeriod() const;
256
260 void setNetworkTimeout( long timeout );
261
264 long getNetworkTimeout() const;
265
269 void setConnectTimeout( long timeout );
270
273 long getConnectTimeout() const;
274
278 void setProxySettings( const ProxySettings& settings );
279
283
286 void overrideNetworkInfo( const NetworkInfo& networkInfo );
287
291
296
300
305 void setAlternateServiceURL( const std::string& URL );
306
309 const std::string& getAlternateServiceURL() const;
310
314 void setAlternateKey( const std::string& key );
315
319 void setAlternateKey( const std::vector<int32_t>& key );
320
325 void setAlternateKey( const int32_t* key, std::size_t size );
326
329 const std::string& getAlternateKey() const;
330
331 private:
332 std::wstring m_licenseFilePath;
333 std::string m_hardwareID;
334 std::string m_serviceURL;
335 std::string m_key;
336 bool m_collectNetworkInfo; // false by default
337 bool m_enableVMDetection; // false by default
338 bool m_enableGuardFile; // true by default
339 bool m_enableSSLCheck; // false by default
340 bool m_useNativeTLS; // see isNativeTLSEnabled
341 bool m_enableLicenseCorruptionCheck; // false by default
342 uint32_t m_gracePeriod; // in hours, default value is 48
343 long m_networkTimeout; // in seconds, default is 5 seconds
344 long m_connectTimeout; // in seconds, default is 7 seconds
345 ProxySettings m_proxySettings; // by default doesn't use any proxy
346 NetworkInfo m_networkInfo;
347 DeviceIDAlgorithm m_deviceIDAlgorithm;
348 CryptoProvider::ptr_t m_cryptoProvider;
349 };
350
351} // namespace LicenseSpring
352
353#ifdef _MSC_VER
354#pragma warning( pop )
355#endif
356
357#endif // LS_EXTENDED_OPTIONS_H
#define LS_API
Macros that expands to dllexport, dllimport or nothing on non Windows platforms or in case of static ...
Definition APIDef.h:22
DeviceIDAlgorithm
Type of Device ID algorithm used by the SDK.
Definition PODTypes.h:108
std::shared_ptr< CryptoProvider > ptr_t
Class for storing useful settings that the Configuration object will inherit.
uint32_t getGracePeriod() const
Getter for grace period.
const std::string & getHardwareID() const
Get hardware ID.
~ExtendedOptions()
Destructor for ExtendedOptions.
void setUseNativeTLS(bool value)
Enable or disable native TLS for curl.
bool isLicenseCorruptionCheckEnabled() const
Checker for whether encrypted license data corruption checking is enabled.
bool isGuardFileEnabled() const
Checker for whether enableGuardFile() is enabled.
void overrideCryptoProvider(CryptoProvider::ptr_t cryptoProvider)
Setter for CryptoProvider.
void collectNetworkInfo(bool collect)
Collect network information.
DeviceIDAlgorithm getDeviceIdAlgorithm() const
Get device (hardware) id calculation algorithm.
const std::wstring & getLicenseFilePath() const
Get license file path.
void setGracePeriod(uint32_t value)
Setter for grace period.
void overrideNetworkInfo(const NetworkInfo &networkInfo)
Setter for NetworkInfo.
void setConnectTimeout(long timeout)
Setter for connect timeout, used for CURLOPT_CONNECTTIMEOUT option.
CryptoProvider::ptr_t getCryptoProvider()
Getter for CryptoProvider.
void setProxySettings(const ProxySettings &settings)
Setter for proxy settings.
bool isLoggingEnabled() const
Checker for whether enableLogging() is enabled.
void setLicenseFilePath(const std::wstring &filePath)
Set license file path.
bool isNativeTLSEnabled() const
Checker for whether native TLS for curl enabled or not.
void setHardwareID(const std::string &ID)
Setter for hardware ID.
bool isVMDetectionEnabled() const
Checker for whether enableVMDetection() is enabled.
void enableGuardFile(bool enable)
Enable guard file.
void setAlternateKey(const std::vector< int32_t > &key)
Set alternate public key.
void enableVMDetection(bool enable)
Enable VM detection.
long getNetworkTimeout() const
Getter for network timeout.
const NetworkInfo & getNetworkInfo() const
Getter for network info.
void enableSSLCheck(bool enable)
Enable or disable SSL certificate verification.
long getConnectTimeout() const
Getter for connect timeout, used for CURLOPT_CONNECTTIMEOUT option.
const std::string & getAlternateKey() const
Getter for alternate License API URL.
const ProxySettings & getProxySettings() const
Getter for proxy settings.
void setAlternateServiceURL(const std::string &URL)
This method can be used if you are planning to deploy self-hosted server.
ExtendedOptions(const std::wstring &licenseFilePath, const std::string &hardwareID, const ProxySettings &proxy=ProxySettings())
Constructor for ExtendedOptions.
void enableLicenseCorruptionCheck(bool enable)
Enable or disable encrypted license data corruption checking.
void setDeviceIdAlgorithm(DeviceIDAlgorithm algorithm)
Allows to choose device (hardware) id calculation algorithm.
ExtendedOptions(const std::wstring &licenseFilePath)
Constructor for ExtendedOptions.
bool isCollectNetworkInfoEnabled() const
Checker for whether collectNetworkInfo() is enabled.
void enableLogging(bool enable)
Enable logging.
ExtendedOptions()
Default constructor for ExtendedOptions.
const std::string & getAlternateServiceURL() const
Getter for alternate License API URL.
void setNetworkTimeout(long timeout)
Setter for network timeout.
void setAlternateKey(const int32_t *key, std::size_t size)
Set alternate public key.
bool isSSLCheckEnabled() const
Checker for whether SSL certificate verification is enabled.
void setAlternateKey(const std::string &key)
Set alternate public key. This method can be used if you are planning to deploy self-hosted server.
Class for storing a device's network information.
const std::string & mac() const
Getter for MAC address.
void setIp(const std::string &ip)
Setter for IP address.
void setHostName(const std::string &hostName)
Setter for host name.
NetworkInfo()=default
Constructor for networkInfo.
const std::string & ip() const
Getter for IP address.
const std::string & hostName() const
Getter for host name.
void setMac(const std::string &mac)
Setter for MAC address.
~NetworkInfo()
Destructor for networkInfo.
Class for storing settings when using a proxy server.
void setUser(const std::string &user)
Setter for proxy user.
bool fetchProxySettings(const std::string &serviceURL, const std::string &credentialTarget, bool throwExceptions=false)
Automatically fetch proxy URI and credentials.
~ProxySettings()
Destructor for proxy settings.
const std::string & getProxyUri() const
Getter for proxy URI.
const std::string & getPassword() const
Getter for password.
const std::string & getUser() const
Getter for proxy user.
bool isValid() const
Checker for if proxy URI is specified (i.e. not empty).
void setProxyUri(const std::string &uri)
Setter for proxy URI.
void setPassword(const std::string &password)
Setter for password.
ProxySettings(const std::string &proxy, const std::string &user, const std::string &password)
Constructor for proxy settings.
ProxySettings()=default
Default constructor for proxy settings.