summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-17 17:33:29 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-17 17:33:29 +0100
commitf90968d920f236faa5419aaf6ef189a120129703 (patch)
treef621b461a5b305952806f51d5855a4e8a44246c8 /server
parent6f1dd0cabf5680b1ad9e6a42ba3f24ac471ae853 (diff)
parent5ac2313bea3f186acdeeb8594542a3702e3dc305 (diff)
Merge branch 'develop' of github.com:manzerbredes/istic-openstack into develop
Diffstat (limited to 'server')
-rwxr-xr-x[-rw-r--r--]server/core/Identity.php188
-rw-r--r--server/core/LibOverride/genTokenOptions.php115
-rw-r--r--server/core/LibOverride/projectTokenData/demo1
-rwxr-xr-x[-rw-r--r--]server/init.php2
4 files changed, 150 insertions, 156 deletions
diff --git a/server/core/Identity.php b/server/core/Identity.php
index 00199ec..2638985 100644..100755
--- a/server/core/Identity.php
+++ b/server/core/Identity.php
@@ -25,9 +25,6 @@ class identity implements Core{
/** @var OpenStack\Identity $libClass protected, contains the library Identity object */
protected $libClass;
-
- /** @var array $actions protected, contains the functions which can be call by the front-end */
- protected $actions = array();
/**
* identity constructor
@@ -44,10 +41,20 @@ class identity implements Core{
$this->libClass = $app->getLibClass("Identity");
}
-
- $credentials = array();
/**
+ * Execute an action
+ *
+ * @param String $action name of another function of this class
+ *
+ * @return void
+ */
+ public function action($action){
+
+ $this->{$action.""}();
+
+ }
+ /**
* Add a credential for the given user/project.
*
* Create a secret/access pair for use with ec2 style auth.
@@ -60,7 +67,7 @@ class identity implements Core{
*
* @return void
*/
- $credentials["addCredential"] = function(){
+ private function addCredential(){
$blob = $this->app->getPostParam("blob");
$projectId = $this->app->getPostParam("projectId");
@@ -96,7 +103,7 @@ class identity implements Core{
*
* @return void
*/
- $credentials["listCredentials"] = function(){
+ private function listCredentials(){
try{
$this->libClass->listCredentials()
@@ -122,7 +129,7 @@ class identity implements Core{
*
* @return void
*/
- $credentials["showCredential"] = function(){
+ private function showCredential(){
$credentId = $this->app->getPostParam("credentialId");
if(!isset($credentId)){
@@ -157,7 +164,7 @@ class identity implements Core{
*
* @return void
*/
- $credentials["updateCredential"] = function(){
+ private function updateCredential(){
$credentId = $this->app->getPostParam("credentialId");
$blob = $this->app->getPostParam("blob");
@@ -197,7 +204,7 @@ class identity implements Core{
*
* @return void
*/
- $credentials["deleteCredential"] = function(){
+ private function deleteCredential(){
$credentId = $this->app->getPostParam("credentialId");
@@ -223,8 +230,6 @@ class identity implements Core{
}
}-
- $domains = array();
-
/**
* Add a domain to an OpenStack instance.
*
@@ -234,7 +239,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["addDomain"] = function(){
+ private function addDomain(){
$description = $this->app->getPostParam("desc");
$enabled = $this->app->getPostParam("enabled");
@@ -277,7 +282,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["listDomains"] = function(){
+ private function listDomains(){
try{
@@ -304,7 +309,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["showDomain"] = function(){
+ private function showDomain(){
$domId = $this->app->getPostParam("domainId");
@@ -340,7 +345,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["updateDomain"] = function(){
+ private function updateDomain(){
$domId = $this->app->getPostParam("domainId");
$description = $this->app->getPostParam("desc");
@@ -386,7 +391,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["deleteDomain"] = function(){
+ private function deleteDomain(){
$domId = $this->app->getPostParam("domainId");
@@ -419,7 +424,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["listRolesDomainUser"] = function(){
+ private function listRolesDomainUser(){
$domId = $this->app->getPostParam("domainId");
$userId = $this->app->getPostParam("userId");
@@ -454,7 +459,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["grantRoleDomainUser"] = function(){
+ private function grantRoleDomainUser(){
$domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId");
@@ -492,7 +497,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["checkRoleDomainUser"] = function(){
+ private function checkRoleDomainUser(){
$domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId");
@@ -531,7 +536,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["revokeRoleDomainUser"] = function(){
+ private function revokeRoleDomainUser(){
$domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId");
@@ -569,7 +574,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["listRolesDomainGroup"] = function(){
+ private function listRolesDomainGroup(){
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
@@ -604,7 +609,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["grantRoleDomainGroup"] = function(){
+ private function grantRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId");
@@ -642,7 +647,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["checkRoleDomainGroup"] = function(){
+ private function checkRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId");
@@ -687,7 +692,7 @@ class identity implements Core{
*
* @return void
*/
- $domains["revokeRoleDomainGroup"] = function(){
+ private function revokeRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId");
@@ -719,8 +724,6 @@ class identity implements Core{
}
}
- $endpoints = array();
-
/**
* Add an endpoint to the Openstack instance
*
@@ -728,7 +731,7 @@ class identity implements Core{
*
* @return void
*/
- $endpoints["addEndpoint"] = function(){
+ private function addEndpoint(){
$servId = $this->app->getPostParam("serviceId");
$name = $this->app->getPostParam("name");
$region = $this->app->getPostParam("region");
@@ -768,7 +771,7 @@ class identity implements Core{
*
* @return void
*/
- $endpoints["getEndpoint"] = function(){
+ private function getEndpoint(){
$endId = $this->app->getPostParam("endpointId");
@@ -798,7 +801,7 @@ class identity implements Core{
*
* @return void
*/
- $endpoints["listEndpoints"] = function(){
+ private function listEndpoints(){
try{
@@ -824,7 +827,7 @@ class identity implements Core{
*
* @return void
*/
- $endpoints["updateEndpoint"] = function(){
+ private function updateEndpoint(){
//Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId");
@@ -863,7 +866,7 @@ class identity implements Core{
*
* @return void
*/
- $endpoints["deleteEndpoint"] = function(){
+ private function deleteEndpoint(){
$endId = $this->app->getPostParam("endpointId");
if(!isset($endId)){
@@ -888,8 +891,6 @@ class identity implements Core{
}
}
- $groups = array();
-
/**
* Add a group.
*
@@ -897,7 +898,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["addGroup"] = function(){
+ private function addGroup(){
//Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId");
@@ -930,7 +931,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["listGroups"] = function(){
+ private function listGroups(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
@@ -963,7 +964,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["showGroup"] = function(){
+ private function showGroup(){
//Not Implemented Yet
/*
@@ -997,7 +998,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["updateGroup"] = function(){
+ private function updateGroup(){
//Todo Argument Optional
$groupId = $this->app->getPostParam("groupId");
$description = $this->app->getPostParam("description");
@@ -1038,7 +1039,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["deleteGroup"] = function(){
+ private function deleteGroup(){
$groupId = $this->app->getPostParam("groupId");
@@ -1072,7 +1073,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["listGroupUsers"] = function(){
+ private function listGroupUsers(){
$groupId = $this->app->getPostParam("groupId");
@@ -1106,7 +1107,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["addGroupUser"] = function(){
+ private function addGroupUser(){
$userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId");
@@ -1141,7 +1142,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["removeGroupUser"] = function(){
+ private function removeGroupUser(){
$userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId");
@@ -1176,7 +1177,7 @@ class identity implements Core{
*
* @return void
*/
- $groups["checkGroupUser"] = function(){
+ private function checkGroupUser(){
$userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId");
@@ -1204,8 +1205,6 @@ class identity implements Core{
}
}
- $policies = array();
-
/**
* @todo
*
@@ -1213,7 +1212,7 @@ class identity implements Core{
*
* @return void
*/
- $policies["addPolicies"] = function(){
+ private function addPolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
@@ -1246,7 +1245,7 @@ class identity implements Core{
*
* @return void
*/
- $policies["listPolicies"] = function(){
+ private function listPolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
@@ -1279,7 +1278,7 @@ class identity implements Core{
*
* @return void
*/
- $policies["showPolicie"] = function(){
+ private function showPolicie(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
@@ -1313,7 +1312,7 @@ class identity implements Core{
*
* @return void
*/
- $policies["updatePolicies"] = function(){
+ private function updatePolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
@@ -1346,7 +1345,7 @@ class identity implements Core{
*
* @return void
*/
- $policies["deletePolicies"] = function(){
+ private function deletePolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
@@ -1372,8 +1371,6 @@ class identity implements Core{
}*/
}
- $projects = array();
-
/**
* Add a project.
*
@@ -1381,7 +1378,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["addProject"] = function(){
+ private function addProject(){
//Todo Parameters Optional
$description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name");
@@ -1416,7 +1413,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["listProjects"] = function(){
+ private function listProjects(){
try{
@@ -1442,7 +1439,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["showProject"] = function(){
+ private function showProject(){
$projId = $this->app->getPostParam("projetId");
@@ -1475,7 +1472,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["updateProject"] = function(){
+ private function updateProject(){
//Todo Parameters Optionnal
$description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name");
@@ -1515,7 +1512,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["deleteProject"] = function(){
+ private function deleteProject(){
$projId = $this->app->getPostParam("projId");
if(!isset($projId)){
@@ -1548,7 +1545,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["listRolesProjectUser"] = function(){
+ private function listRolesProjectUser(){
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
@@ -1583,7 +1580,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["grantRoleProjectUser"] = function(){
+ private function grantRoleProjectUser(){
$projId = $this->app->getPostParam("projId");
$userId = $this->app->getPostParam("userId");
@@ -1622,7 +1619,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["checkRoleProjectUser"] = function(){
+ private function checkRoleProjectUser(){
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
@@ -1663,7 +1660,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["revokeRoleProjectUser"] = function(){
+ private function revokeRoleProjectUser(){
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
@@ -1702,7 +1699,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["listRolesProjectGroup"] = function(){
+ private function listRolesProjectGroup(){
$projId = $this->app->getPostParam("projetId");
$groupId = $this->app->getPostParam("groupId");
@@ -1738,7 +1735,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["grantRoleProjectGroup"] = function(){
+ private function grantRoleProjectGroup(){
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
@@ -1777,7 +1774,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["checkRoleProjectGroup"] = function(){
+ private function checkRoleProjectGroup(){
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
@@ -1818,7 +1815,7 @@ class identity implements Core{
*
* @return void
*/
- $projects["revokeRoleProjectGroup"] = function(){
+ private function revokeRoleProjectGroup(){
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
@@ -1850,8 +1847,6 @@ class identity implements Core{
}
}
- $roles = array();
-
/**
* Add a role.
*
@@ -1859,7 +1854,7 @@ class identity implements Core{
*
* @return void
*/
- $roles["addRole"] = function(){
+ private function addRole(){
$name = $this->app->getPostParam("name");
@@ -1891,7 +1886,7 @@ class identity implements Core{
*
* @return void
*/
- $roles["listRoles"] = function(){
+ private function listRoles(){
try{
@@ -1915,7 +1910,7 @@ class identity implements Core{
*
* @return void
*/
- $roles["listRoleAssignements"] = function(){
+ private function listRoleAssignements(){
try{
@@ -1934,8 +1929,6 @@ class identity implements Core{
}
}
- $services = array();
-
/**
* Add a service.
*
@@ -1943,7 +1936,7 @@ class identity implements Core{
*
* @return void
*/
- $services["addService"] = function(){
+ private function addService(){
$name = $this->app->getPostParam("name");
$type = $this->app->getPostParam("type");
@@ -1976,7 +1969,7 @@ class identity implements Core{
*
* @return void
*/
- $services["listServices"] = function(){
+ private function listServices(){
try{
@@ -2002,7 +1995,7 @@ class identity implements Core{
*
* @return void
*/
- $services["showService"] = function(){
+ private function showService(){
$servId = $this->app->getPostParam("serviceId");
if(!isset($servId)){
@@ -2033,7 +2026,7 @@ class identity implements Core{
*
* @return void
*/
- $services["deleteService"] = function(){
+ private function deleteService(){
$servId = $this->app->getPostParam("serviceId");
$groupId = $this->app->getPostParam("groupId");
@@ -2060,8 +2053,6 @@ class identity implements Core{
}
}
- $tokens = array();
-
/**
* Generate a new token for a given user id.
*
@@ -2069,7 +2060,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["genTokenUserID"] = function(){
+ private function genTokenUserID(){
$userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPassword");
@@ -2107,7 +2098,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["genTokenUserName"] = function(){
+ private function genTokenUserName(){
$username = $this->app->getPostParam("username");
$userPass = $this->app->getPostParam("userPassword");
$domId = $this->app->getPostParam("domainId");
@@ -2149,7 +2140,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["geneTokenID"] = function(){
+ private function genTokenID(){
$tokenId = $this->app->getPostParam("tokenId");
$projectId = $this->app->getPostParam("projectId");
@@ -2185,7 +2176,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["genTokenScopedProjectID"] = function(){
+ private function genTokenScopedProjectID(){
$userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPass");
@@ -2227,7 +2218,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["genTokenScopedProjectName"] = function(){
+ private function genTokenScopedProjectName(){
$userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPass");
@@ -2275,7 +2266,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["validateToken"] = function(){
+ private function validateToken(){
$tokenId = $this->app->getPostParam("tokenId");
@@ -2311,7 +2302,7 @@ class identity implements Core{
*
* @return void
*/
- $tokens["revokeToken"] = function(){
+ private function revokeToken(){
$tokenId = $this->app->getPostParam("tokenId");
@@ -2336,8 +2327,6 @@ class identity implements Core{
}
}
- $users = array();
-
/**
* Add a new user.
*
@@ -2345,7 +2334,7 @@ class identity implements Core{
*
* @return void
*/
- $users["addUser"] = function(){
+ private function addUser(){
//Todo Optionnal Parameter
$projId = $this->app->getPostParam("projId");
$desc = $this->app->getPostParam("description");
@@ -2388,7 +2377,7 @@ class identity implements Core{
*
* @return void
*/
- $users["listUsers"] = function(){
+ private function listUsers(){
try{
@@ -2414,7 +2403,7 @@ class identity implements Core{
*
* @return void
*/
- $users["showUser"] = function(){
+ private function showUser(){
$userId = $this->app->getPostParam("userId");
@@ -2447,7 +2436,7 @@ class identity implements Core{
*
* @return void
*/
- $users["updateUser"] = function(){
+ private function updateUser(){
$userId = $this->app->getPostParam("userId");
$desc = $this->app->getPostParam("description");
@@ -2486,7 +2475,7 @@ class identity implements Core{
*
* @return void
*/
- $users["deleteUser"] = function(){
+ private function deleteUser(){
$userId = $this->app->getPostParam("userId");
@@ -2519,7 +2508,7 @@ class identity implements Core{
*
* @return void
*/
- $users["listUserGroups"] = function(){
+ private function listUserGroups(){
$userId = $this->app->getPostParam("userId");
@@ -2553,7 +2542,7 @@ class identity implements Core{
*
* @return void
*/
- $users["listUserProjects"] = function(){
+ private function listUserProjects(){
$userId = $this->app->getPostParam("userId");
@@ -2579,15 +2568,4 @@ class identity implements Core{
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
-
- $actions["Credentials"] = $credentials;
- $actions["Domains"] = $domains;
- $actions["Endpoints"] = $endpoints;
- $actions["Groups"] = $groups;
- $actions["Policies"] = $policies;
- $actions["Projects"] = $projects;
- $actions["Roles"] = $roles;
- $actions["Services"] = $services;
- $actions["Tokens"] = $tokens;
- $actions["Users"] = $users;
}
diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php
index 58b87c1..b71defa 100644
--- a/server/core/LibOverride/genTokenOptions.php
+++ b/server/core/LibOverride/genTokenOptions.php
@@ -70,7 +70,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Identity'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options;
}
@@ -95,7 +95,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Identity'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options;
}
@@ -118,7 +118,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Image'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options;
}
@@ -143,7 +143,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Image'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options;
}
@@ -165,7 +165,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Network'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options;
}
@@ -190,7 +190,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Network'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options;
}
@@ -212,7 +212,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options;
}
@@ -238,10 +238,21 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);
- $this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl );
+ $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options;
}
+ private function saveBackup($name, $data){
+ $token = $this->serializeToken($data["token"]);
+ $path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"];
+ error_log(print_r($path, true), 0);
+ file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved']));
+ $this->backup["roles"] = $token["roles"];
+ $this->backup["project"] = $token['saved']["project"]["name"];
+ $this->backup["user"] = $token["user"];
+ $this->backup[$name] = array('token' => $token["token"], 'baseUrl' => $data["baseUrl"] );
+ }
+
public function getBackup(){
return serialize($this->backup);
}
@@ -249,6 +260,9 @@ class genTokenOptions
public function loadBackup($back){
$backup = unserialize($back);
+ $this->backup["roles"] = $backup["roles"];
+ $this->backup["project"] = $backup["project"];
+ $this->backup["user"] = $backup["user"];
loadComputeBackup($backup["Compute"]);
loadIdentityBackup($backup["Identity"]);
loadImageBackup($backup["Image"]);
@@ -262,7 +276,7 @@ class genTokenOptions
private function serializeToken($token){
$tokenSerialized = [];
- $tokenSerialized["methods"] = serialize($token->methods);
+ $tokenSerialized["token"]["methods"] = serialize($token->methods);
$tokenSerialized["roles"] = [];
foreach($token->roles as $role){
@@ -270,30 +284,30 @@ class genTokenOptions
$tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name);
}
- $tokenSerialized["expires"] = serialize($token->expires);
- $tokenSerialized["project"]["domainId"] = serialize($token->project->domainId);
- $tokenSerialized["project"]["parentId"] = serialize($token->project->parentId);
- $tokenSerialized["project"]["enabled"] = serialize($token->project->enabled);
- $tokenSerialized["project"]["description"] = serialize($token->project->description);
- $tokenSerialized["project"]["id"] = serialize($token->project->id);
- $tokenSerialized["project"]["links"] = serialize($token->project->links);
- $tokenSerialized["project"]["name"] = serialize($token->project->name);
+ $tokenSerialized["token"]["expires"] = serialize($token->expires);
+ $tokenSerialized['saved']["project"]["domainId"] = serialize($token->project->domainId);
+ $tokenSerialized['saved']["project"]["parentId"] = serialize($token->project->parentId);
+ $tokenSerialized['saved']["project"]["enabled"] = serialize($token->project->enabled);
+ $tokenSerialized['saved']["project"]["description"] = serialize($token->project->description);
+ $tokenSerialized['saved']["project"]["id"] = serialize($token->project->id);
+ $tokenSerialized['saved']["project"]["links"] = serialize($token->project->links);
+ $tokenSerialized['saved']["project"]["name"] = $token->project->name;
foreach($token->catalog->services as $service){
- $tokenSerialized["catalog"][serialize($service->id)]["name"] = serialize($service->name);
- $tokenSerialized["catalog"][serialize($service->id)]["description"] = serialize($service->description);
- $tokenSerialized["catalog"][serialize($service->id)]["type"] = serialize($service->type);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["name"] = serialize($service->name);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["description"] = serialize($service->description);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["type"] = serialize($service->type);
foreach($service->endpoints as $end){
- $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface);
- $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name);
- $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId);
- $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region);
- $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links);
- $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url);
}
- $tokenSerialized["roles"][serialize($service->id)]["links"] = serialize($service->links);
+ $tokenSerialized['saved']["catalog"][serialize($service->id)]["links"] = serialize($service->links);
}
- $tokenSerialized["extras"] = serialize($token->extras);
+ $tokenSerialized["token"]["extras"] = serialize($token->extras);
$tokenSerialized["user"]["domainId"] = serialize($token->user->domainId);
$tokenSerialized["user"]["defaultProjectId"] = serialize($token->user->defaultProjectId);
$tokenSerialized["user"]["id"] = serialize($token->user->id);
@@ -302,42 +316,42 @@ class genTokenOptions
$tokenSerialized["user"]["description"] = serialize($token->user->description);
$tokenSerialized["user"]["links"] = serialize($token->user->links);
$tokenSerialized["user"]["name"] = serialize($token->user->name);
- $tokenSerialized["issued"] = serialize($token->issued);
- $tokenSerialized["id"] = serialize($token->id);
+ $tokenSerialized["token"]["issued"] = serialize($token->issued);
+ $tokenSerialized["token"]["id"] = serialize($token->id);
return $tokenSerialized;
}
private function unserializeToken($tokenSerialized){
+ $Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]);
$api = new Api();
$token = new Models\Token($this->httpClient, $api);
$token->methods = unserialize($tokenSerialized["methods"]);
$token->roles = [];
- foreach($tokenSerialized["roles"] as $key => $role){
+ foreach($this->backup["roles"] as $key => $role){
$tmp = new Models\Role($this->httpClient, $api);
$tmp->id = unserialize($key);
$tmp->links = unserialize($role["links"]);
- if(isset($role["name"]))
- $tmp->name = unserialize($role["name"]);
+ $tmp->name = unserialize($role["name"]);
$token->roles[] = $tmp;
}
$token->expires = unserialize($tokenSerialized["expires"]);
$token->project = new Models\Project($this->httpClient, $api);
- $token->project->domainId = unserialize($tokenSerialized["project"]["domainId"]);
- $token->project->parentId = unserialize($tokenSerialized["project"]["parentId"]);
- $token->project->enabled = unserialize($tokenSerialized["project"]["enabled"]);
- $token->project->description = unserialize($tokenSerialized["project"]["description"]);
- $token->project->id = unserialize($tokenSerialized["project"]["id"]);
- $token->project->links = unserialize($tokenSerialized["project"]["links"]);
- $token->project->name = unserialize($tokenSerialized["project"]["name"]);
+ $token->project->domainId = unserialize($Saved["project"]["domainId"]);
+ $token->project->parentId = unserialize($Saved["project"]["parentId"]);
+ $token->project->enabled = unserialize($Saved["project"]["enabled"]);
+ $token->project->description = unserialize($Saved["project"]["description"]);
+ $token->project->id = unserialize($Saved["project"]["id"]);
+ $token->project->links = unserialize($Saved["project"]["links"]);
+ $token->project->name = $Saved["project"]["name"];
$token->catalog = new Models\Catalog($this->httpClient, $api);
$token->catalog->services = [];
- foreach($tokenSerialized["catalog"] as $key => $service){
+ foreach($Saved["catalog"] as $key => $service){
$tmp = new Models\Service($this->httpClient, $api);
$tmp->id = unserialize($key);
@@ -356,21 +370,20 @@ class genTokenOptions
$tmpEnd->url = unserialize($end["url"]);
$tmp->endpoints[] = $tmpEnd;
}
- if(isset($service["links"]))
- $tmp->links = unserialize($service["links"]);
+ $tmp->links = unserialize($service["links"]);
$token->catalog->services[] = $tmp;
}
$token->extras = unserialize($tokenSerialized["extras"]);
$token->user = new Models\User($this->httpClient, $api);
- $token->user->domainId = unserialize($tokenSerialized["user"]["domainId"]);
- $token->user->defaultProjectId = unserialize($tokenSerialized["user"]["defaultProjectId"]);
- $token->user->id = unserialize($tokenSerialized["user"]["id"]);
- $token->user->email = unserialize($tokenSerialized["user"]["email"]);
- $token->user->enabled = unserialize($tokenSerialized["user"]["enabled"]);
- $token->user->links = unserialize($tokenSerialized["user"]["links"]);
- $token->user->name = unserialize($tokenSerialized["user"]["name"]);
- $token->user->description = unserialize($tokenSerialized["user"]["description"]);
+ $token->user->domainId = unserialize($this->backup["user"]["domainId"]);
+ $token->user->defaultProjectId = unserialize($this->backup["user"]["defaultProjectId"]);
+ $token->user->id = unserialize($this->backup["user"]["id"]);
+ $token->user->email = unserialize($this->backup["user"]["email"]);
+ $token->user->enabled = unserialize($this->backup["user"]["enabled"]);
+ $token->user->links = unserialize($this->backup["user"]["links"]);
+ $token->user->name = unserialize($this->backup["user"]["name"]);
+ $token->user->description = unserialize($this->backup["user"]["description"]);
$token->issued = unserialize($tokenSerialized["issued"]);
$token->id = unserialize($tokenSerialized["id"]);
diff --git a/server/core/LibOverride/projectTokenData/demo b/server/core/LibOverride/projectTokenData/demo
new file mode 100644
index 0000000..95d1e10
--- /dev/null
+++ b/server/core/LibOverride/projectTokenData/demo
@@ -0,0 +1 @@
+a:2:{s:7:"project";a:7:{s:8:"domainId";s:2:"N;";s:8:"parentId";s:2:"N;";s:7:"enabled";s:2:"N;";s:11:"description";s:2:"N;";s:2:"id";s:40:"s:32:"bdb42ccd0a074d15a9808ed0d2f09ce7";";s:5:"links";s:2:"N;";s:4:"name";s:4:"demo";}s:7:"catalog";a:4:{s:40:"s:32:"52c1f2e9782b47a697df38185d72a3f9";";a:5:{s:4:"name";s:14:"s:7:"neutron";";s:11:"description";s:2:"N;";s:4:"type";s:14:"s:7:"network";";s:9:"endpoints";a:3:{s:40:"s:32:"2c765b2eb502467fba360a1188174f6a";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9696";";}s:40:"s:32:"499dc9aeb1c3438fb23b0168d75bbef1";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:32:"s:24:"http://148.60.11.31:9696";";}s:40:"s:32:"d0672225fe1a4fce89794f3825deec2b";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9696";";}}s:5:"links";s:2:"N;";}s:40:"s:32:"5d48cf5c41b9412a8bfcf87e4b6b4bb4";";a:5:{s:4:"name";s:13:"s:6:"glance";";s:11:"description";s:2:"N;";s:4:"type";s:12:"s:5:"image";";s:9:"endpoints";a:3:{s:40:"s:32:"03aed8cd676d4b1b8b6ed69ba7750d72";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9292";";}s:40:"s:32:"06ba5f2c1cb24eaebe3ef3b258ff0841";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:32:"s:24:"http://148.60.11.31:9292";";}s:40:"s:32:"32dd6e5e7acd44d88c1e89a4d805a355";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9292";";}}s:5:"links";s:2:"N;";}s:40:"s:32:"be984e9e4da645449c645a3dad056d6b";";a:5:{s:4:"name";s:15:"s:8:"keystone";";s:11:"description";s:2:"N;";s:4:"type";s:15:"s:8:"identity";";s:9:"endpoints";a:3:{s:40:"s:32:"0f292b615b544869841c349dbbfead32";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:36:"s:28:"http://148.60.11.31:5000/2.0";";}s:40:"s:32:"6a01f770c4014bec933cccc28d378c78";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:36:"s:28:"http://controller:35357/v2.0";";}s:40:"s:32:"d94955c39c784602a1ab49003056a4a4";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:35:"s:27:"http://controller:5000/v2.0";";}}s:5:"links";s:2:"N;";}s:40:"s:32:"edc16c0a3e4042b7b396727fa8e57e7e";";a:5:{s:4:"name";s:11:"s:4:"nova";";s:11:"description";s:2:"N;";s:4:"type";s:14:"s:7:"compute";";s:9:"endpoints";a:3:{s:40:"s:32:"0d61ec232f3b4975b3e3d32f2b7a6122";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:68:"s:60:"http://148.60.11.31:8774/v2/bdb42ccd0a074d15a9808ed0d2f09ce7";";}s:40:"s:32:"20ac63e325274a5bbde914f3bb582c45";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:66:"s:58:"http://controller:8774/v2/bdb42ccd0a074d15a9808ed0d2f09ce7";";}s:40:"s:32:"749e7483b9b04dceb1838095dd877aa8";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:66:"s:58:"http://controller:8774/v2/bdb42ccd0a074d15a9808ed0d2f09ce7";";}}s:5:"links";s:2:"N;";}}} \ No newline at end of file
diff --git a/server/init.php b/server/init.php
index cf08523..a00927d 100644..100755
--- a/server/init.php
+++ b/server/init.php
@@ -43,4 +43,6 @@
$App = new App($Args);
+ if(isset($token))
+ $App->setToken($token);
?>