6 Commits

Author SHA1 Message Date
Grégory Soutadé
7f5a4900e0 Typo fix 2021-08-21 20:37:07 +02:00
Grégory Soutadé
d8f882a277 Fix a bug : gmtime() should used in place of localtime() to keep date in UTC and not local timezone 2021-08-12 21:11:40 +02:00
Grégory Soutadé
bdaceba2e0 Fix bad utils return value on error. Build network errors with a message and not just an error code. 2021-07-29 21:14:48 +02:00
Grégory Soutadé
b5eb0efd31 Force ACSM files to be parsed using UTF8 locale 2021-07-17 09:34:03 +02:00
Grégory Soutadé
20b4e69c3e Rename too generic "activate" util in "adept_activate" 2021-07-16 20:44:40 +02:00
Grégory Soutadé
878e4e7453 ACSM data mut be unescaped before parsing
Add a copy constructor to Exception
Start an authentication when E_ADEPT_DISTRIBUTOR_AUTH error is received during fulfill
Don't download external libraries if it already exists
2021-07-16 20:38:32 +02:00
17 changed files with 89 additions and 47 deletions

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _BYTEARRAY_H_ #ifndef _BYTEARRAY_H_

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _DEVICE_H_ #ifndef _DEVICE_H_
@@ -48,7 +48,7 @@ namespace gourou
const unsigned char* getDeviceKey(); const unsigned char* getDeviceKey();
/** /**
* @brief Get one value of device.xml (deviceClass, deviceSerial, deviceName, deviceType, jobbes, clientOS, clientLocale) * @brief Get one value of device.xml (deviceClass, deviceSerial, deviceName, deviceType, hobbes, clientOS, clientLocale)
*/ */
std::string getProperty(const std::string& property, const std::string& _default=std::string("")); std::string getProperty(const std::string& property, const std::string& _default=std::string(""));
std::string operator[](const std::string& property); std::string operator[](const std::string& property);

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _DRMPROCESSORCLIENT_H_ #ifndef _DRMPROCESSORCLIENT_H_

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _FULFILLMENT_ITEM_H_ #ifndef _FULFILLMENT_ITEM_H_

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _LIBGOUROU_H_ #ifndef _LIBGOUROU_H_
@@ -40,7 +40,7 @@
#define ACS_SERVER "http://adeactivate.adobe.com/adept" #define ACS_SERVER "http://adeactivate.adobe.com/adept"
#endif #endif
#define LIBGOUROU_VERSION "0.2.2" #define LIBGOUROU_VERSION "0.3.2"
namespace gourou namespace gourou
{ {
@@ -188,6 +188,7 @@ namespace gourou
void addNonce(pugi::xml_node& root); void addNonce(pugi::xml_node& root);
void buildAuthRequest(pugi::xml_document& authReq); void buildAuthRequest(pugi::xml_document& authReq);
void buildInitLicenseServiceRequest(pugi::xml_document& initLicReq, std::string operatorURL); void buildInitLicenseServiceRequest(pugi::xml_document& initLicReq, std::string operatorURL);
void doOperatorAuth(std::string operatorURL);
void operatorAuth(std::string operatorURL); void operatorAuth(std::string operatorURL);
void buildFulfillRequest(pugi::xml_document& acsmDoc, pugi::xml_document& fulfillReq); void buildFulfillRequest(pugi::xml_document& acsmDoc, pugi::xml_document& fulfillReq);
void buildActivateReq(pugi::xml_document& activateReq); void buildActivateReq(pugi::xml_document& activateReq);

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _LIBGOUROU_COMMON_H_ #ifndef _LIBGOUROU_COMMON_H_
@@ -109,7 +109,6 @@ namespace gourou
CLIENT_ZIP_ERROR, CLIENT_ZIP_ERROR,
CLIENT_GENERIC_EXCEPTION, CLIENT_GENERIC_EXCEPTION,
CLIENT_NETWORK_ERROR, CLIENT_NETWORK_ERROR,
}; };
/** /**
@@ -129,6 +128,14 @@ namespace gourou
fullmessage = strdup(msg.str().c_str()); fullmessage = strdup(msg.str().c_str());
} }
Exception(const Exception& other)
{
this->code = other.code;
this->line = line;
this->file = file;
this->fullmessage = strdup(other.fullmessage);
}
~Exception() ~Exception()
{ {
free(fullmessage); free(fullmessage);

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _LIBGOUROU_LOG_H_ #ifndef _LIBGOUROU_LOG_H_

View File

@@ -1,10 +1,14 @@
#!/bin/bash #!/bin/bash
# Pugixml # Pugixml
git clone https://github.com/zeux/pugixml.git lib/pugixml if [ ! -d lib/pugixml ] ; then
pushd lib/pugixml git clone https://github.com/zeux/pugixml.git lib/pugixml
git checkout latest pushd lib/pugixml
popd git checkout latest
popd
fi
# Base64 # Base64
git clone https://gist.github.com/f0fd86b6c73063283afe550bc5d77594.git lib/base64 if [ ! -d lib/base64 ] ; then
git clone https://gist.github.com/f0fd86b6c73063283afe550bc5d77594.git lib/base64
fi

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <string.h> #include <string.h>

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <sys/stat.h> #include <sys/stat.h>

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <fulfillment_item.h> #include <fulfillment_item.h>

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <arpa/inet.h> #include <arpa/inet.h>
@@ -291,7 +291,7 @@ namespace gourou
appendTextElem(root, "adept:nonce", nonce.toBase64().data()); appendTextElem(root, "adept:nonce", nonce.toBase64().data());
time_t _time = time(0) + 10*60; // Cur time + 10 minutes time_t _time = time(0) + 10*60; // Cur time + 10 minutes
struct tm* tm_info = localtime(&_time); struct tm* tm_info = gmtime(&_time);
char buffer[32]; char buffer[32];
strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", tm_info); strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", tm_info);
@@ -368,6 +368,22 @@ namespace gourou
appendTextElem(root, "adept:signature", signature); appendTextElem(root, "adept:signature", signature);
} }
void DRMProcessor::doOperatorAuth(std::string operatorURL)
{
pugi::xml_document authReq;
buildAuthRequest(authReq);
std::string authURL = operatorURL;
unsigned int fulfillPos = authURL.rfind("Fulfill");
if (fulfillPos == (authURL.size() - (sizeof("Fulfill")-1)))
authURL = authURL.substr(0, fulfillPos-1);
ByteArray replyData = sendRequest(authReq, authURL + "/Auth");
pugi::xml_document initLicReq;
std::string activationURL = user->getProperty("//adept:activationURL");
buildInitLicenseServiceRequest(initLicReq, authURL);
sendRequest(initLicReq, activationURL + "/InitLicenseService");
}
void DRMProcessor::operatorAuth(std::string operatorURL) void DRMProcessor::operatorAuth(std::string operatorURL)
{ {
pugi::xpath_node_set operatorList = user->getProperties("//adept:operatorURL"); pugi::xpath_node_set operatorList = user->getProperties("//adept:operatorURL");
@@ -382,20 +398,9 @@ namespace gourou
return; return;
} }
} }
pugi::xml_document authReq; doOperatorAuth(operatorURL);
buildAuthRequest(authReq);
std::string authURL = operatorURL;
int fulfillPos = authURL.rfind("Fulfill");
if (fulfillPos == ((int)authURL.size() - 7))
authURL = authURL.substr(0, fulfillPos-1);
ByteArray replyData = sendRequest(authReq, authURL + "/Auth");
pugi::xml_document initLicReq;
std::string activationURL = user->getProperty("//adept:activationURL");
buildInitLicenseServiceRequest(initLicReq, authURL);
sendRequest(initLicReq, activationURL + "/InitLicenseService");
// Add new operatorURL to list // Add new operatorURL to list
pugi::xml_document activationDoc; pugi::xml_document activationDoc;
user->readActivation(activationDoc); user->readActivation(activationDoc);
@@ -455,7 +460,7 @@ namespace gourou
pugi::xml_document acsmDoc; pugi::xml_document acsmDoc;
if (!acsmDoc.load_file(ACSMFile.c_str(), pugi::parse_ws_pcdata_single)) if (!acsmDoc.load_file(ACSMFile.c_str(), pugi::parse_ws_pcdata_single|pugi::parse_escapes, pugi::encoding_utf8))
EXCEPTION(FF_INVALID_ACSM_FILE, "Invalid ACSM file " << ACSMFile); EXCEPTION(FF_INVALID_ACSM_FILE, "Invalid ACSM file " << ACSMFile);
GOUROU_LOG(INFO, "Fulfill " << ACSMFile); GOUROU_LOG(INFO, "Fulfill " << ACSMFile);
@@ -494,7 +499,30 @@ namespace gourou
operatorAuth(operatorURL); operatorAuth(operatorURL);
ByteArray replyData = sendRequest(fulfillReq, operatorURL); ByteArray replyData;
try
{
replyData = sendRequest(fulfillReq, operatorURL);
}
catch (gourou::Exception& e)
{
/*
Operator requires authentication even if it's already in
our operator list
*/
std::string errorMsg(e.what());
if (e.getErrorCode() == GOUROU_ADEPT_ERROR &&
errorMsg.find("E_ADEPT_DISTRIBUTOR_AUTH") != std::string::npos)
{
doOperatorAuth(operatorURL);
replyData = sendRequest(fulfillReq, operatorURL);
}
else
{
throw e;
}
}
pugi::xml_document fulfillReply; pugi::xml_document fulfillReply;

View File

@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>. along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <libgourou.h> #include <libgourou.h>

View File

@@ -1,5 +1,5 @@
TARGETS=acsmdownloader activate TARGETS=acsmdownloader adept_activate
CXXFLAGS=-Wall `pkg-config --cflags Qt5Core Qt5Network` -fPIC -I$(ROOT)/include -I$(ROOT)/lib/pugixml/src/ CXXFLAGS=-Wall `pkg-config --cflags Qt5Core Qt5Network` -fPIC -I$(ROOT)/include -I$(ROOT)/lib/pugixml/src/
ifneq ($(STATIC_UTILS),) ifneq ($(STATIC_UTILS),)
@@ -19,7 +19,7 @@ all: $(TARGETS)
acsmdownloader: drmprocessorclientimpl.cpp acsmdownloader.cpp acsmdownloader: drmprocessorclientimpl.cpp acsmdownloader.cpp
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@ $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
activate: drmprocessorclientimpl.cpp activate.cpp adept_activate: drmprocessorclientimpl.cpp adept_activate.cpp
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@ $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
clean: clean:

View File

@@ -66,6 +66,7 @@ public:
void run() void run()
{ {
int ret = 0;
try try
{ {
DRMProcessorClientImpl client; DRMProcessorClientImpl client;
@@ -99,10 +100,10 @@ public:
} catch(std::exception& e) } catch(std::exception& e)
{ {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
this->app->exit(1); ret = 1;
} }
this->app->exit(0); this->app->exit(ret);
} }
private: private:

View File

@@ -100,10 +100,10 @@ static std::string getpass(const char *prompt, bool show_asterisk=false)
} }
class Activate: public QRunnable class ADEPTActivate: public QRunnable
{ {
public: public:
Activate(QCoreApplication* app): ADEPTActivate(QCoreApplication* app):
app(app) app(app)
{ {
setAutoDelete(false); setAutoDelete(false);
@@ -111,6 +111,7 @@ public:
void run() void run()
{ {
int ret = 0;
try try
{ {
DRMProcessorClientImpl client; DRMProcessorClientImpl client;
@@ -124,10 +125,10 @@ public:
} catch(std::exception& e) } catch(std::exception& e)
{ {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
this->app->exit(1); ret = 1;
} }
this->app->exit(0); this->app->exit(ret);
} }
private: private:
@@ -262,7 +263,7 @@ int main(int argc, char** argv)
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
Activate activate(&app); ADEPTActivate activate(&app);
QThreadPool::globalInstance()->start(&activate); QThreadPool::globalInstance()->start(&activate);
ret = app.exec(); ret = app.exec();

View File

@@ -119,7 +119,7 @@ std::string DRMProcessorClientImpl::sendHTTPRequest(const std::string& URL, cons
} }
if (reply->error() != QNetworkReply::NoError) if (reply->error() != QNetworkReply::NoError)
EXCEPTION(gourou::CLIENT_NETWORK_ERROR, "Error " << reply->error()); EXCEPTION(gourou::CLIENT_NETWORK_ERROR, "Error " << reply->errorString().toStdString());
if (gourou::logLevel >= gourou::DEBUG) if (gourou::logLevel >= gourou::DEBUG)
{ {