From 98c5bd4436120f2ac752d1bd7cbf18491b2a7d98 Mon Sep 17 00:00:00 2001
From: Benjamin Renard <benjamin.renard@akka.eu>
Date: Thu, 9 Jul 2020 14:07:11 +0200
Subject: [PATCH] Introduce anonymous user for WS (ie. impex user)

---
 php/WebServices/WebServer.php | 22 +++++++++++-----------
 php/classes/AmdaAction.php    |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/php/WebServices/WebServer.php b/php/WebServices/WebServer.php
index b33439a..6ef6f0a 100644
--- a/php/WebServices/WebServer.php
+++ b/php/WebServices/WebServer.php
@@ -24,7 +24,7 @@ class WebServer
 		$this->requestTime = date('Ymd',time());
 		
 		if (!isset($data)) {
-			$this->userID  = 'impex';
+			$this->userID  = WSConfigClass::getAnonymousUserName();
 			return array('success' => true);
 		}
 		
@@ -41,7 +41,7 @@ class WebServer
 			IHMConfigClass::setUserName($this->userID);
 		}
 		else {
-			$this->userID  = 'impex';
+			$this->userID  = WSConfigClass::getAnonymousUserName();
 		}
 		
 		$this->sessionID = $this->userID;
@@ -49,7 +49,7 @@ class WebServer
 		if (isset($vars['password']))
 			$this->userPWD = $vars['password'];
 		else 
-			$this->userPWD = 'impexfp7';
+			$this->userPWD = WSConfigClass::getAnonymousUserPwd();
 		
 		return array('success' => true, 'vars' => $vars);
 	}
@@ -116,14 +116,14 @@ class WebServer
 	}
 	
 /*
-*  get user TimeTables list; Shared for impex
+*  get user TimeTables list; Shared for anonymous user ('impex')
 */
 	private function getTimeTablesCatalogsList($object) 
 	{
 		$this->initUserMgr();
 		$dom = new DOMDocument("1.0");
 		
-		if ($this->userID == 'impex') {
+		if ($this->userID == WSConfigClass::getAnonymousUserName()) {
 			$sharedObjMgr = new SharedObjectsMgr();
 			if (!@$dom->load($sharedObjMgr->getTreeFilePath()))
 					$this->throwError("workspaceError", "Workspace Error : Cannot load Shared TimeTable list");
@@ -337,7 +337,7 @@ error_log($path);
 	}
 	
 /*
-*   public data only : user impex
+*   public data only : anonymous user (impex)
 */
 	public function getObsDataTree() 
 	{         
@@ -455,7 +455,7 @@ error_log("BRE =============================> getParameter");
 	}
 	
 /*
-*  get user Catalogs list; Shared for impex
+*  get user Catalogs list; Shared for anonymous user (impex)
 */
 	public function getCatalogsList($data) 
 	{
@@ -465,7 +465,7 @@ error_log("BRE =============================> getParameter");
 	}
 
 /*
-*  get user TimeTables list; Shared for impex
+*  get user TimeTables list; Shared for anonymous user (impex)
 */
 	public function getTimeTablesList($data) 
 	{
@@ -635,7 +635,7 @@ error_log("BRE =============================> getParameter");
 *    TODO Can be done by TTCONVERT function of AMDA_Kernel - more hard !!!
 *    TODO Think about this if merge/union will be also done by AMDA_Kernel
 *
-*    get Time Table : shared for impex ; user' for user
+*    get Time Table : shared for anonymous user (impex) ; user' for user
 */
 	public function getTimeTable($data) 
 	{
@@ -649,7 +649,7 @@ error_log("BRE =============================> getParameter");
 		
 		$ttID = $res['vars']['ttID'];
 
-		if ($this->userID == 'impex') {
+		if ($this->userID == WSConfigClass::getAnonymousUserName()) {
 			$sharedObjMgr = new SharedObjectsMgr();
 			$ttSrc = $sharedObjMgr->getDataFilePath('timeTable', $ttID);
 		}
@@ -764,7 +764,7 @@ error_log("BRE =============================> getParameter");
 	 
 		$resultFilePrefix = strtolower(__FUNCTION__)."_".$mission."_".date("YmdHms",strtotime($vars["startTime"]))."_".date("YmdHms",strtotime($vars["stopTime"]));
 		
-		if ($this->userID != "impex") 
+		if ($this->userID != WSConfigClass::getAnonymousUserName()) 
 			$resultFilePrefix .= "_".$this->userID;
 
 		$dom = new DomDocument("1.0");
diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php
index 53d9fd8..cfd504d 100644
--- a/php/classes/AmdaAction.php
+++ b/php/classes/AmdaAction.php
@@ -948,7 +948,7 @@ class AmdaAction
 			return array('success' => false, 'message' => 'ddLogin error: '.$res);
 		}
 
-		if ($dd->user == 'impex')
+		if ($dd->user == WSConfigClass::getAnonymousUserName())
 		{
 			//if ($dd->getWsSize() > DISK_QUOTA * 100)
 			//	error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu');
--
libgit2 0.21.2