LicenseSpring C++ SDK
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 {
21 {
22 public:
24  NetworkInfo() = default;
25 
27  ~NetworkInfo();
28 
31  void setIp(const std::string &ip);
32 
35  const std::string &ip() const;
36 
39  void setMac(const std::string &mac);
40 
43  const std::string &mac() const;
44 
47  void setHostName(const std::string &hostName);
48 
51  const std::string &hostName() const;
52 
53 private:
54  std::string m_localIP;
55  std::string m_hostName;
56  std::string m_macAddress;
57 };
58 
61 {
62 public:
64  ProxySettings() = default;
65 
70  ProxySettings(const std::string &proxy, const std::string &user, const std::string &password);
71 
73  ~ProxySettings();
74 
85  bool fetchProxySettings(const std::string &serviceURL, const std::string &credentialTarget,
86  bool throwExceptions = false);
87 
90  void setProxyUri(const std::string &uri);
91 
94  const std::string &getProxyUri() const;
95 
98  void setUser(const std::string &user);
99 
102  const std::string &getUser() const;
103 
106  void setPassword(const std::string &password);
107 
110  const std::string &getPassword() const;
111 
114  bool isValid() const;
115 
116 private:
117  std::string m_proxyUri; // e.g. "http://local.example.com:1080"
118  std::string m_user;
119  std::string m_password;
120 };
121 
124 {
125 public:
127  ExtendedOptions();
128 
131  ExtendedOptions(const std::wstring &licenseFilePath);
132 
137  ExtendedOptions(const std::wstring &licenseFilePath, const std::string &hardwareID,
138  const ProxySettings &proxy = ProxySettings());
139 
141  ~ExtendedOptions();
142 
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 
164  DeviceIDAlgorithm getDeviceIdAlgorithm() const;
165 
169  void setDeviceIdAlgorithm(DeviceIDAlgorithm algorithm);
170 
176  void collectNetworkInfo(bool collect);
177 
180  bool isCollectNetworkInfoEnabled() const;
181 
189  void enableLogging(bool enable);
190 
193  bool isLoggingEnabled() const;
194 
199  void enableGuardFile(bool enable);
200 
203  bool isGuardFileEnabled() const;
204 
209  void enableVMDetection(bool enable);
210 
213  bool isVMDetectionEnabled() const;
214 
220  void enableSSLCheck(bool enable);
221 
224  bool isSSLCheckEnabled() const;
225 
232  void setUseNativeTLS(bool value);
233 
237  bool isNativeTLSEnabled() const;
238 
244  void enableLicenseCorruptionCheck(bool enable);
245 
249  bool isLicenseCorruptionCheckEnabled() const;
250 
256  void setGracePeriod(uint32_t value);
257 
260  uint32_t getGracePeriod() const;
261 
265  void setNetworkTimeout(long timeout);
266 
269  long getNetworkTimeout() const;
270 
274  void setConnectTimeout(long timeout);
275 
278  long getConnectTimeout() const;
279 
283  void setProxySettings(const ProxySettings &settings);
284 
287  const ProxySettings &getProxySettings() const;
288 
291  void overrideNetworkInfo(const NetworkInfo &networkInfo);
292 
295  const NetworkInfo &getNetworkInfo() const;
296 
300  void overrideCryptoProvider(CryptoProvider::ptr_t cryptoProvider);
301 
304  CryptoProvider::ptr_t getCryptoProvider();
305 
311  void setAlternateServiceURL(const std::string &URL);
312 
315  const std::string &getAlternateServiceURL() const;
316 
322  void setAlternateKey(const std::string &key);
323 
327  void setAlternateKey(const std::vector<int32_t> &key);
328 
333  void setAlternateKey(const int32_t *key, std::size_t size);
334 
337  const std::string &getAlternateKey() const;
338 
339 private:
340  std::wstring m_licenseFilePath;
341  std::string m_hardwareID;
342  std::string m_serviceURL;
343  std::string m_key;
344  bool m_collectNetworkInfo; // false by default
345  bool m_enableVMDetection; // false by default
346  bool m_enableGuardFile; // true by default
347  bool m_enableSSLCheck; // false by default
348  bool m_useNativeTLS; // see isNativeTLSEnabled
349  bool m_enableLicenseCorruptionCheck; // false by default
350  uint32_t m_gracePeriod; // in hours, default value is 48
351  long m_networkTimeout; // in seconds, default is 5 seconds
352  long m_connectTimeout; // in seconds, default is 7 seconds
353  ProxySettings m_proxySettings; // by default doesn't use any proxy
354  NetworkInfo m_networkInfo;
355  DeviceIDAlgorithm m_deviceIDAlgorithm;
356  CryptoProvider::ptr_t m_cryptoProvider;
357 };
358 
359 } // namespace LicenseSpring
360 
361 #ifdef _MSC_VER
362 #pragma warning(pop)
363 #endif
364 
365 #endif // LS_EXTENDED_OPTIONS_H
Class for storing a device&#39;s network information.
std::shared_ptr< CryptoProvider > ptr_t
Class for storing useful settings that the Configuration object will inherit.
DeviceIDAlgorithm
Type of Device ID algorithm used by the SDK.
Definition: PODTypes.h:114
Class for storing settings when using a proxy server.
#define LS_API
Definition: APIDef.h:23