├── python_django ├── sdk_lpl │ ├── __init__.py │ ├── apps.py │ ├── __pycache__ │ │ ├── config.cpython-35.pyc │ │ ├── urls.cpython-35.pyc │ │ ├── views.cpython-35.pyc │ │ └── __init__.cpython-35.pyc │ ├── utils │ │ ├── __pycache__ │ │ │ ├── crypt.cpython-35.pyc │ │ │ └── middlewares.cpython-35.pyc │ │ ├── inscription_partenaire.py │ │ ├── crypt.py │ │ └── middlewares.py │ ├── config.py │ ├── models │ │ ├── __pycache__ │ │ │ ├── MajCompteModel.cpython-35.pyc │ │ │ ├── UserInfosModel.cpython-35.pyc │ │ │ ├── CreationCompteModel.cpython-35.pyc │ │ │ ├── VerificationModel.cpython-35.pyc │ │ │ └── ValidationReponseModel.cpython-35.pyc │ │ ├── InfoCompteModel.py │ │ ├── VerificationModel.py │ │ ├── MajCompteModel.py │ │ ├── UserInfosModel.py │ │ ├── CreationCompteModel.py │ │ └── ValidationReponseModel.py │ ├── urls.py │ └── views.py ├── python_django │ ├── __init__.py │ ├── __pycache__ │ │ ├── urls.cpython-35.pyc │ │ ├── wsgi.cpython-35.pyc │ │ ├── __init__.cpython-35.pyc │ │ └── settings.cpython-35.pyc │ ├── wsgi.py │ ├── urls.py │ └── settings.py ├── db.sqlite3 ├── README.md ├── .idea │ ├── modules.xml │ ├── python_django.iml │ ├── misc.xml │ └── workspace.xml ├── manage.py └── LICENSE ├── logo-lpl.png ├── nodejs ├── package.json ├── changelog.md ├── models │ ├── VerificationModel.js │ ├── InformationCompteModel.js │ ├── MajCompteModel.js │ ├── CreationCompteModel.js │ ├── UserInfosModel.js │ └── ValidationReponseModel.js ├── config.js ├── utils │ ├── InscriptionPartenaire.js │ ├── AesCrypt.js │ └── Middleware.js └── app.js ├── php ├── examples │ ├── inscription-partenaire.php │ ├── update.php │ ├── creation.php │ └── verification.php ├── changelog.md ├── models │ ├── InformationsCompteModel.php │ ├── VerificationModel.php │ ├── UserInfoModel.php │ ├── ValidationReponseModel.php │ ├── MajCompteModel.php │ └── CreationCompteModel.php ├── Config.php ├── utils │ ├── InscriptionPartenaire.php │ └── HeaderUtils.php └── api │ ├── MajCompteService.php │ ├── CreationCompteService.php │ ├── VerificationService.php │ └── LPLAbstractService.php ├── asp.net └── sdk-lpl-mvc5 │ ├── sdk-lpl-mvc5 │ ├── Models │ │ ├── InformationCompteModel.cs │ │ ├── VerificationModel.cs │ │ ├── UpdateAccountModel.cs │ │ ├── CreationCompteModel.cs │ │ ├── ValidationResponseModel.cs │ │ └── UserInfoModel.cs │ ├── sdk-lpl-mvc5.shproj │ ├── Utils │ │ ├── InscriptionPartenaire.cs │ │ ├── Timestamp.cs │ │ ├── Hash.cs │ │ └── Encrypt.cs │ ├── sdk-lpl-mvc5.projitems │ ├── Config.cs │ ├── Filters │ │ └── CheckHeaderAttribute.cs │ └── Controllers │ │ ├── MajCompteController.cs │ │ ├── VerificationController.cs │ │ └── CreationCompteController.cs │ └── sdk-lpl-mvc5.sln ├── README.md ├── LICENSE ├── .gitattributes └── .gitignore /python_django/sdk_lpl/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /python_django/python_django/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /logo-lpl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/logo-lpl.png -------------------------------------------------------------------------------- /python_django/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/db.sqlite3 -------------------------------------------------------------------------------- /python_django/sdk_lpl/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SdkpythonConfig(AppConfig): 5 | name = 'sdkpython' 6 | -------------------------------------------------------------------------------- /python_django/README.md: -------------------------------------------------------------------------------- 1 | #SDK Python/Django 2 | 3 | Version Python : 3.5.2 4 | 5 | Version Django : 1.10.2 6 | 7 | Dependencies : pycrypto 2.6.1 -------------------------------------------------------------------------------- /python_django/sdk_lpl/__pycache__/config.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/__pycache__/config.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/__pycache__/urls.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/__pycache__/urls.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/__pycache__/views.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/__pycache__/views.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/python_django/__pycache__/urls.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/python_django/__pycache__/urls.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/python_django/__pycache__/wsgi.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/python_django/__pycache__/wsgi.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/utils/__pycache__/crypt.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/utils/__pycache__/crypt.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/python_django/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/python_django/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/python_django/__pycache__/settings.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/python_django/__pycache__/settings.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/utils/__pycache__/middlewares.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/utils/__pycache__/middlewares.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/config.py: -------------------------------------------------------------------------------- 1 | class Config: 2 | aes_key = "UKKzV7sxiGx3uc0auKrUO2kJTT2KSCeg" 3 | iv = "7405589013321961" 4 | partenaire_id = "2" 5 | code_secret = "mGoMuzoX8u" 6 | 7 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/__pycache__/MajCompteModel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/models/__pycache__/MajCompteModel.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/__pycache__/UserInfosModel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/models/__pycache__/UserInfosModel.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/__pycache__/CreationCompteModel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/models/__pycache__/CreationCompteModel.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/__pycache__/VerificationModel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/models/__pycache__/VerificationModel.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/__pycache__/ValidationReponseModel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NextINpact/LaPresseLibreSDK/HEAD/python_django/sdk_lpl/models/__pycache__/ValidationReponseModel.cpython-35.pyc -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/InfoCompteModel.py: -------------------------------------------------------------------------------- 1 | class InformationCompteModel(object): 2 | def __init__(self, mail, userName, guid): 3 | self.Email = mail 4 | self.Pseudo = userName 5 | self.Guid = guid -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/VerificationModel.py: -------------------------------------------------------------------------------- 1 | class VerificationModel(object): 2 | def __init__(self, password, mail, code): 3 | self.Password = password 4 | self.Mail = mail 5 | self.CodeUtilisateur = code 6 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | url(r'^verif', views.verification, name='verif'), 7 | url(r'^propagation', views.propagation, name='propagation'), 8 | url(r'^update', views.update, name='update'), 9 | ] 10 | -------------------------------------------------------------------------------- /python_django/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SDKLPL-node", 3 | "version": "1.0.2-rc1", 4 | "description": "SDK pour l'intégration des partenaire sur La Presse Libre", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node app.js" 8 | }, 9 | "dependencies": { 10 | "express": "^4.13.4", 11 | "body-parser": "^1.14.2", 12 | "errorhandler": "^1.4.3", 13 | "sha1": "^1.1.1" 14 | } 15 | } -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/MajCompteModel.py: -------------------------------------------------------------------------------- 1 | class MajCompteModel(object): 2 | def __init__(self, code_utilisateur, type_abo, date_souscription, date_expiration, tarif, statut): 3 | self.CodeUtilisateur = code_utilisateur 4 | self.TypeAbonnement = type_abo 5 | self.DateSouscription = date_souscription 6 | self.DateExpiration = date_expiration 7 | self.Tarif = tarif 8 | self.Statut = statut 9 | -------------------------------------------------------------------------------- /python_django/.idea/python_django.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /python_django/python_django/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for python_django project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "python_django.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /php/examples/inscription-partenaire.php: -------------------------------------------------------------------------------- 1 | "; 14 | echo "Inscrivez vous à La Presse Libre"; 15 | echo ""; 16 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/UserInfosModel.py: -------------------------------------------------------------------------------- 1 | class UserInfoModel(object): 2 | PartenaireID = 0 3 | Mail = "" 4 | CodeUtilisateur = "" 5 | TypeAbonnement = "" 6 | DateExpiration = "" 7 | DateSouscription = "" 8 | AccountExist = False 9 | 10 | def __init__(self, **kwargs): 11 | self.__dict__.update(kwargs) 12 | 13 | def create_dummy_model(self): 14 | self.Mail = "dummy@gmail.com" 15 | self.CodeUtilisateur = "dummy1234" 16 | self.AccountExist = True 17 | self.PartenaireID = 0 18 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Models/InformationCompteModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace sdk_lpl_mvc5.Models 6 | { 7 | /// 8 | /// Modèle pour la création d'un lien d'inscription partenaire 9 | /// Représente le modèle de données qui compose le paramètre dans l'url d'inscription partenaire 10 | /// 11 | public class InformationCompteModel 12 | { 13 | public string Email { get; set; } 14 | public string Pseudo { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/CreationCompteModel.py: -------------------------------------------------------------------------------- 1 | class CreationCompteModel(object): 2 | def __init__(self, code_utilisateur, pseudo, mail, password, type_abo, date_souscription, date_expiration, tarif, statut): 3 | self.CodeUtilisateur = code_utilisateur 4 | self.Pseudo = pseudo 5 | self.Mail = mail 6 | self.Password = password 7 | self.TypeAbonnement = type_abo 8 | self.DateSouscription = date_souscription 9 | self.DateExpiration = date_expiration 10 | self.Tarif = tarif 11 | self.Statut = statut 12 | -------------------------------------------------------------------------------- /nodejs/changelog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## 1.0.3 - 2016-09-08 6 | ### Updated 7 | - Fichier de configuration 8 | - Modèle de retour lors d'un test sur le web-service de Vérification 9 | 10 | ## 1.0.2-rc1 - 2016-05-26 11 | ### Updated 12 | - Release candidate 13 | - Ajout license MIT 14 | - Mise à jour de l'inscription partenaire (ajout du GUID dans les paramètres) 15 | 16 | ## 1.0.0 - 2016-02-02 17 | ### Added 18 | - Création du SDK NodeJS v1.0 19 | - Ajout du fichier CHANGELOG 20 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/models/ValidationReponseModel.py: -------------------------------------------------------------------------------- 1 | from enum import IntEnum 2 | 3 | 4 | class Codes(IntEnum): 5 | Success = 1 6 | EmailExist = 2 7 | UsernameExist = 3 8 | Fail = 4 9 | 10 | 11 | class ValidationResponseModel(object): 12 | PartenaireID = 0 13 | CodeUtilisateur = "" 14 | IsValid = False 15 | CodeEtat = Codes.Fail 16 | 17 | def __init__(self, **kwargs): 18 | self.__dict__.update(kwargs) 19 | 20 | def create_dummy_model(self): 21 | self.PartenaireID = 0 22 | self.CodeUtilisateur = "dummy1234" 23 | self.IsValid = True 24 | self.CodeEtat = Codes.Success 25 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "sdk-lpl-mvc5", "sdk-lpl-mvc5\sdk-lpl-mvc5.shproj", "{1B95BA3F-1111-456A-8B69-9EF295122E86}" 7 | EndProject 8 | Global 9 | GlobalSection(SharedMSBuildProjectFiles) = preSolution 10 | sdk-lpl-mvc5\sdk-lpl-mvc5.projitems*{1b95ba3f-1111-456a-8b69-9ef295122e86}*SharedItemsImports = 13 11 | EndGlobalSection 12 | GlobalSection(SolutionProperties) = preSolution 13 | HideSolutionNode = FALSE 14 | EndGlobalSection 15 | EndGlobal 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SDK La Presse Libre 2 | ![logo](https://github.com/NextINpact/LaPresseLibreSDK/blob/master/logo-lpl.png "Logo LPL") 3 | 4 | Ceci est le dépot des SDK d'intégration pour les partenaires La Presse Libre. Actuellement quatres langages sont supportés : PHP, NodeJS, ASP.NET et Python. 5 | 6 | - Version ASP.NET MVC5, C#6 7 | - Version PHP >= 5.2.x 8 | - Version NodeJS >= 4.0.x 9 | - Version Python 3.5.2 / Django 1.10.2 10 | 11 | Pour plus d'informations concernant le fonctionnement ou la configuration du SDK, veuillez vous rendre sur la page [Wiki](https://github.com/NextINpact/LaPresseLibreSDK/wiki). 12 | 13 | # License 14 | The MIT License (MIT) 15 | 16 | See [LICENSE file](LICENSE) 17 | 18 | #Version 19 | Release Candidate 1 20 | -------------------------------------------------------------------------------- /python_django/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /python_django/python_django/urls.py: -------------------------------------------------------------------------------- 1 | """python_django URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.10/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import include, url 17 | 18 | urlpatterns = [ 19 | url(r'^ws/', include('sdk_lpl.urls')), 20 | ] 21 | -------------------------------------------------------------------------------- /python_django/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "python_django.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /php/examples/update.php: -------------------------------------------------------------------------------- 1 | getResult(); 14 | 15 | // Traitements en base de données à partir de l'objet $majModel 16 | 17 | $model = new ValidationReponseModel(); 18 | $model->CodeUtilisateur = "e5016836-dfbe-49e1-82d7-b8ac300da6aa"; 19 | $model->IsValid = TRUE; 20 | $model->PartenaireID = 2; 21 | $model->CodeEtat = Etat::Success; 22 | 23 | echo $service->createResponse($model, 200); 24 | } catch(Exception $e) { 25 | header('HTTP/1.1 401 Unauthorized', true, 401); 26 | echo json_encode(Array('error' => $e->getMessage())); 27 | } -------------------------------------------------------------------------------- /python_django/sdk_lpl/utils/inscription_partenaire.py: -------------------------------------------------------------------------------- 1 | import json 2 | from urllib.parse import quote 3 | 4 | from sdk_lpl.config import Config 5 | from sdk_lpl.models.InfoCompteModel import InformationCompteModel 6 | from sdk_lpl.utils.crypt import Crypt 7 | 8 | 9 | def generate_url(mail, username, guid): 10 | """ 11 | Génération de l'url de l'inscription partenaire 12 | Inclure cette url dans une balise pour rediriger l'utilisateur connecté vers une page d'inscription de la plateforme LPL avec les champs mail et pseudo déjà remplis 13 | :param mail: 14 | :param username: 15 | :param guid: 16 | :return: 17 | """ 18 | model = InformationCompteModel(mail, username, guid) 19 | json_val = json.dumps(model.__dict__) 20 | crypt = Crypt(Config.aes_key, Config.iv) 21 | return "http://www.lapresselibre.fr/inscription-partenaire?user={}&partId={}".format( 22 | quote(crypt.aes_encrypt(json_val)), Config.partenaire_id) 23 | -------------------------------------------------------------------------------- /php/changelog.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## 1.0.3 - 2016-09-08 6 | ### Updated 7 | - Fichier de configuration 8 | - Modèle de retour lors d'un test sur le web-service de Vérification 9 | 10 | ## 1.0.2-rc1 - 2016-05-26 11 | ### Updated 12 | - Release candidate 13 | - Ajout license MIT 14 | - Mise à jour de l'inscription partenaire (ajout du GUID dans les paramètres) 15 | 16 | ## 1.0.1 - 2016-02-02 17 | ### Updated 18 | - Mise à jour du chiffrement des données et du retour des données à LPL (text/plain) 19 | 20 | ## 1.0.0 - 2016-01-19 21 | ### Added 22 | - Fonctionnalité de l'inscription LPL depuis un partenaire 23 | - Fichier CHANGELOG 24 | 25 | ### Updated 26 | - Déplacement des utilitaires concernant les headers dans le fichier HeaderUtils.php 27 | - Déplacement des exemples dans le dossier examples 28 | - Documentation du SDK 29 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/sdk-lpl-mvc5.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1b95ba3f-1111-456a-8b69-9ef295122e86 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 INpact Mediagroup 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /python_django/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 INpact Mediagroup 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Utils/InscriptionPartenaire.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using sdk_lpl_mvc5; 5 | using sdk_lpl_mvc5.Models; 6 | using Newtonsoft.Json; 7 | using System.Web; 8 | 9 | namespace sdk_lpl_mvc5.Utils 10 | { 11 | /// 12 | /// Utilitaire pour l'inscription partenaire 13 | /// 14 | public static class InscriptionPartenaire 15 | { 16 | /// 17 | /// Génération de l'url de l'inscription partenaire 18 | /// Inclure cette url dans une balise pour rediriger l'utilisateur connecté vers une page d'inscription de la plateforme LPL avec les champs mail et pseudo déjà remplis 19 | /// 20 | /// 21 | /// 22 | public static string GenerateUrl(InformationCompteModel model) 23 | { 24 | var json = JsonConvert.SerializeObject(model); 25 | 26 | return "http://www.lapresselibre.fr/inscription-partenaire?" + 27 | $"user={HttpUtility.UrlEncode(Encrypt.EncryptRJ256(json, Config.AESKey, Config.IV))}" + 28 | $"&partId={Config.PartID}"; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /php/examples/creation.php: -------------------------------------------------------------------------------- 1 | CreateDummyModel(); 18 | } else { 19 | $createModel = $service->getResult(); 20 | // Ajoutez ici votre logique de vérification des données en base à partir de l'objet $createModel 21 | 22 | // Exemple de composition du modèle à partir des données en base 23 | $model->CodeUtilisateur = "e5016836-dfbe-49e1-82d7-b8ac300da6aa"; 24 | $model->IsValid = TRUE; 25 | $model->PartenaireID = 2; 26 | $model->CodeEtat = Etat::Success; 27 | } 28 | 29 | echo $service->createResponse($model, 200); 30 | } catch(Exception $e) { 31 | header('HTTP/1.1 401 Unauthorized', true, 401); 32 | echo json_encode(Array('error' => $e->getMessage())); 33 | } -------------------------------------------------------------------------------- /python_django/sdk_lpl/utils/crypt.py: -------------------------------------------------------------------------------- 1 | import base64 2 | from Crypto.Cipher import AES 3 | 4 | 5 | class Crypt(object): 6 | """ 7 | Classe pour le chiffrement AES256 8 | """ 9 | 10 | def __init__(self, key, iv): 11 | self._key = key 12 | self._iv = iv 13 | self._mode = AES.MODE_CBC 14 | self._block_size = AES.block_size 15 | 16 | def pad(self, s): 17 | return s + b"\0" * (self._block_size - len(s) % self._block_size) 18 | 19 | def aes_encrypt(self, plain_text): 20 | """ 21 | Chiffrement AES256 22 | Utilise AES256 pour chiffrer une chaine de caractères et encode en base64 23 | :param plain_text: 24 | :return: 25 | """ 26 | encryptor = AES.new(self._key, self._mode, self._iv) 27 | padded_text = self.pad(plain_text.encode('utf-8')) 28 | return base64.b64encode(encryptor.encrypt(padded_text)) 29 | 30 | def aes_decrypt(self, cipher_text): 31 | """ 32 | Déchiffrement AES256 33 | Décode en base64 la chaine de caractères et utilise AES256 pour la déchiffrer 34 | :param cipher_text: 35 | :return: 36 | """ 37 | decryptor = AES.new(self._key, self._mode, self._iv) 38 | plain_text = decryptor.decrypt(base64.b64decode(cipher_text)) 39 | return plain_text.rstrip(b"\0").decode('utf-8') 40 | -------------------------------------------------------------------------------- /nodejs/models/VerificationModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Modèle pour la vérification de compte 3 | * Représente le modèle de données reçu lors de l'envoi d'une requete LPL de vérification de compte partenaire 4 | * @author Bastien Caubet , Luc Raymond 5 | * 6 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | */ 11 | module.exports = VerificationModel; 12 | 13 | function VerificationModel(obj) { 14 | this.Password = obj.Password; 15 | this.Mail = obj.Mail; 16 | this.CodeUtilisateur = obj.CodeUtilisateur; 17 | } -------------------------------------------------------------------------------- /nodejs/models/InformationCompteModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Modèle pour la création d'un lien d'inscription partenaire 3 | * Représente le modèle de données qui compose le paramètre dans l'url d'inscription partenaire 4 | * @author Bastien Caubet , Luc Raymond 5 | * 6 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | */ 11 | module.exports = InformationCompteModel; 12 | 13 | function InformationCompteModel(mail, userName, guid) { 14 | this.Email = mail; 15 | this.Pseudo = userName; 16 | this.Guid = guid; 17 | } 18 | -------------------------------------------------------------------------------- /php/examples/verification.php: -------------------------------------------------------------------------------- 1 | CreateDummyModel(); 21 | } else { 22 | $verificationModel = $service->getResult(); 23 | 24 | // Ajoutez ici votre logique de vérification des données en base à partir de l'objet $verificationModel 25 | // Exemple de composition du modèle à partir des données en base 26 | $model->Mail = "jean.dupont@gmail.com"; 27 | $model->CodeUtilisateur = "e5016836-dfbe-49e1-82d7-b8ac300da6aa"; 28 | $model->TypeAbonnement = "Mensuel"; 29 | $model->PartenaireID = 2; 30 | $model->DateExpiration = date_format(new DateTime(), "Y-m-d\TH:i:sO"); 31 | $model->DateSouscription = date_format(new DateTime(), "Y-m-d\TH:i:sO"); 32 | $model->AccountExist = TRUE; 33 | } 34 | 35 | echo $service->createResponse($model, 200); 36 | } catch(Exception $e) { 37 | header('HTTP/1.1 401 Unauthorized', true, 401); 38 | echo json_encode(Array('error' => $e->getMessage())); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/sdk-lpl-mvc5.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 1b95ba3f-1111-456a-8b69-9ef295122e86 7 | 8 | 9 | sdk_lpl_mvc5 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /nodejs/models/MajCompteModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Modèle pour la mise à jour de compte 3 | * Représente le modèle de données reçu lors de l'envoi d'une requete LPL de mise à jour de compte partenaire 4 | * @author Bastien Caubet , Luc Raymond 5 | * 6 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | */ 11 | module.exports = MajCompteModel; 12 | 13 | function MajCompteModel(obj) { 14 | this.CodeUtilisateur = obj.CodeUtilisateur; 15 | this.TypeAbonnement = obj.TypeAbonnement; 16 | this.DateSouscription = obj.DateSouscription; 17 | this.DateExpiration = obj.DateExpiration; 18 | this.Tarif = obj.Tarif; 19 | this.Statut = obj.Statut; 20 | } -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Utils/Timestamp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | /** 5 | * @author Bastien Caubet , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | namespace sdk_lpl_mvc5.Utils 16 | { 17 | public class Timestamp 18 | { 19 | /// 20 | /// Création d'un timestamp au format unix (en secondes) 21 | /// 22 | /// 23 | public static Int32 UnixTimestamp() 24 | { 25 | return (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /php/models/InformationsCompteModel.php: -------------------------------------------------------------------------------- 1 | dans l'url d'inscription partenaire 6 | * @author Bastien Caubet , Luc Raymond 7 | * 8 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | class InformationsCompteModel 17 | { 18 | public $Email; 19 | public $Pseudo; 20 | public $Guid; 21 | 22 | public function __construct($email, $userName, $guid) 23 | { 24 | $this->Email = $email; 25 | $this->Pseudo = $userName; 26 | $this->Guid = $guid; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Models/VerificationModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | /** 6 | * @author Bastien Caubet , Luc Raymond 7 | * 8 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | namespace sdk_lpl_mvc5.Models 17 | { 18 | /// 19 | /// Modèle pour la vérification de compte 20 | /// Représente le modèle de données reçu lors de l'envoi d'une requete LPL de vérification de compte partenaire 21 | /// 22 | public class VerificationModel 23 | { 24 | public string CodeUtilisateur { get; set; } 25 | public string Mail { get; set; } 26 | public string Password { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /php/models/VerificationModel.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | class VerificationModel 16 | { 17 | public $Password; 18 | public $Mail; 19 | public $CodeUtilisateur; 20 | 21 | /** 22 | * VerificationModel constructor. 23 | * @param $json 24 | */ 25 | public function __construct($json) { 26 | $this->Password = $json["Password"]; 27 | $this->Mail = $json["Mail"]; 28 | $this->CodeUtilisateur = $json["CodeUtilisateur"]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /nodejs/models/CreationCompteModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Modèle pour la création de compte 3 | * Représente le modèle de données reçu lors de l'envoi d'une requete LPL de création de compte partenaire 4 | * @author Bastien Caubet , Luc Raymond 5 | * 6 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | */ 11 | module.exports = CreationCompteModel; 12 | 13 | function CreationCompteModel(obj) { 14 | this.CodeUtilisateur = obj.CodeUtilisateur; 15 | this.Pseudo = obj.Pseudo; 16 | this.Mail = obj.Mail; 17 | this.Password = obj.Password; 18 | this.TypeAbonnement = obj.TypeAbonnement; 19 | this.DateSouscription = obj.DateSouscription; 20 | this.DateExpiration = obj.DateExpiration; 21 | this.Tarif = obj.Tarif; 22 | this.Statut = obj.Statut; 23 | } -------------------------------------------------------------------------------- /nodejs/models/UserInfosModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Modèle de réponse pour la vérification de compte 3 | * Représente le modèle de données envoyé en réponse d'une requête de vérification de compte partenaire 4 | * @author Bastien Caubet , Luc Raymond 5 | * 6 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | */ 11 | module.exports = UserInfosModel; 12 | 13 | function UserInfosModel() { 14 | this.PartenaireID; 15 | this.Mail; 16 | this.CodeUtilisateur; 17 | this.TypeAbonnement; 18 | this.DateExpiration ; 19 | this.DateSouscription; 20 | this.AccountExist; 21 | } 22 | 23 | UserInfosModel.prototype.CreateDummyModel = function () { 24 | this.Mail = "dummy@gmail.com"; 25 | this.CodeUtilisateur = "dummy1234"; 26 | this.AccountExist = true; 27 | this.PartenaireID = 0; 28 | } -------------------------------------------------------------------------------- /php/models/UserInfoModel.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | class UserInfoModel 16 | { 17 | public $PartenaireID; 18 | public $Mail; 19 | public $CodeUtilisateur; 20 | public $TypeAbonnement; 21 | public $DateExpiration; 22 | public $DateSouscription; 23 | public $AccountExist; 24 | 25 | 26 | public function CreateDummyModel() { 27 | $this->Mail = "dummy@gmail.com"; 28 | $this->CodeUtilisateur = "dummy"; 29 | $this->AccountExist = TRUE; 30 | $this->PartenaireID = 0; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/utils/middlewares.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import time 3 | from django.http import HttpResponse 4 | from sdk_lpl.config import Config 5 | 6 | 7 | def is_testing_ctx(request): 8 | """ 9 | Vérifie le contexte de la requête 10 | Si le header x-ctx est présent, la requête sert à verifier l'état du web-service 11 | :param request: 12 | :return: 13 | """ 14 | return "HTTP_X_CTX" in request.META 15 | 16 | 17 | class LplMiddleware(object): 18 | """ 19 | Vérification des informations contenus dans le header 20 | Permet de valider la transaction après comparaison du hachage SHA1 21 | entre les valeurs contenues dans les headers X-PART et X-TS plus le code secret et la valeur du header X-LPL 22 | """ 23 | 24 | def process_request(self, request): 25 | if "HTTP_X_LPL" in request.META and "HTTP_X_TS" in request.META and "HTTP_X_PART" in request.META: 26 | request_hash = request.META["HTTP_X_LPL"] 27 | timestamp = request.META["HTTP_X_TS"] 28 | part_id = request.META["HTTP_X_PART"] 29 | 30 | expected_hash = hashlib.sha1( 31 | "{}+{}+{}".format(part_id, timestamp, Config.code_secret).encode('utf-8')).hexdigest() 32 | 33 | if expected_hash != request_hash: 34 | return HttpResponse('Unauthorized', status=401) 35 | else: 36 | pass 37 | 38 | else: 39 | return HttpResponse('Unauthorized', status=401) 40 | 41 | def process_response(self, request, response): 42 | timestamp = int(time.time()) 43 | 44 | response['X-LPL'] = hashlib.sha1( 45 | "{}+{}+{}".format(Config.partenaire_id, timestamp, Config.code_secret).encode('utf-8')).hexdigest() 46 | response['X-TS'] = timestamp 47 | response['X-PART'] = Config.partenaire_id 48 | 49 | return response 50 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Models/UpdateAccountModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | /** 5 | * @author Bastien Caubet , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | namespace sdk_lpl_mvc5.Models 16 | { 17 | /// 18 | /// Modèle pour la mise à jour de compte 19 | /// Représente le modèle de données reçu lors de l'envoi d'une requete LPL de mise à jour de compte partenaire 20 | /// 21 | public class UpdateAccountModel 22 | { 23 | public string CodeUtilisateur { get; set; } 24 | public DateTime DateExpiration { get; set; } 25 | public DateTime DateSouscription { get; set; } 26 | public string TypeAbonnement { get; set; } 27 | public double Tarif { get; set; } 28 | public int Statut { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /php/models/ValidationReponseModel.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | class ValidationReponseModel 16 | { 17 | public $IsValid; 18 | public $CodeUtilisateur; 19 | public $PartenaireID; 20 | public $CodeEtat; 21 | 22 | public function CreateDummyModel() { 23 | $this->PartenaireID = 0; 24 | $this->CodeUtilisateur = "dummy"; 25 | $this->IsValid = TRUE; 26 | $this->CodeEtat = Etat::Success; 27 | } 28 | } 29 | 30 | 31 | abstract class Etat { 32 | const Success = 1; 33 | const EmailExist = 2; 34 | const UsernameExist = 3; 35 | const Fail = 4; 36 | } -------------------------------------------------------------------------------- /nodejs/models/ValidationReponseModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Modèle de réponse 3 | * Représente le modèle de données envoyé en réponse d'une requête de création ou de mise à jour de compte partenaire 4 | * @author Bastien Caubet , Luc Raymond 5 | * 6 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | */ 11 | module.exports.ValidationModel = ValidationReponseModel; 12 | 13 | function ValidationReponseModel() { 14 | this.PartenaireID; 15 | this.CodeUtilisateur; 16 | this.IsValid; 17 | this.CodeEtat; 18 | } 19 | 20 | ValidationReponseModel.prototype.CreateDummyModel = function() { 21 | this.PartenaireID = 0; 22 | this.CodeUtilisateur = "dummy"; 23 | this.IsValid = true; 24 | this.CodeEtat = Etat.Success; 25 | } 26 | 27 | 28 | var Etat = { 29 | Success : 1, 30 | EmailExist: 2, 31 | UsernameExist: 3, 32 | Fail: 4 33 | }; 34 | 35 | module.exports.Etat = Etat; -------------------------------------------------------------------------------- /php/models/MajCompteModel.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | class MajCompteModel 16 | { 17 | public $CodeUtilisateur; 18 | public $TypeAbonnement; 19 | public $DateSouscription; 20 | public $DateExpiration; 21 | public $Tarif; 22 | public $Statut; 23 | 24 | public function __construct($json) { 25 | $this->CodeUtilisateur = $json["CodeUtilisateur"]; 26 | $this->TypeAbonnement = $json["TypeAbonnement"]; 27 | $this->DateSouscription = $json["DateSouscription"]; 28 | $this->DateExpiration = $json["DateExpiration"]; 29 | $this->Tarif = $json["Tarif"]; 30 | $this->Statut = $json["Statut"]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Models/CreationCompteModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | /** 5 | * @author Bastien Caubet , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | namespace sdk_lpl_mvc5.Models 16 | { 17 | /// 18 | /// Modèle pour la création de compte 19 | /// Représente le modèle de données reçu lors de l'envoi d'une requete LPL de création de compte partenaire 20 | /// 21 | public class CreationCompteModel 22 | { 23 | public string CodeUtilisateur { get; set; } 24 | public string Mail { get; set; } 25 | public string Pseudo { get; set; } 26 | public string Password { get; set; } 27 | public string TypeAbonnement { get; set; } 28 | public DateTime DateExpiration { get; set; } 29 | public DateTime DateSouscription { get; set; } 30 | public double Tarif { get; set; } 31 | public int Statut { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /php/Config.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | exports.values = { 13 | /** 14 | * Clé secrete pour le chiffrage AES Rijndael 256 15 | * À modifier 16 | * @var string 17 | */ 18 | AES_KEY: "UKKzV7sxiGx3uc0auKrUO2kJTT2KSCeg", 19 | 20 | /** 21 | * Vecteur d'initialisation pour le chiffrage AES Rijndael 256 22 | * À modifier 23 | * @var string 24 | */ 25 | IV: "7405589013321961", 26 | 27 | /** 28 | * Numéro partenaire LPL 29 | * À modifier 30 | * @var string 31 | */ 32 | PARTENAIRE_ID: "2", 33 | 34 | /** 35 | * Code secret pour le hachage du header X-LPL 36 | * À modifier 37 | * @var string 38 | */ 39 | CODE_SECRET: "mGoMuzoX8u", 40 | }; -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Models/ValidationResponseModel.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Bastien Caubet , Luc Raymond 3 | * 4 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | * 8 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | namespace sdk_lpl_mvc5.Models 13 | { 14 | /// 15 | /// Modèle de réponse 16 | /// Représente le modèle de données envoyé en réponse d'une requête de création ou de mise à jour de compte partenaire 17 | /// 18 | public class ValidationResponseModel 19 | { 20 | public bool IsValid { get; set; } 21 | public string CodeUtilisateur { get; set; } 22 | public int PartenaireID { get; set; } 23 | public int CodeEtat { get; set; } 24 | 25 | public void CreateDummyModel() 26 | { 27 | CodeUtilisateur = "dummy"; 28 | IsValid = true; 29 | CodeEtat = Etat.Success; 30 | } 31 | } 32 | 33 | public enum Etat 34 | { 35 | Success = 1, 36 | EmailExist = 2, 37 | UsernameExist = 3, 38 | Fail = 4 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /php/models/CreationCompteModel.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | class CreationCompteModel{ 16 | 17 | public $CodeUtilisateur; 18 | public $Pseudo; 19 | public $Mail; 20 | public $Password; 21 | public $TypeAbonnement; 22 | public $DateSouscription; 23 | public $DateExpiration; 24 | public $Tarif; 25 | public $Statut; 26 | 27 | public function __construct($json){ 28 | $this->CodeUtilisateur = $json["CodeUtilisateur"]; 29 | $this->Pseudo = $json["Pseudo"]; 30 | $this->Mail = $json["Mail"]; 31 | $this->Password = $json["Password"]; 32 | $this->TypeAbonnement = $json["TypeAbonnement"]; 33 | $this->DateSouscription = $json["DateSouscription"]; 34 | $this->DateExpiration = $json["DateExpiration"]; 35 | $this->Tarif = $json["Tarif"]; 36 | $this->Statut = $json["Statut"]; 37 | } 38 | } -------------------------------------------------------------------------------- /nodejs/utils/InscriptionPartenaire.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Utilitaire pour l'inscription partenaire 3 | * @author Bastien Caubet , Luc Raymond 4 | * 5 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | var InfoModel = require("../models/InformationCompteModel"); 12 | var config = require("../config"); 13 | var AESCrypt = require("../utils/AesCrypt"); 14 | 15 | /** 16 | * Génération de l'url de l'inscription partenaire 17 | * Inclure cette url dans une balise pour rediriger l'utilisateur connecté vers une page d'inscription de la plateforme LPL avec les champs mail et pseudo déjà remplis 18 | * @param mail 19 | * @param userName 20 | * @return string 21 | */ 22 | exports.GenerateUrl = function(mail, userName, guid) { 23 | var model = new InfoModel(mail, userName, guid); 24 | 25 | var json = JSON.stringify(model); 26 | 27 | var crypt = new AESCrypt(); 28 | 29 | return "http://www.lapresselibre.fr/inscription-partenaire?" + 30 | `user=${encodeURIComponent(crypt.rijndael128Encrypt(config.values.AES_KEY, config.values.IV, json))}` + 31 | `&partId=${config.values.PARTENAIRE_ID}`; 32 | }; 33 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Models/UserInfoModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | /** 5 | * @author Bastien Caubet , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | namespace sdk_lpl_mvc5.Models 16 | { 17 | /// 18 | /// Modèle de réponse pour la vérification de compte 19 | /// Représente le modèle de données envoyé en réponse d'une requête de vérification de compte partenaire 20 | /// 21 | public class UserInfoModel 22 | { 23 | public int PartenaireID { get; set; } 24 | public string CodeUtilisateur { get; set; } 25 | public string Mail { get; set; } 26 | public string TypeAbonnement { get; set; } 27 | public DateTime? DateExpiration { get; set; } 28 | public DateTime? DateSouscription { get; set; } 29 | public bool AccountExist { get; set; } 30 | 31 | public void CreateDummyModel() 32 | { 33 | model.AccountExist = true; 34 | model.Mail = "dummy@gmail.com"; 35 | model.CodeUtilisateur = "dummy1234"; 36 | model.PartenaireID = 0; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /php/utils/InscriptionPartenaire.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * Date: 18/01/2016 7 | * Time: 16:24 8 | * 9 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | 18 | require_once "../models/InformationsCompteModel.php"; 19 | require_once "../Config.php"; 20 | 21 | class InscriptionPartenaire 22 | { 23 | /** 24 | * Génération de l'url de l'inscription partenaire 25 | * Inclure cette url dans une balise pour rediriger l'utilisateur connecté vers une page d'inscription de la plateforme LPL avec les champs mail et pseudo déjà remplis 26 | * @param $email 27 | * @param $userName 28 | * @return string 29 | */ 30 | public static function GenerateUrl($email, $userName, $guid) { 31 | $model = new InformationsCompteModel($email, $userName, $guid); 32 | 33 | $json = json_encode($model); 34 | 35 | $url = "http://www.lapresselibre.fr/inscription-partenaire?" 36 | . "user=" . rawurlencode(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, Config::AES_KEY, $json, MCRYPT_MODE_CBC, Config::IV))) 37 | . "&partId=" . Config::PARTENAIRE_ID; 38 | 39 | return $url; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | /** 6 | * @author Bastien Caubet , Luc Raymond 7 | * 8 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | namespace sdk_lpl_mvc5 17 | { 18 | /// 19 | /// A remplacer par les valeurs fournies par l'administration de La Presse Libre 20 | /// 21 | public static class Config 22 | { 23 | /// 24 | /// Clé secrete pour le chiffrage AES Rijndael 256 25 | /// À modifier 26 | /// 27 | public static int PartID => 2; 28 | 29 | /// 30 | /// Vecteur d'initialisation pour le chiffrage AES Rijndael 256 31 | /// À modifier 32 | /// 33 | public static string AESKey => "UKKzV7sxiGx3uc0auKrUO2kJTT2KSCeg"; 34 | 35 | /// 36 | /// Numéro partenaire LPL 37 | /// À modifier 38 | /// 39 | public static string IV => "7405589013321961"; 40 | 41 | /// 42 | /// Code secret pour le hachage du header X-LPL 43 | /// À modifier 44 | /// 45 | public static string CodeSecret => "mGoMuzoX8u"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /php/utils/HeaderUtils.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 5 | * Date: 19/01/2016 6 | * Time: 09:01 7 | * 8 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | class HeaderUtils 17 | { 18 | /** 19 | * Vérifie le contexte de la requête 20 | * Si le header X_CTX est présent, la requête sert à verifier l'état du web-service 21 | * @param $server 22 | * @return bool 23 | */ 24 | public static function IsTestingContext($server) { 25 | return array_key_exists('HTTP_X_CTX', $server); 26 | } 27 | 28 | 29 | /** 30 | * Vérification des informations contenus dans le header 31 | * Permet de valider la transaction après comparaison du hachage SHA1 entre les valeurs contenues dans les headers X-PART et X-TS plus le code secret et la valeur du header X-LPL 32 | * @param $server 33 | * @return bool 34 | */ 35 | public static function CheckHeaders($server) { 36 | if(array_key_exists('HTTP_X_TS', $server) && array_key_exists('HTTP_X_PART', $server) && array_key_exists('HTTP_X_LPL', $server)) { 37 | return sha1($server['HTTP_X_PART'] . "+" . $server['HTTP_X_TS'] . "+" . Config::CODE_SECRET) == $server['HTTP_X_LPL']; 38 | } 39 | return FALSE; 40 | } 41 | } -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Utils/Hash.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Text; 3 | 4 | /** 5 | * @author Bastien Caubet , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | namespace sdk_lpl_mvc5.Utils 16 | { 17 | public class Hash 18 | { 19 | /// 20 | /// Fonction de hashage d'un tableau de byte avec SHA-1 21 | /// 22 | /// 23 | /// 24 | public static string SHA1Hash(byte[] temp) 25 | { 26 | using (SHA1Managed sha1 = new SHA1Managed()) 27 | { 28 | var hash = sha1.ComputeHash(temp); 29 | return ByteArrayToString(hash); 30 | } 31 | } 32 | 33 | /// 34 | /// Converti un tableau de byte en string hexadecimal 35 | /// 36 | /// 37 | /// 38 | public static string ByteArrayToString(byte[] ba) 39 | { 40 | StringBuilder hex = new StringBuilder(ba.Length * 2); 41 | foreach (byte b in ba) 42 | hex.AppendFormat("{0:x2}", b); 43 | return hex.ToString(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /nodejs/utils/AesCrypt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Classe pour le chiffrement AES 3 | * @author Bastien Caubet , Luc Raymond 4 | * 5 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | 12 | var crypto = require("crypto"); 13 | 14 | module.exports = AESCrypt; 15 | 16 | function AESCrypt() { } 17 | 18 | /** 19 | * Chiffrement AES256 20 | * Utilise AES256 pour chiffrer une chaine de caractères et encode en base64 21 | * @param aesKey 22 | * @param iv 23 | * @param data 24 | * @return string 25 | */ 26 | AESCrypt.prototype.rijndael128Encrypt = function (aesKey, iv, data) { 27 | var encipher = crypto.createCipheriv("aes-128-cbc", aesKey, iv); 28 | 29 | var encryptdata = encipher.update(data, "utf8", "base64"); 30 | 31 | encryptdata += encipher.final("base64"); 32 | 33 | return encryptdata; 34 | } 35 | 36 | 37 | /** 38 | * Déchiffrement AES256 39 | * Décode en base64 la chaine de caractères et utilise AES256 pour la déchiffrer 40 | * @param aesKey 41 | * @param iv 42 | * @param data 43 | * @return string 44 | */ 45 | AESCrypt.prototype.rijndael128Decrypt = function (aesKey, iv, data) { 46 | var decipher = crypto.createDecipheriv("aes-128-cbc", aesKey, iv); 47 | 48 | decipher.setAutoPadding(false); 49 | 50 | var decoded = decipher.update(data, "base64", "utf8"); 51 | 52 | decoded += decipher.final("utf8"); 53 | 54 | return decoded; 55 | } 56 | -------------------------------------------------------------------------------- /php/api/MajCompteService.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | require_once "LPLAbstractService.php"; 17 | require_once "../models/MajCompteModel.php"; 18 | 19 | class MajCompteService extends LPLAbstractService 20 | { 21 | /** 22 | * Constructeur 23 | * Appel du constructeur parent LPLAbstractService 24 | * 25 | * @access public 26 | * @param $server : $_SERVER 27 | */ 28 | public function __construct($server) { 29 | parent::__construct($server); 30 | } 31 | 32 | /** 33 | * Obtient les informations déchiffrées envoyé par LPL. 34 | * Déchiffre le json et retourne l'objet correspondant 35 | * 36 | * @access public 37 | * @return CreationCompteModel 38 | * @throws Exception 39 | */ 40 | public function getResult() { 41 | if($this->method == 'PUT') { 42 | $json = parent::decryptRequest($this->file); 43 | return new MajCompteModel($json); 44 | } 45 | 46 | throw new Exception("Invalid Request"); 47 | } 48 | 49 | /** 50 | * Création de la réponse HTTP 51 | * Appel à la méthode héritée de la classe parent LPLAbstractService 52 | * 53 | * @access public 54 | * @param $data 55 | * @param $status 56 | * @return Array 57 | */ 58 | public function createResponse($data, $status = 200) { 59 | return parent::createResponse($data, $status); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /php/api/CreationCompteService.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | require_once "LPLAbstractService.php"; 17 | require_once "../models/CreationCompteModel.php"; 18 | 19 | class CreationCompteService extends LPLAbstractService 20 | { 21 | /** 22 | * Constructeur 23 | * Appel du constructeur parent LPLAbstractService 24 | * 25 | * @access public 26 | * @param $server : $_SERVER 27 | */ 28 | public function __construct($server) { 29 | parent::__construct($server); 30 | } 31 | 32 | /** 33 | * Obtient les informations déchiffrées envoyé par LPL. 34 | * Déchiffre le json et retourne l'objet correspondant 35 | * 36 | * @access public 37 | * @return CreationCompteModel 38 | * @throws Exception 39 | */ 40 | public function getResult() { 41 | if($this->method == 'POST') { 42 | $json = parent::decryptRequest($this->file); 43 | return new CreationCompteModel($json); 44 | } 45 | 46 | throw new Exception("Invalid Request"); 47 | } 48 | 49 | /** 50 | * Création de la réponse HTTP 51 | * Appel à la méthode héritée de la classe parent LPLAbstractService 52 | * 53 | * @access public 54 | * @param $data 55 | * @param $status 56 | * @return Array 57 | */ 58 | public function createResponse($data, $status = 200){ 59 | return parent::createResponse($data, $status); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /php/api/VerificationService.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 6 | * 7 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | require_once "LPLAbstractService.php"; 17 | require_once "../models/VerificationModel.php"; 18 | 19 | class VerificationService extends LPLAbstractService 20 | { 21 | /** 22 | * Constructeur 23 | * Appel du constructeur parent LPLAbstractService 24 | * 25 | * @access public 26 | * @param $server : $_SERVER 27 | */ 28 | public function __construct($server) { 29 | parent::__construct($server); 30 | } 31 | 32 | /** 33 | * Obtient les informations déchiffrées envoyé par LPL. 34 | * Déchiffre le json et retourne l'objet correspondant 35 | * @access public 36 | * @return VerificationModel 37 | * @throws Exception 38 | * @internal param $request 39 | */ 40 | public function getResult() { 41 | if($this->method == 'GET') { 42 | $json = parent::decryptRequest($this->request["crd"]); 43 | return new VerificationModel($json); 44 | } 45 | 46 | throw new Exception("Invalid Request"); 47 | } 48 | 49 | /** 50 | * Création de la réponse HTTP 51 | * Appel à la méthode héritée de la classe parent LPLAbstractService 52 | * @access public 53 | * @param $data 54 | * @param $status 55 | * @return Array 56 | */ 57 | public function createResponse($data, $status = 200) { 58 | return parent::createResponse($data, $status); 59 | } 60 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Filters/CheckHeaderAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Text; 6 | using System.Web.Http.Controllers; 7 | using System.Web.Http.Filters; 8 | using sdk_lpl_mvc5.Utils; 9 | using sdk_lpl_mvc5; 10 | 11 | 12 | /** 13 | * @author Bastien Caubet , Luc Raymond 14 | * 15 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 16 | * 17 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | namespace sdk_lpl_mvc5.Filters 24 | { 25 | [AttributeUsage(AttributeTargets.Method)] 26 | public class CheckHeaderAttribute : AuthorizationFilterAttribute 27 | { 28 | /// 29 | /// Vérification des informations contenus dans le header 30 | /// Permet de valider la transaction après comparaison du hachage SHA1 entre les valeurs contenues dans les headers X-PART et X-TS plus le code secret et la valeur du header X-LPL 31 | /// 32 | /// 33 | public override void OnAuthorization(HttpActionContext actionContext) 34 | { 35 | if (!actionContext.Request.Headers.Contains("X-LPL") || !actionContext.Request.Headers.Contains("X-TS") || 36 | !actionContext.Request.Headers.Contains("X-PART")) HandleUnauthorizedRequest(actionContext); 37 | else 38 | { 39 | string requestHash = actionContext.Request.Headers.GetValues("X-LPL").FirstOrDefault(); 40 | string timeStamp = actionContext.Request.Headers.GetValues("X-TS").FirstOrDefault(); 41 | string partID = actionContext.Request.Headers.GetValues("X-PART").FirstOrDefault(); 42 | 43 | string expectedHash = 44 | Hash.SHA1Hash(Encoding.UTF8.GetBytes(String.Concat(partID, "+", timeStamp, "+", Config.CodeSecret))); 45 | 46 | if (expectedHash != requestHash) 47 | { 48 | HandleUnauthorizedRequest(actionContext); 49 | } 50 | 51 | base.OnAuthorization(actionContext); 52 | } 53 | } 54 | 55 | protected void HandleUnauthorizedRequest(HttpActionContext actionContext) 56 | { 57 | actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /nodejs/utils/Middleware.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Bastien Caubet , Luc Raymond 3 | * 4 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | var config = require("../config"); 11 | var sha1 = require("sha1"); 12 | 13 | /** 14 | * Vérifie le contexte de la requête 15 | * Si le header x-ctx est présent, la requête sert à verifier l'état du web-service 16 | * @param req 17 | * @return bool 18 | */ 19 | exports.IsTestingContext = function(req) { 20 | return req.get("x-ctx") !== undefined; 21 | }; 22 | 23 | 24 | 25 | /** 26 | * Vérification des informations contenus dans le header 27 | * Permet de valider la transaction après comparaison du hachage SHA1 entre les valeurs contenues dans les headers X-PART et X-TS plus le code secret et la valeur du header X-LPL 28 | * @param req 29 | * @param res 30 | * @param next 31 | * @return bool 32 | */ 33 | exports.CheckRequestHeaders = function(req, res, next) { 34 | if (req.get("x-lpl") !== undefined && req.get("x-ts") !== undefined && req.get("x-part") !== undefined) { 35 | var requestHash = req.get("x-lpl"); 36 | var timeStamp = req.get("x-ts"); 37 | var partID = req.get("x-part"); 38 | 39 | var expectedHash = sha1(`${partID}+${timeStamp}+${config.values.CODE_SECRET}`); 40 | 41 | if (expectedHash != requestHash) 42 | res.status(401).end(); 43 | else 44 | next(); 45 | } 46 | 47 | res.status(401).end("Unauthorized"); 48 | }; 49 | 50 | 51 | /** 52 | * Ajout des headers LPL à la réponse 53 | * @param res 54 | * @return 55 | */ 56 | exports.AddResponseHeaders = function(res) { 57 | var timeStamp = Date.now() / 1000 | 0; 58 | 59 | res.set({ 60 | 'X-LPL': sha1(`${config.values.PARTENAIRE_ID}+${timeStamp}+${config.values.CODE_SECRET}`), 61 | 'X-PART': config.values.PARTENAIRE_ID, 62 | 'X-TS': timeStamp, 63 | }); 64 | }; 65 | 66 | 67 | /** 68 | * Récupère le json contenu dans la requête 69 | * Déchiffre la valeur reçu avec AES256 et enlèves les caractères unicodes non supportés 70 | * @param crypt 71 | * @param reqValue 72 | * @return string 73 | */ 74 | exports.GetJsonFromRequest = function(crypt, reqValue) { 75 | var json = crypt.rijndael128Decrypt(config.values.AES_KEY, config.values.IV, reqValue); 76 | json = json.replace(/[\x00-\x1F\x80-\xFF]+/, ""); 77 | return JSON.parse(json); 78 | }; 79 | -------------------------------------------------------------------------------- /python_django/python_django/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for python_django project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.10.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.10/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.10/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '&%g7pvhdawpwghq1!4rjjqgpy*3+2%i^$r=s3n$0)ub(tx%$c$' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | ] 41 | 42 | MIDDLEWARE = [ 43 | 'django.middleware.security.SecurityMiddleware', 44 | 'django.contrib.sessions.middleware.SessionMiddleware', 45 | 'django.middleware.common.CommonMiddleware', 46 | 'django.middleware.csrf.CsrfViewMiddleware', 47 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 48 | 'django.contrib.messages.middleware.MessageMiddleware', 49 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 50 | ] 51 | 52 | ROOT_URLCONF = 'python_django.urls' 53 | 54 | TEMPLATES = [ 55 | { 56 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 57 | 'DIRS': [], 58 | 'APP_DIRS': True, 59 | 'OPTIONS': { 60 | 'context_processors': [ 61 | 'django.template.context_processors.debug', 62 | 'django.template.context_processors.request', 63 | 'django.contrib.auth.context_processors.auth', 64 | 'django.contrib.messages.context_processors.messages', 65 | ], 66 | }, 67 | }, 68 | ] 69 | 70 | WSGI_APPLICATION = 'python_django.wsgi.application' 71 | 72 | 73 | # Database 74 | # https://docs.djangoproject.com/en/1.10/ref/settings/#databases 75 | 76 | DATABASES = { 77 | 'default': { 78 | 'ENGINE': 'django.db.backends.sqlite3', 79 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 80 | } 81 | } 82 | 83 | 84 | # Password validation 85 | # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators 86 | 87 | AUTH_PASSWORD_VALIDATORS = [ 88 | { 89 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 90 | }, 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 99 | }, 100 | ] 101 | 102 | 103 | # Internationalization 104 | # https://docs.djangoproject.com/en/1.10/topics/i18n/ 105 | 106 | LANGUAGE_CODE = 'en-us' 107 | 108 | TIME_ZONE = 'UTC' 109 | 110 | USE_I18N = True 111 | 112 | USE_L10N = True 113 | 114 | USE_TZ = True 115 | 116 | 117 | # Static files (CSS, JavaScript, Images) 118 | # https://docs.djangoproject.com/en/1.10/howto/static-files/ 119 | 120 | STATIC_URL = '/static/' 121 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Controllers/MajCompteController.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Http; 3 | using System.Text; 4 | using System.Web; 5 | using System.Web.Http; 6 | using sdk_lpl_mvc5; 7 | using sdk_lpl_mvc5.Models; 8 | using sdk_lpl_mvc5.Utils; 9 | using sdk_lpl_mvc5.Filters; 10 | 11 | 12 | /** 13 | * @author Bastien Caubet , Luc Raymond 14 | * 15 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 16 | * 17 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | namespace sdk_lpl_mvc5.Controllers 24 | { 25 | /// 26 | /// Ce service a pour but de mettre à jour les comptes utilisateurs sur les plateformes partenaire pour la propagation de l’abonnement à partir des paramètres fourni par LPL. 27 | /// Ce service sera exécuter lors de la reconduite d’un abonnement (si l’utilisateur a reconduit son paiement mensuel). Les données d’entrées fournies par LPL seront sérialisées en JSON dans le body de la requête. 28 | /// 29 | /// Contient les informations de l'utilisateur, cryptées avec AES puis encodé en base64 30 | /// Retourne une chaine de caractère cryptée et encodée contenant les informations de validation 31 | public class MajCompteController : ApiController 32 | { 33 | [HttpPut] 34 | [Route("ws/majCompte")] 35 | [CheckHeader] 36 | public HttpResponseMessage UpdateAccount() 37 | { 38 | var body = Request.Content.ReadAsStringAsync().Result; 39 | 40 | UpdateAccountModel account = 41 | JsonConvert.DeserializeObject(Encrypt.DecryptRJ256(body, 42 | Config.AESKey, Config.IV)); 43 | 44 | // TODO : à modifier 45 | // Ajoutez ici votre logique de verification des donnees en base à partir de l'objet UpdateAccountModel 46 | // Exemple de composition du modele à partir des donnees en base 47 | ValidationResponseModel model = new ValidationResponseModel 48 | { 49 | IsValid = true, 50 | CodeUtilisateur = account.CodeUtilisateur, 51 | PartenaireID = Config.PartID 52 | }; 53 | 54 | string json = Encrypt.EncryptRJ256(JsonConvert.SerializeObject(model), Config.AESKey, Config.IV); 55 | 56 | string timeStampHeader = Timestamp.UnixTimestamp().ToString(); 57 | string concat = string.Concat(Config.PartID.ToString(), "+", timeStampHeader, "+", Config.CodeSecret); 58 | 59 | HttpContext.Current.Response.AddHeader("X-TS", timeStampHeader); 60 | HttpContext.Current.Response.AddHeader("X-PART", Config.PartID.ToString()); 61 | HttpContext.Current.Response.AddHeader("X-LPL", Hash.SHA1Hash(Encoding.UTF8.GetBytes(concat))); 62 | 63 | var resp = new HttpResponseMessage(HttpStatusCode.OK) 64 | { 65 | Content = new StringContent(json, Encoding.UTF8, "text/plain") 66 | }; 67 | 68 | return resp; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Controllers/VerificationController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Text; 6 | using System.Web; 7 | using System.Web.Http; 8 | using Newtonsoft.Json; 9 | using sdk_lpl_mvc5; 10 | using sdk_lpl_mvc5.Models; 11 | using sdk_lpl_mvc5.Utils; 12 | using sdk_lpl_mvc5.Filters; 13 | 14 | 15 | /** 16 | * @author Bastien Caubet , Luc Raymond 17 | * 18 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 19 | * 20 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | namespace sdk_lpl_mvc5.Controllers 27 | { 28 | /// 29 | /// Ce service a pour but de récupérer des informations utilisateur sur une plateforme partenaire à partir de paramètres fourni par LPL. 30 | /// 31 | /// Contient les identifiants de l'utilisateur, cryptés avec AES puis encodés en base64 32 | /// Retourne une chaine de caractère cryptée et encodée contenant les informations de l'utilisateur trouvé 33 | public class VerificationController : ApiController 34 | { 35 | [HttpGet] 36 | [Route("ws/verification")] 37 | [CheckHeader] 38 | public HttpResponseMessage CheckAccountService([FromUri] string crd) 39 | { 40 | VerificationModel obj = 41 | JsonConvert.DeserializeObject(Encrypt.DecryptRJ256(crd, 42 | Config.AESKey, Config.IV)); 43 | 44 | UserInfoModel model = new UserInfoModel {PartenaireID = Config.PartID}; 45 | 46 | if (Request.Headers.Contains("X-CTX")) 47 | { 48 | // Ne pas modifier 49 | model.CreateDummyModel(); 50 | } 51 | else 52 | { 53 | // TODO : à modifier 54 | // Ajoutez ici votre logique de verification des donnees en base a partir de l'objet VerificationModel 55 | // Exemple de composition du modele a partir des donnees en base 56 | model.AccountExist = true; 57 | model.Mail = obj.Mail; 58 | model.CodeUtilisateur = obj.CodeUtilisateur; 59 | } 60 | 61 | string json = Encrypt.EncryptRJ256(JsonConvert.SerializeObject(model), Config.AESKey, 62 | Config.IV); 63 | 64 | string timeStampHeader = Timestamp.UnixTimestamp().ToString(); 65 | string concat = string.Concat(Config.PartID.ToString(), "+", timeStampHeader, "+", Config.CodeSecret); 66 | 67 | HttpContext.Current.Response.AddHeader("X-TS", timeStampHeader); 68 | HttpContext.Current.Response.AddHeader("X-PART", Config.PartID.ToString()); 69 | HttpContext.Current.Response.AddHeader("X-LPL", Hash.SHA1Hash(Encoding.UTF8.GetBytes(concat))); 70 | 71 | var resp = new HttpResponseMessage(HttpStatusCode.OK) 72 | { 73 | Content = new StringContent(json, Encoding.UTF8, "text/plain") 74 | }; 75 | 76 | return resp; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | -------------------------------------------------------------------------------- /python_django/sdk_lpl/views.py: -------------------------------------------------------------------------------- 1 | import json 2 | from datetime import datetime 3 | 4 | from django.http import HttpResponse 5 | from django.utils.decorators import decorator_from_middleware 6 | 7 | from sdk_lpl.config import Config 8 | from sdk_lpl.models.CreationCompteModel import CreationCompteModel 9 | from sdk_lpl.models.MajCompteModel import MajCompteModel 10 | from sdk_lpl.models.UserInfosModel import UserInfoModel 11 | from sdk_lpl.models.ValidationReponseModel import ValidationResponseModel, Codes 12 | from sdk_lpl.models.VerificationModel import VerificationModel 13 | from sdk_lpl.utils.crypt import Crypt 14 | from sdk_lpl.utils.middlewares import is_testing_ctx, LplMiddleware 15 | 16 | 17 | @decorator_from_middleware(LplMiddleware) 18 | def verification(request): 19 | """ 20 | Web-service de vérification 21 | :param request: 22 | :return: 23 | """ 24 | 25 | crypt = Crypt(Config.aes_key, Config.iv) 26 | model = UserInfoModel() 27 | 28 | if is_testing_ctx(request): 29 | model.create_dummy_model() 30 | else: 31 | json_val = crypt.aes_decrypt(request.GET.get('crd', '')) 32 | j = json.loads(json_val) 33 | v_model = VerificationModel(j['Password'], j['Mail'], j['CodeUtilisateur']) 34 | 35 | """ 36 | TODO : à modifier 37 | Ajoutez ici votre logique de verification des donnees en base à partir de l'objet c_model 38 | Exemple de composition du modele à partir des donnees en base 39 | """ 40 | model.PartenaireID = Config.partenaire_id 41 | model.Mail = "testabo@gmail.com" 42 | model.CodeUtilisateur = "123123-1231-123-12311" 43 | model.AccountExist = True 44 | model.TypeAbonnement = "mensuel" 45 | model.DateExpiration = datetime.now().isoformat() 46 | model.DateSouscription = datetime.now().isoformat() 47 | 48 | response = crypt.aes_encrypt(json.dumps(model.__dict__)) 49 | return HttpResponse(response, content_type="application/json") 50 | 51 | 52 | @decorator_from_middleware(LplMiddleware) 53 | def propagation(request): 54 | """ 55 | Web-service de création de compte 56 | :param request: 57 | :return: 58 | """ 59 | 60 | crypt = Crypt(Config.aes_key, Config.iv) 61 | model = ValidationResponseModel() 62 | 63 | if is_testing_ctx(request): 64 | model.create_dummy_model() 65 | else: 66 | json_val = crypt.aes_decrypt(request.body) 67 | j = json.loads(json_val) 68 | c_model = CreationCompteModel(j['CodeUtilisateur'], j['Pseudo'], j['Mail'], j['Password'], j['TypeAbonnement'], j['DateSouscription'], j['DateExpiration'], j['Tarif'], j['Statut']) 69 | 70 | 71 | """ 72 | TODO : à modifier 73 | Ajoutez ici votre logique de verification des donnees en base à partir de l'objet c_model 74 | Exemple de composition du modele à partir des donnees en base 75 | """ 76 | model.PartenaireID = Config.partenaire_id 77 | model.CodeUtilisateur = c_model.CodeUtilisateur 78 | model.IsValid = True 79 | model.CodeEtat = Codes.Success 80 | 81 | response = crypt.aes_encrypt(json.dumps(model.__dict__)) 82 | return HttpResponse(response, content_type="application/json") 83 | 84 | 85 | @decorator_from_middleware(LplMiddleware) 86 | def update(request): 87 | """ 88 | Web-service de mise à jour de compte 89 | :param request: 90 | :return: 91 | """ 92 | crypt = Crypt(Config.aes_key, Config.iv) 93 | model = ValidationResponseModel() 94 | 95 | json_val = crypt.aes_decrypt(request.body) 96 | j = json.loads(json_val) 97 | maj_model = MajCompteModel(j['CodeUtilisateur'], j['TypeAbonnement'], j['DateSouscription'], j['DateExpiration'], j['Tarif'], j['Statut']) 98 | 99 | """ 100 | TODO : à modifier 101 | Ajoutez ici votre logique de verification des donnees en base à partir de l'objet maj_model 102 | Exemple de composition du modele à partir des donnees en base 103 | """ 104 | model.PartenaireID = Config.partenaire_id 105 | model.CodeUtilisateur = maj_model.CodeUtilisateur 106 | model.IsValid = True 107 | model.CodeEtat = Codes.Success 108 | 109 | response = crypt.aes_encrypt(json.dumps(model.__dict__)) 110 | return HttpResponse(response, content_type="application/json") -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Controllers/CreationCompteController.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Http; 3 | using System.Text; 4 | using System.Web; 5 | using System.Web.Http; 6 | using Newtonsoft.Json; 7 | using sdk_lpl_mvc5; 8 | using sdk_lpl_mvc5.Models; 9 | using sdk_lpl_mvc5.Utils; 10 | using sdk_lpl_mvc5.Filters; 11 | 12 | /** 13 | * @author Bastien Caubet , Luc Raymond 14 | * 15 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 16 | * 17 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | namespace sdk_lpl_mvc5.Controllers 24 | { 25 | /// 26 | /// Ce service a pour but de de fournir des informations concernant un utilisateur à la plateforme partenaire pour qu’elle puisse lui créer un compte et propager son abonnement. 27 | /// À noter que ce service est exécuté après la création du compte sur la plateforme LPL (qui s’effectue après que l’utilisateur ait souscrit et payé son abonnement). Les données d’entrées fournies par LPL seront sérialisées en JSON dans le body de la requête. 28 | /// 29 | /// Contient les informations de l'utilisateur, cryptées avec AES puis encodé en base64 30 | /// Retourne une chaine de caractère cryptée et encodée contenant les informations de validation 31 | public class CreationCompteController : ApiController 32 | { 33 | [HttpPost] 34 | [Route("ws/creationCompte")] 35 | [CheckHeader] 36 | public HttpResponseMessage CreateAccountService() 37 | { 38 | var body = Request.Content.ReadAsStringAsync().Result; 39 | 40 | CreationCompteModel compte = 41 | JsonConvert.DeserializeObject(Encrypt.DecryptRJ256(body, 42 | Config.AESKey, Config.IV)); 43 | 44 | ValidationResponseModel model = new ValidationResponseModel { PartenaireID = Config.PartID }; 45 | 46 | if (Request.Headers.Contains("X-CTX")) 47 | { 48 | // Ne pas modifier 49 | model.CreateDummyModel(); 50 | } 51 | else 52 | { 53 | // TODO : à modifier 54 | // Ajoutez ici votre logique de verification des donnees en base a partir de l'objet CreationCompteModel 55 | // Exemple de composition du modele a partir des donnees en base 56 | model.IsValid = true; 57 | model.PartenaireID = Config.PartID; 58 | model.CodeUtilisateur = compte.CodeUtilisateur; 59 | model.CodeEtat = Etat.Success; 60 | } 61 | 62 | string json = Encrypt.EncryptRJ256(JsonConvert.SerializeObject(model), Config.AESKey, Config.IV); 63 | 64 | string timeStampHeader = Timestamp.UnixTimestamp().ToString(); 65 | string concat = string.Concat(Config.PartID.ToString(), "+", timeStampHeader, "+", Config.CodeSecret); 66 | 67 | HttpContext.Current.Response.AddHeader("X-TS", timeStampHeader); 68 | HttpContext.Current.Response.AddHeader("X-PART", Config.PartID.ToString()); 69 | HttpContext.Current.Response.AddHeader("X-LPL", Hash.SHA1Hash(Encoding.UTF8.GetBytes(concat))); 70 | 71 | var resp = new HttpResponseMessage(HttpStatusCode.OK) 72 | { 73 | Content = new StringContent(json, Encoding.UTF8, "text/plain") 74 | }; 75 | 76 | return resp; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /asp.net/sdk-lpl-mvc5/sdk-lpl-mvc5/Utils/Encrypt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | using System.Text; 5 | 6 | /** 7 | * @author Bastien Caubet , Luc Raymond 8 | * 9 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | */ 17 | namespace sdk_lpl_mvc5.Utils 18 | { 19 | public static class Encrypt 20 | { 21 | /// 22 | /// Chiffre une chaine de caractères à l'aide de Rijndael 256 (AES 256) 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | static public string EncryptRJ256(string plainText, string keyString, string ivString) 29 | { 30 | string sRet; 31 | 32 | var encoding = new UTF8Encoding(); 33 | var key = encoding.GetBytes(keyString); 34 | var iv = encoding.GetBytes(ivString); 35 | 36 | using (var rj = new RijndaelManaged()) 37 | { 38 | try 39 | { 40 | rj.Padding = PaddingMode.Zeros; 41 | rj.Mode = CipherMode.CBC; 42 | rj.KeySize = 256; 43 | rj.BlockSize = 128; 44 | rj.Key = key; 45 | rj.IV = iv; 46 | 47 | var ms = new MemoryStream(); 48 | 49 | using (var cs = new CryptoStream(ms, rj.CreateEncryptor(key, iv), CryptoStreamMode.Write)) 50 | { 51 | using (var sw = new StreamWriter(cs)) 52 | { 53 | sw.Write(plainText); 54 | } 55 | sRet = Convert.ToBase64String(ms.ToArray()); 56 | } 57 | } 58 | finally 59 | { 60 | rj.Clear(); 61 | } 62 | } 63 | 64 | return sRet; 65 | } 66 | 67 | /// 68 | /// Déchiffre une chaine de caractères à l'aide de Rijndael 256 (AES 256) 69 | /// 70 | /// 71 | /// 72 | /// 73 | /// 74 | static public string DecryptRJ256(string cypherText, string keyString, string ivString) 75 | { 76 | string sRet; 77 | 78 | byte[] cypher = Convert.FromBase64String(cypherText); 79 | 80 | var encoding = new UTF8Encoding(); 81 | var key = encoding.GetBytes(keyString); 82 | var iv = encoding.GetBytes(ivString); 83 | 84 | using (var rj = new RijndaelManaged()) 85 | { 86 | try 87 | { 88 | rj.Padding = PaddingMode.Zeros; 89 | rj.Mode = CipherMode.CBC; 90 | rj.KeySize = 256; 91 | rj.BlockSize = 128; 92 | rj.Key = key; 93 | rj.IV = iv; 94 | 95 | var ms = new MemoryStream(cypher); 96 | 97 | using (var cs = new CryptoStream(ms, rj.CreateDecryptor(key, iv), CryptoStreamMode.Read)) 98 | { 99 | using (var sr = new StreamReader(cs)) 100 | { 101 | sRet = sr.ReadLine(); 102 | } 103 | } 104 | } 105 | finally 106 | { 107 | rj.Clear(); 108 | } 109 | } 110 | 111 | return sRet; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /nodejs/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Bastien Caubet , Luc Raymond 3 | * 4 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | */ 9 | 10 | var express = require("express"); 11 | var bodyParser = require('body-parser'); 12 | var errorHandler = require('errorhandler'); 13 | 14 | var config = require("./config"); 15 | var AESCrypt = require("./utils/AesCrypt"); 16 | var LPLMiddleware = require("./utils/Middleware"); 17 | var InscriptionPartenaire = require("./utils/InscriptionPartenaire"); 18 | 19 | 20 | var VerifModel = require("./models/VerificationModel"); 21 | var CreaModel = require("./models/CreationCompteModel"); 22 | var UserInfosModel = require("./models/UserInfosModel"); 23 | var ValidResModel = require("./models/ValidationReponseModel").ValidationModel; 24 | var Etat = require("./models/ValidationReponseModel").Etat; 25 | var MajModel = require("./models/MajCompteModel"); 26 | 27 | 28 | 29 | var app = express(); 30 | app.set('port', process.env.PORT || 8888); 31 | app.use(bodyParser.text()); 32 | 33 | if(app.get("env") == "development") { 34 | app.use(errorHandler()); 35 | 36 | app.use(function (req, res, next) { 37 | next(); 38 | }); 39 | } 40 | 41 | 42 | /** 43 | * Exemple de la génération d'une url pour l'inscription partenaire 44 | */ 45 | app.get("/inscription-partenaire", function (req, res) { 46 | res.setHeader("Content-Type", "text/plain"); 47 | res.end(InscriptionPartenaire.GenerateUrl("toto@gmail.com", "tata")); 48 | }); 49 | 50 | 51 | /** 52 | * Web-service de vérification 53 | */ 54 | app.get("/ws/verification", LPLMiddleware.CheckRequestHeaders, function (req, res) { 55 | var model = new UserInfosModel(); 56 | var crypt = new AESCrypt(); 57 | 58 | if(LPLMiddleware.IsTestingContext(req)) { 59 | // Ne pas modifier 60 | model.CreateDummyModel(); 61 | } else { 62 | var json = LPLMiddleware.GetJsonFromRequest(crypt, req.query.crd); 63 | 64 | var vModel = new VerifModel(json); 65 | 66 | // TODO : à modifier 67 | // Ajoutez ici votre logique de verification des donnees en base à partir de l'objet vModel 68 | // Exemple de composition du modele à partir des donnees en base 69 | model.Mail = "testabo@gmail.com"; 70 | model.CodeUtilisateur = "123123-1231-123-12311"; 71 | model.AccountExist = true; 72 | model.PartenaireID = config.values.PARTENAIRE_ID; 73 | model.TypeAbonnement = "Mensuel"; 74 | model.DateExpiration = new Date(); 75 | model.DateSouscription = new Date(); 76 | } 77 | 78 | var response = crypt.rijndael256Encrypt(config.values.AES_KEY, config.values.IV, JSON.stringify(model)); 79 | 80 | LPLMiddleware.AddResponseHeaders(res); 81 | 82 | res.status(200).end(response); 83 | }); 84 | 85 | 86 | /** 87 | * Web-service de création de compte 88 | */ 89 | app.post("/ws/creationCompte", LPLMiddleware.CheckRequestHeaders, function(req, res) { 90 | var crypt = new AESCrypt(); 91 | var model = new ValidResModel(); 92 | 93 | if(LPLMiddleware.IsTestingContext(req)) { 94 | // Ne pas modifier 95 | model.CreateDummyModel(); 96 | } else { 97 | var json = LPLMiddleware.GetJsonFromRequest(crypt, req.body); 98 | 99 | var cModel = new CreaModel(json); 100 | 101 | // TODO : à modifier 102 | // Ajoutez ici votre logique de verification des donnees en base a partir de l'objet cModel 103 | // Exemple de composition du modele a partir des donnees en base 104 | model.PartenaireID = config.values.PARTENAIRE_ID; 105 | model.CodeUtilisateur = cModel.CodeUtilisateur; 106 | model.IsValid = true; 107 | model.CodeEtat = Etat.Success; 108 | } 109 | 110 | var response = crypt.rijndael256Encrypt(config.values.AES_KEY, config.values.IV, JSON.stringify(model)); 111 | 112 | LPLMiddleware.AddResponseHeaders(res); 113 | 114 | res.status(200).end(response); 115 | }); 116 | 117 | 118 | app.put("/ws/majCompte", LPLMiddleware.CheckRequestHeaders, function(req, res) { 119 | var crypt = new AESCrypt(); 120 | var model = new ValidResModel(); 121 | 122 | var json = LPLMiddleware.GetJsonFromRequest(crypt, req.body); 123 | 124 | var majModel = new MajModel(json); 125 | 126 | // TODO : à modifier 127 | // Ajoutez ici votre logique de verification des donnees en base a partir de l'objet majModel 128 | // Exemple de composition du modele a partir des donnees en base 129 | model.PartenaireID = config.values.PARTENAIRE_ID; 130 | model.CodeUtilisateur = majModel.CodeUtilisateur; 131 | model.IsValid = true; 132 | model.CodeEtat = Etat.Success; 133 | 134 | var response = crypt.rijndael256Encrypt(config.values.AES_KEY, config.values.IV, JSON.stringify(model)); 135 | 136 | LPLMiddleware.AddResponseHeaders(res); 137 | 138 | res.status(200).end(response); 139 | }); 140 | 141 | 142 | app.listen(app.get('port'), function(){ 143 | console.log('Express server listening on port ' + app.get('port')); 144 | }); -------------------------------------------------------------------------------- /php/api/LPLAbstractService.php: -------------------------------------------------------------------------------- 1 | , Luc Raymond 7 | * 8 | * The MIT License (MIT) Copyright (c) 2016 INpact Mediagroup 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | require_once "../Config.php"; 18 | require_once "../utils/HeaderUtils.php"; 19 | 20 | abstract class LPLAbstractService 21 | { 22 | /** 23 | * Méthode HTTP de la requête 24 | * @var string 25 | * @access protected 26 | */ 27 | protected $method; 28 | 29 | /** 30 | * Données stockées dans la requête 31 | * @var array 32 | * @access protected 33 | */ 34 | protected $request; 35 | 36 | /** 37 | * Données stockées dans une requête PUT 38 | * @var array 39 | * @access protected 40 | */ 41 | public $file; 42 | 43 | /** 44 | * Constructeur 45 | * Récupère la requête serveur, vérifie si les headers LPL sont présents et valides 46 | * Vérifie le type de méthode associée à la requête 47 | * Récupère les informations en fonction de la méthode 48 | * @access public 49 | * @param $server : $_SERVER 50 | * @throws Exception 51 | */ 52 | public function __construct($server) { 53 | header("Access-Control-Allow-Orgin: *"); 54 | header("Access-Control-Allow-Methods: *"); 55 | header("Content-Type: application/json"); 56 | 57 | if(HeaderUtils::CheckHeaders($server)) { 58 | $this->method = $server['REQUEST_METHOD']; 59 | if ($this->method == 'POST' && array_key_exists('HTTP_X_HTTP_METHOD', $server)) { 60 | if ($server['HTTP_X_HTTP_METHOD'] == 'DELETE') { 61 | $this->method = 'DELETE'; 62 | } else if ($server['HTTP_X_HTTP_METHOD'] == 'PUT') { 63 | $this->method = 'PUT'; 64 | } else { 65 | throw new Exception("Unexpected Header"); 66 | } 67 | } 68 | 69 | switch($this->method) { 70 | case 'DELETE': 71 | case 'POST': 72 | $this->request = $this->_cleanInputs($_GET); 73 | $this->file = file_get_contents("php://input"); 74 | break; 75 | case 'GET': 76 | $this->request = $this->_cleanInputs($_GET); 77 | break; 78 | case 'PUT': 79 | $this->request = $this->_cleanInputs($_GET); 80 | $this->file = file_get_contents("php://input"); 81 | break; 82 | default: 83 | $this->createResponse('Invalid Method', 405); 84 | break; 85 | } 86 | } else { 87 | throw new Exception("Unauthorized"); 88 | } 89 | } 90 | 91 | 92 | /** 93 | * Récupération des informations de la requête 94 | * Création d'un array contenant les informations de la requête 95 | * @access private 96 | * @param $data 97 | * @return Array 98 | */ 99 | private function _cleanInputs($data) { 100 | $clean_input = Array(); 101 | if (is_array($data)) { 102 | foreach ($data as $k => $v) { 103 | $clean_input[$k] = $this->_cleanInputs($v); 104 | } 105 | } else { 106 | $clean_input = trim(strip_tags($data)); 107 | } 108 | return $clean_input; 109 | } 110 | 111 | /** 112 | * Déchiffre le paramètre URL ou le body de la requête LPL 113 | * Decode en base64, déchiffre l'AES et décode en json la chaîne de caractère envoyée 114 | * @access protected 115 | * @param $param : string 116 | * @return Array 117 | */ 118 | protected function decryptRequest($param) { 119 | $raw = base64_decode($param); 120 | $rawJson = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, Config::AES_KEY, $raw, MCRYPT_MODE_CBC, Config::IV), "\0\4"); 121 | return json_decode($rawJson, TRUE); 122 | } 123 | 124 | /** 125 | * Création de la réponse HTTP 126 | * Ajout des headers, chiffrage AES, encodage Json 127 | * @access protected 128 | * @param $data 129 | * @param $status 130 | * @return string 131 | */ 132 | protected function createResponse($data, $status = 200) { 133 | header("HTTP/1.1 " . $status . " " . $this->_requestStatus($status)); 134 | 135 | if($status == 200) { 136 | header("X-LPL: " . sha1(Config::PARTENAIRE_ID . "+" . time() . "+" . Config::CODE_SECRET)); 137 | header("X-PART: " . Config::PARTENAIRE_ID); 138 | header("X-TS: " . time()); 139 | $response = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, Config::AES_KEY, json_encode($data), MCRYPT_MODE_CBC, Config::IV)); 140 | } else { 141 | $response = $data; 142 | } 143 | 144 | return $response; 145 | } 146 | 147 | /** 148 | * Retourne le code de statut de la requête 149 | * @access private 150 | * @param $code 151 | * @return string 152 | * @internal param $data 153 | */ 154 | private function _requestStatus($code) { 155 | $status = array( 156 | 200 => 'OK', 157 | 401 => 'Not Authorized', 158 | 404 => 'Not Found', 159 | 405 => 'Method Not Allowed', 160 | 500 => 'Internal Server Error', 161 | ); 162 | return ($status[$code]) ? $status[$code] : $status[500]; 163 | } 164 | } -------------------------------------------------------------------------------- /python_django/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 62 | 63 | 64 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 103 | 104 | 105 | 106 | 109 | 110 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 139 | 140 | 151 | 152 | 170 | 171 | 189 | 190 | 210 | 211 | 232 | 233 | 256 | 257 | 258 | 260 | 261 | 262 | 263 | 1476362699298 264 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 297 | 300 | 301 | 302 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | --------------------------------------------------------------------------------