diff --git a/php/classes/AmdaClient.php b/php/classes/AmdaClient.php index 15f9907..58499cd 100644 --- a/php/classes/AmdaClient.php +++ b/php/classes/AmdaClient.php @@ -28,6 +28,10 @@ class AmdaClient { date_default_timezone_set('UTC'); } + public function base64url_encode($data) { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); + } + /* Just copy URL to Info/Bases.xml */ public function getAvailableExternalBases() { try { @@ -230,13 +234,40 @@ class AmdaClient { /* Get user info from login */ public function getUserInfo($login) { try { - $info = $this->client->getUserInfo($login,md5(DDSERVICE_PRIVATEKEY.$login.'getUserInfo')); + $data_array = array( + "login" => $login, + "timestamp" => time(), + ); + $data = $this->base64url_encode(json_encode($data_array)); + $check = md5($data.DDSERVICE_PUBLICKEY.DDSERVICE_PRIVATEKEY); + $info = $this->client->getUserInfo($data,DDSERVICE_PUBLICKEY,$check); } catch (SoapFault $exception) { return array('success' => false, 'message' => $exception->faultstring); } return $info; } + + /* Create a new user */ + public function createUser($login, $pwd, $first_name, $last_name, $email) { + $result = FALSE; + try { + $data_array = array( + "login" => $login, + "pwd" => $pwd, + "first_name" => $first_name, + "last_name" => $last_name, + "email" => $email, + "timestamp" => time(), + ); + $data = $this->base64url_encode(json_encode($data_array)); + $check = md5($data.DDSERVICE_PUBLICKEY.DDSERVICE_PRIVATEKEY); + $result = $this->client->createUser($data,DDSERVICE_PUBLICKEY,$check); + } + catch (SoapFault $exception) { + } + return $result; + } /* Get data set info */ // public function getInfo($viID, $infoID) { diff --git a/php/config.php b/php/config.php index 2791769..0680790 100644 --- a/php/config.php +++ b/php/config.php @@ -48,8 +48,6 @@ define("MaxGuestTimeInterval", 10); // days define('DISK_QUOTA_standard', 1024*1024*200); // 200MB // max lines of uploaded ascii file to show define('MAX_FILE_INDEX_TO_SHOW', 100); -// private key used to be considerate as a trust client for some functions of DD web service -define('DDSERVICE_PRIVATEKEY', '!%p856Dc'); // EPN-TAP services define('EPNTAP_APIS', 'http://voparis-tap.obspm.fr/__system__/tap/run/tap/sync'); -- libgit2 0.21.2