Manage loan tokens

This commit is contained in:
2022-04-03 09:32:06 +02:00
parent 2e7e352e35
commit 570ad83747
8 changed files with 207 additions and 8 deletions

View File

@@ -20,7 +20,7 @@
#ifndef _FULFILLMENT_ITEM_H_
#define _FULFILLMENT_ITEM_H_
#include "bytearray.h"
#include "loan_token.h"
#include <pugixml.hpp>
@@ -42,6 +42,8 @@ namespace gourou
*/
FulfillmentItem(pugi::xml_document& doc, User* user);
~FulfillmentItem();
/**
* @brief Return metadata value from ACSM metadata section
*
@@ -64,13 +66,19 @@ namespace gourou
*/
std::string getResource();
/**
* @brief Return loan token if there is one
*/
LoanToken* getLoanToken();
private:
pugi::xml_document fulfillDoc;
pugi::xml_node metadatas;
pugi::xml_document rights;
std::string downloadURL;
std::string resource;
LoanToken* loanToken;
void buildRights(const pugi::xml_node& licenseToken, User* user);
};
}

View File

@@ -40,7 +40,7 @@
#define ACS_SERVER "http://adeactivate.adobe.com/adept"
#endif
#define LIBGOUROU_VERSION "0.6"
#define LIBGOUROU_VERSION "0.7"
namespace gourou
{
@@ -100,6 +100,14 @@ namespace gourou
*/
void activateDevice();
/**
* @brief Return loaned book to server
*
* @param loanID Loan ID received during fulfill
* @param operatorURL URL of operator that loans this book
*/
void returnLoan(const std::string& loanID, const std::string& operatorURL);
/**
* @brief Create a new ADEPT environment (device.xml, devicesalt and activation.xml).
*
@@ -218,6 +226,7 @@ namespace gourou
void operatorAuth(std::string operatorURL);
void buildFulfillRequest(pugi::xml_document& acsmDoc, pugi::xml_document& fulfillReq);
void buildActivateReq(pugi::xml_document& activateReq);
void buildReturnReq(pugi::xml_document& returnReq, const std::string& loanID, const std::string& operatorURL);
ByteArray sendFulfillRequest(const pugi::xml_document& document, const std::string& url);
void buildSignInRequest(pugi::xml_document& signInRequest, const std::string& adobeID, const std::string& adobePassword, const std::string& authenticationCertificate);
void fetchLicenseServiceCertificate(const std::string& licenseURL,

View File

@@ -55,7 +55,8 @@ namespace gourou
GOUROU_INVALID_CLIENT,
GOUROU_TAG_NOT_FOUND,
GOUROU_ADEPT_ERROR,
GOUROU_FILE_ERROR
GOUROU_FILE_ERROR,
GOUROU_INVALID_PROPERTY
};
enum FULFILL_ERROR {
@@ -96,7 +97,8 @@ namespace gourou
};
enum FULFILL_ITEM_ERROR {
FFI_INVALID_FULFILLMENT_DATA = 0x4000
FFI_INVALID_FULFILLMENT_DATA = 0x4000,
FFI_INVALID_LOAN_TOKEN
};
enum CLIENT_ERROR {

54
include/loan_token.h Normal file
View File

@@ -0,0 +1,54 @@
/*
Copyright 2022 Grégory Soutadé
This file is part of libgourou.
libgourou is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libgourou is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with libgourou. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _LOAN_TOKEN_H_
#define _LOAN_TOKEN_H_
#include <map>
#include <pugixml.hpp>
namespace gourou
{
/**
* @brief This class is a container for a fulfillment object
*/
class LoanToken
{
public:
/**
* @brief Main constructor. Not to be called by user
*
* @param doc Fulfill reply
*/
LoanToken(pugi::xml_document& doc);
/**
* @brief Get a property (id, operatorURL, validity)
*/
std::string getProperty(const std::string& property, const std::string& _default=std::string(""));
std::string operator[](const std::string& property);
private:
std::map<std::string, std::string> properties;
};
}
#endif