1 | /*␊ |
2 | Copyright 2021 Grégory Soutadé␊ |
3 | ␊ |
4 | This file is part of libgourou.␊ |
5 | ␊ |
6 | libgourou is free software: you can redistribute it and/or modify␊ |
7 | it under the terms of the GNU Lesser General Public License as published by␊ |
8 | the Free Software Foundation, either version 3 of the License, or␊ |
9 | (at your option) any later version.␊ |
10 | ␊ |
11 | libgourou is distributed in the hope that it will be useful,␊ |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of␊ |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the␊ |
14 | GNU Lesser General Public License for more details.␊ |
15 | ␊ |
16 | You should have received a copy of the GNU Lesser General Public License␊ |
17 | along with libgourou. If not, see <http://www.gnu.org/licenses/>.␊ |
18 | */␊ |
19 | ␊ |
20 | #ifndef _USER_H_␊ |
21 | #define _USER_H_␊ |
22 | ␊ |
23 | #include <string>␊ |
24 | #include <map>␊ |
25 | ␊ |
26 | #include "bytearray.h"␊ |
27 | ␊ |
28 | #include <pugixml.hpp>␊ |
29 | ␊ |
30 | namespace gourou␊ |
31 | {␊ |
32 | class DRMProcessor;␊ |
33 | ␊ |
34 | /**␊ |
35 | * @brief This class is a container for activation.xml (activation info). It should not be used by user.␊ |
36 | */␊ |
37 | class User␊ |
38 | {␊ |
39 | public:␊ |
40 | User(DRMProcessor* processor, const std::string& activationFile);␊ |
41 | ␊ |
42 | ␉/**␊ |
43 | ␉ * @brief Retrieve some values from activation.xml ␊ |
44 | ␉ */␊ |
45 | ␉std::string& getUUID();␊ |
46 | ␉std::string& getPKCS12();␊ |
47 | ␉std::string& getDeviceUUID();␊ |
48 | ␉std::string& getDeviceFingerprint();␊ |
49 | ␉std::string& getUsername();␊ |
50 | ␉std::string& getLoginMethod();␊ |
51 | ␉std::string getLicenseServiceCertificate(std::string url);␊ |
52 | ␉std::string& getAuthenticationCertificate();␊ |
53 | ␉std::string& getPrivateLicenseKey();␊ |
54 | ␊ |
55 | ␉/**␊ |
56 | ␉ * @brief Read activation.xml and put result into doc␊ |
57 | ␉ */␊ |
58 | ␉void readActivation(pugi::xml_document& doc);␊ |
59 | ␊ |
60 | ␉/**␊ |
61 | ␉ * @brief Update activation.xml with new data␊ |
62 | ␉ */␊ |
63 | ␉void updateActivationFile(const char* data);␊ |
64 | ␊ |
65 | ␉/**␊ |
66 | ␉ * @brief Update activation.xml with doc data␊ |
67 | ␉ */␊ |
68 | ␉void updateActivationFile(const pugi::xml_document& doc);␊ |
69 | ␊ |
70 | ␉/**␊ |
71 | ␉ * @brief Get one value of activation.xml ␊ |
72 | ␉ */␊ |
73 | ␉std::string getProperty(const std::string property);␊ |
74 | ␉␊ |
75 | ␉/**␊ |
76 | ␉ * @brief Get all nodes with property name␊ |
77 | ␉ */␊ |
78 | ␉pugi::xpath_node_set getProperties(const std::string property);␊ |
79 | ␉␊ |
80 | ␉/**␊ |
81 | ␉ * @brief Create activation.xml and devicesalt files if they did not exists␊ |
82 | ␉ *␊ |
83 | ␉ * @param processor Instance of DRMProcessor␊ |
84 | ␉ * @param dirName Directory where to put files (.adept)␊ |
85 | ␉ * @param ACSServer Server used for signIn␊ |
86 | ␉ */␊ |
87 | ␉static User* createUser(DRMProcessor* processor, const std::string& dirName, const std::string& ACSServer);␊ |
88 | ␊ |
89 | private:␊ |
90 | ␉DRMProcessor* processor;␊ |
91 | ␉pugi::xml_document activationDoc;␊ |
92 | ␉␊ |
93 | std::string activationFile;␊ |
94 | ␉std::string pkcs12;␊ |
95 | ␉std::string uuid;␊ |
96 | ␉std::string deviceUUID;␊ |
97 | ␉std::string deviceFingerprint;␊ |
98 | ␉std::string username;␊ |
99 | ␉std::string loginMethod;␊ |
100 | ␉std::map<std::string,std::string> licenseServiceCertificates;␊ |
101 | ␉std::string authenticationCertificate;␊ |
102 | ␉std::string privateLicenseKey;␊ |
103 | ␊ |
104 | ␉User(DRMProcessor* processor);␊ |
105 | ␉␊ |
106 | ␉void parseActivationFile(bool throwOnNull=true);␊ |
107 | ␉ByteArray signIn(const std::string& adobeID, const std::string& adobePassword,␊ |
108 | ␉␉␉ ByteArray authenticationCertificate);␊ |
109 | };␊ |
110 | }␊ |
111 | ␊ |
112 | #endif␊ |