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 
127 {
128 public:
130  HardwareKeyOptions() = default;
131 
133  ~HardwareKeyOptions() = default;
134 
140  static std::vector<std::string> ListAvailableKeys();
141 
145  void setTargetSerial(const std::string &serial);
146 
149  const std::string &getTargetSerial() const;
150 
153  void setPin(const std::string &pin);
154 
157  const std::string &getPin() const;
158 
159 private:
160  std::string m_targetSerial;
161  std::string m_pin;
162 };
163 
166 {
167 public:
169  ExtendedOptions();
170 
173  ExtendedOptions(const std::wstring &licenseFilePath);
174 
179  ExtendedOptions(const std::wstring &licenseFilePath, const std::string &hardwareID,
180  const ProxySettings &proxy = ProxySettings());
181 
183  ~ExtendedOptions();
184 
189  void setLicenseFilePath(const std::wstring &filePath);
190 
194  const std::wstring &getLicenseFilePath() const;
195 
198  void setHardwareID(const std::string &ID);
199 
202  const std::string &getHardwareID() const;
203 
206  DeviceIDAlgorithm getDeviceIdAlgorithm() const;
207 
211  void setDeviceIdAlgorithm(DeviceIDAlgorithm algorithm);
212 
218  void collectNetworkInfo(bool collect);
219 
222  bool isCollectNetworkInfoEnabled() const;
223 
231  void enableLogging(bool enable);
232 
235  bool isLoggingEnabled() const;
236 
241  void enableGuardFile(bool enable);
242 
245  bool isGuardFileEnabled() const;
246 
251  void enableVMDetection(bool enable);
252 
255  bool isVMDetectionEnabled() const;
256 
262  void enableSSLCheck(bool enable);
263 
266  bool isSSLCheckEnabled() const;
267 
274  void setUseNativeTLS(bool value);
275 
279  bool isNativeTLSEnabled() const;
280 
286  void enableLicenseCorruptionCheck(bool enable);
287 
291  bool isLicenseCorruptionCheckEnabled() const;
292 
297  void enableHardwareKey(bool enable);
298 
302  bool isHardwareKeyEnabled() const;
303 
309  void setGracePeriod(uint32_t value);
310 
313  uint32_t getGracePeriod() const;
314 
318  void setNetworkTimeout(long timeout);
319 
322  long getNetworkTimeout() const;
323 
327  void setConnectTimeout(long timeout);
328 
331  long getConnectTimeout() const;
332 
336  void setProxySettings(const ProxySettings &settings);
337 
340  const ProxySettings &getProxySettings() const;
341 
344  void overrideNetworkInfo(const NetworkInfo &networkInfo);
345 
348  const NetworkInfo &getNetworkInfo() const;
349 
353  void overrideCryptoProvider(CryptoProvider::ptr_t cryptoProvider);
354 
357  CryptoProvider::ptr_t getCryptoProvider();
358 
364  void setAlternateServiceURL(const std::string &URL);
365 
368  const std::string &getAlternateServiceURL() const;
369 
375  void setAlternateKey(const std::string &key);
376 
380  void setAlternateKey(const std::vector<int32_t> &key);
381 
386  void setAlternateKey(const int32_t *key, std::size_t size);
387 
390  const std::string &getAlternateKey() const;
391 
396  void setHardwareKeyOptions(const HardwareKeyOptions &options);
397 
400  const HardwareKeyOptions &getHardwareKeyOptions() const;
401 
402 private:
403  std::wstring m_licenseFilePath;
404  std::string m_hardwareID;
405  std::string m_serviceURL;
406  std::string m_key;
407  bool m_collectNetworkInfo; // false by default
408  bool m_enableVMDetection; // false by default
409  bool m_enableGuardFile; // true by default
410  bool m_enableSSLCheck; // false by default
411  bool m_useNativeTLS; // see isNativeTLSEnabled
412  bool m_enableLicenseCorruptionCheck; // false by default
413  bool m_enableHardwareKey; // false by default
414  uint32_t m_gracePeriod; // in hours, default value is 48
415  long m_networkTimeout; // in seconds, default is 5 seconds
416  long m_connectTimeout; // in seconds, default is 7 seconds
417  ProxySettings m_proxySettings; // by default doesn't use any proxy
418  NetworkInfo m_networkInfo;
419  DeviceIDAlgorithm m_deviceIDAlgorithm;
420  CryptoProvider::ptr_t m_cryptoProvider;
421  HardwareKeyOptions m_hardwareKeyOptions;
422 };
423 
424 } // namespace LicenseSpring
425 
426 #ifdef _MSC_VER
427 #pragma warning(pop)
428 #endif
429 
430 #endif // LS_EXTENDED_OPTIONS_H
LicenseSpring::CryptoProvider::ptr_t
std::shared_ptr< CryptoProvider > ptr_t
Definition: CryptoProvider.h:23
LicenseSpring
Definition: BaseManager.h:16
DeviceIDAlgorithm
DeviceIDAlgorithm
Type of Device ID algorithm used by the SDK.
Definition: PODTypes.h:118
LicenseSpring::NetworkInfo
Class for storing a device's network information.
Definition: ExtendedOptions.h:20
APIDef.h
LS_API
#define LS_API
Definition: APIDef.h:23
LicenseSpring::HardwareKeyOptions
Class for managing Hardware Key (YubiKey PIV) specific options.
Definition: ExtendedOptions.h:126
PODTypes.h
CryptoProvider.h
LicenseSpring::ExtendedOptions
Class for storing useful settings that the Configuration object will inherit.
Definition: ExtendedOptions.h:165
LicenseSpring::ProxySettings
Class for storing settings when using a proxy server.
Definition: ExtendedOptions.h:60