LicenseSpring C++ SDK  7.27.0
Easily add Software Licensing to your application
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 
15 namespace 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 
77  void setProxyUri( const std::string& uri );
78 
81  const std::string& getProxyUri() const;
82 
85  void setUser( const std::string& user );
86 
89  const std::string& getUser() const;
90 
93  void setPassword( const std::string& password );
94 
97  const std::string& getPassword() const;
98 
101  bool isValid() const;
102 
103  private:
104  std::string m_proxyUri; // e.g. "http://local.example.com:1080"
105  std::string m_user;
106  std::string m_password;
107  };
108 
111  {
112  public:
113 
116 
119  ExtendedOptions( const std::wstring& licenseFilePath );
120 
125  ExtendedOptions( const std::wstring& licenseFilePath,
126  const std::string& hardwareID,
127  const ProxySettings& proxy = ProxySettings() );
128 
131 
135  void setLicenseFilePath( const std::wstring& filePath );
136 
140  const std::wstring& getLicenseFilePath() const;
141 
144  void setHardwareID( const std::string& ID );
145 
148  const std::string& getHardwareID() const;
149 
153 
158 
163  void collectNetworkInfo( bool collect );
164 
168 
175  void enableLogging( bool enable );
176 
179  bool isLoggingEnabled() const;
180 
185  void enableGuardFile( bool enable );
186 
189  bool isGuardFileEnabled() const;
190 
195  void enableVMDetection( bool enable );
196 
199  bool isVMDetectionEnabled() const;
200 
205  void enableSSLCheck( bool enable );
206 
209  bool isSSLCheckEnabled() const;
210 
217  void setUseNativeTLS( bool value );
218 
222  bool isNativeTLSEnabled() const;
223 
228  void setGracePeriod( uint32_t value );
229 
232  uint32_t getGracePeriod() const;
233 
237  void setNetworkTimeout( long timeout );
238 
241  long getNetworkTimeout() const;
242 
246  void setProxySettings( const ProxySettings& settings );
247 
251 
254  void overrideNetworkInfo( const NetworkInfo& networkInfo );
255 
258  const NetworkInfo& getNetworkInfo() const;
259 
264 
268 
273  void setAlternateServiceURL( const std::string& URL );
274 
277  const std::string& getAlternateServiceURL() const;
278 
282  void setAlternateKey( const std::string& key );
283 
287  void setAlternateKey( const std::vector<int32_t>& key );
288 
293  void setAlternateKey( const int32_t* key, std::size_t size );
294 
297  const std::string& getAlternateKey() const;
298 
299  private:
300  std::wstring m_licenseFilePath;
301  std::string m_hardwareID;
302  std::string m_serviceURL;
303  std::string m_key;
304  bool m_collectNetworkInfo; // false by default
305  bool m_enableVMDetection; // false by default
306  bool m_enableGuardFile; // true by default
307  bool m_enableSSLCheck; // false by default
308  bool m_useNativeTLS; // see isNativeTLSEnabled
309  uint32_t m_gracePeriod; // in hours, default value is 48
310  long m_networkTimeout; // in seconds, default is 5 seconds
311  ProxySettings m_proxySettings; // by default doesn't use any proxy
312  NetworkInfo m_networkInfo;
313  DeviceIDAlgorithm m_deviceIDAlgorithm;
314  CryptoProvider::ptr_t m_cryptoProvider;
315  };
316 
317 } // namespace LicenseSpring
318 
319 #ifdef _MSC_VER
320 #pragma warning( pop )
321 #endif
322 
323 #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:101
std::shared_ptr< CryptoProvider > ptr_t
Class for storing useful settings that the Configuration object will inherit.
const std::string & getHardwareID() const
Get hardware ID.
uint32_t getGracePeriod() const
Getter for grace period.
~ExtendedOptions()
Destructor for ExtendedOptions.
void setUseNativeTLS(bool value)
Enable or disable native TLS for curl.
bool isGuardFileEnabled() const
Checker for whether enableGuardFile() is enabled.
void overrideCryptoProvider(CryptoProvider::ptr_t cryptoProvider)
Setter for CryptoProvider.
const NetworkInfo & getNetworkInfo() const
Getter for network info.
void collectNetworkInfo(bool collect)
Collect network information.
DeviceIDAlgorithm getDeviceIdAlgorithm() const
Get device (hardware) id calculation algorithm.
void setGracePeriod(uint32_t value)
Setter for grace period.
void overrideNetworkInfo(const NetworkInfo &networkInfo)
Setter for NetworkInfo.
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.
const ProxySettings & getProxySettings() const
Getter for proxy settings.
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.
void enableSSLCheck(bool enable)
Enable or disable SSL certificate verification.
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 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 & getAlternateKey() 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.
const std::string & getAlternateServiceURL() const
Getter for alternate License API URL.
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.
const std::wstring & getLicenseFilePath() const
Get license file path.
Class for storing a device's network information.
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.
void setMac(const std::string &mac)
Setter for MAC address.
const std::string & mac() const
Getter for MAC address.
const std::string & hostName() const
Getter for host name.
~NetworkInfo()
Destructor for networkInfo.
Class for storing settings when using a proxy server.
const std::string & getProxyUri() const
Getter for proxy URI.
const std::string & getPassword() const
Getter for password.
void setUser(const std::string &user)
Setter for proxy user.
const std::string & getUser() const
Getter for proxy user.
~ProxySettings()
Destructor for proxy settings.
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.