Refactoring of comments beginning

This commit is contained in:
EoleDev 2016-04-26 20:42:31 +02:00
parent 477dc82182
commit 5263cf00a2
13 changed files with 1535 additions and 1744 deletions

View file

@ -1,11 +1,21 @@
<?php <?php
/**
* File containing the code for the API door.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
date_default_timezone_set('Europe/Paris'); date_default_timezone_set('Europe/Paris');
$config = Array(); $config = Array();
$config["modules_enabled"] = ""; $config["modules_enabled"] = "";
$config["urlAuth"] = "http://148.60.11.31:5000/v3"; $config["urlAuth"] = "http://148.60.11.31:5000/v3";
$config["tokenTime"] = 60 //minute = 60 $config["tokenTime"] = 60; //minute = 60
?> ?>

View file

@ -1,21 +1,53 @@
<?php <?php
/**
* File containing the identity Class.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
//Library token management override
include_once("core/LibOverride/genTokenOptions.php"); include_once("core/LibOverride/genTokenOptions.php");
include_once("core/ErrorManagement.php"); include_once("core/ErrorManagement.php");
//Library loading
use OpenCloud\Common\Error\BadResponseError; use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError; use OpenCloud\Common\Error\UserInputError;
/**
* App Class of the back-end application
*
* This class allow the communication between the front-end application and
* the library which allow to send requests to an Openstack instance.
*
*/
class App{ class App{
/** @var Openstack $openstack protected, contains the main library object */
protected $openstack; protected $openstack;
/** @var Array $postParams protected, contains the post parameters */
protected $postParams; protected $postParams;
/** @var genTokenOptions $tokenClass protected, contains the class object for the authentication override of the library */
protected $tokenClass; protected $tokenClass;
/** @var String $tokenPost protected, contains the token given in parameter */
protected $tokenPost; protected $tokenPost;
/** @var errorManagement $errorClass protected, contains the errorManagement object */
protected $errorClass; protected $errorClass;
/** @var Array $output protected, contains the result for the API call */
protected $output; protected $output;
/**
* App constructor
*
* @param Array $args Args for the OpenStack Library
*
* @return App object
*/
public function __construct($args){ public function __construct($args){
$this->tokenPost = NULL; $this->tokenPost = NULL;
@ -27,6 +59,13 @@ class App{
} }
/**
* Set the class var $tokenPost and load the token
* into the genTokenOptions Class
*
* @param String $token token to be set
*
*/
public function setToken($token){ public function setToken($token){
$this->tokenPost = $token; $this->tokenPost = $token;
@ -34,10 +73,22 @@ class App{
} }
/**
* Check the expiration of the token
*
* @return Boolean if the token is not expired
*/
public function checkToken(){ public function checkToken(){
return $this->tokenClass->checkToken(); return $this->tokenClass->checkToken();
} }
/**
* Get the service Class given the name in parameter
*
* @param String $service Name of the service
*
* @return Core object
*/
public function getLibClass($service){ public function getLibClass($service){
switch($service){ switch($service){
@ -70,6 +121,11 @@ class App{
} }
/**
* Generate the token for the different services in OpenStack
*
* @return NULL
*/
public function authenticate(){ public function authenticate(){
try{ try{
@ -91,6 +147,11 @@ class App{
} }
/**
* Revoke the openstack services' token
*
* @return NULL
*/
public function deauthenticate(){ public function deauthenticate(){
try{ try{
@ -113,6 +174,13 @@ class App{
} }
/**
* Retrieve a post parameter given its name
*
* @param String $name Expected post parameter's name
*
* @return Object Post value
*/
public function getPostParam($name){ public function getPostParam($name){
if(isset($this->postParams[$name])){ if(isset($this->postParams[$name])){
@ -123,28 +191,52 @@ class App{
} }
/**
* Set a post parameter for automating task
*
* @param String $param Name for the Post entry
* @param Object $value Value for the Post entry
*
* @return NULL
*/
public function setPostParam($param, $value){ public function setPostParam($param, $value){
$this->postParams[$param] = $value; $this->postParams[$param] = $value;
} }
/**
* Set a new output message
*
* @param String $key Array key for the message
* @param Array $out Message's value
*
* @return NULL
*/
public function setOutput($key, $out){ public function setOutput($key, $out){
$this->output[$key] = $out; $this->output[$key] = $out;
} }
/**
* Retrieve the errorManagement instance Object
*
* @return errorManagement object
*/
public function getErrorInstance(){ public function getErrorInstance(){
return $this->errorClass; return $this->errorClass;
} }
/**
* Output the messages to be send to the client
*
* @return NULl
*/
public function show(){ public function show(){
echo json_encode($this->output); echo json_encode($this->output);
//error_log(var_dump(json_encode($this->output), true), 0);
} }
} }

View file

@ -5,9 +5,8 @@
* @version 1.0 Initialisation of this file * @version 1.0 Initialisation of this file
* @since 1.0 Core application's file * @since 1.0 Core application's file
* *
* @author Evan Pisani 'yogg at epsina . com' et bhupi * @author Evan Pisani 'yogg at epsina . com', bhupi
* *
* @todo Complete the functions with errors detection and finish the descriptions
*/ */
include("Image.php"); include("Image.php");
@ -44,7 +43,7 @@ class automating{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
@ -58,7 +57,7 @@ class automating{
* @param String $serverName name ofthe new server * @param String $serverName name ofthe new server
* @param String $flavor kind of server * @param String $flavor kind of server
* *
* @return void * @return NULL
*/ */
private function createPublicServer() private function createPublicServer()
{ {

View file

@ -21,7 +21,7 @@ class compute
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
@ -300,7 +300,7 @@ class compute
/** /**
* update a server * update a server
* @return void * @return NULL
*/ */
public function updateServer() public function updateServer()
{ {
@ -346,7 +346,7 @@ class compute
} }
/** /**
* Delete a server * Delete a server
* @return void * @return NULL
*/ */
public function deleteServer() public function deleteServer()
{ {
@ -380,7 +380,7 @@ class compute
} }
/** /**
* Change the password of a server * Change the password of a server
* @return void * @return NULL
*/ */
public function changePassword() public function changePassword()
{ {
@ -415,7 +415,7 @@ class compute
} }
/** /**
* Reboot a server * Reboot a server
* @return void * @return NULL
*/ */
public function reboot() public function reboot()
{ {
@ -449,7 +449,7 @@ class compute
} }
/** /**
* Rebuild a server * Rebuild a server
* @return void * @return NULL
*/ */
public function rebuild() public function rebuild()
{ {
@ -496,7 +496,7 @@ class compute
/** /**
* Resize a server * Resize a server
* A call to this method has to be followed by either confirmResize or revertResize * A call to this method has to be followed by either confirmResize or revertResize
* @return void * @return NULL
*/ */
public function resize() public function resize()
{ {
@ -530,7 +530,7 @@ class compute
} }
/** /**
* Confirm resize operation on a server * Confirm resize operation on a server
* @return void * @return NULL
*/ */
public function confirmResize() public function confirmResize()
{ {
@ -564,7 +564,7 @@ class compute
} }
/** /**
* Revert resize operation on a server * Revert resize operation on a server
* @return void * @return NULL
*/ */
public function revertResize() public function revertResize()
{ {
@ -598,7 +598,7 @@ class compute
} }
/** /**
* List private and public addresses of a server * List private and public addresses of a server
* @return void * @return NULL
*/ */
public function listAddresses(array $options = []) public function listAddresses(array $options = [])

View file

@ -1,5 +1,13 @@
<?php <?php
/**
* File containing Core Interface
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
interface Core{ interface Core{
public function action($action); public function action($action);

View file

@ -22,9 +22,9 @@ Class errorManagement{
/** /**
* ErrorManagemement constructor * ErrorManagemement constructor
* *
* @param App $app the main app object * @param App $args the main app object
* *
* @return ErrorManagement * @return ErrorManagement Object
*/ */
public function __construct($args){ public function __construct($args){
@ -35,9 +35,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a base error in the output * Put an error message corresponding to a base error in the output
* *
* @param $error the error triggered * @param Exception $error the exception triggered
* *
* @return String BaseError message * @return NULL
*/ */
public function BaseErrorHandler($error){ public function BaseErrorHandler($error){
$this->app->setOutput("Error", "BaseError"); $this->app->setOutput("Error", "BaseError");
@ -46,9 +46,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a bad response in function of the status code in the output * Put an error message corresponding to a bad response in function of the status code in the output
* *
* @param $error the error triggered * @param Exception $error the exception triggered
* *
* @return String Error message * @return NULL
*/ */
public function BadResponseHandler($error){ public function BadResponseHandler($error){
$statusCode = $error->getResponse()->getStatusCode(); $statusCode = $error->getResponse()->getStatusCode();
@ -86,9 +86,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a not implemented yet error in the output * Put an error message corresponding to a not implemented yet error in the output
* *
* @param $error the error triggered * @param Exception $error the exception triggered
* *
* @return String internal error message * @return NULL
*/ */
public function NotImplementedHandler($error){ public function NotImplementedHandler($error){
$this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator");
@ -97,9 +97,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a user input error in the output * Put an error message corresponding to a user input error in the output
* *
* @param $error the error triggered * @param Exception $error the exception triggered
* *
* @return String User input error message * @return NULL
*/ */
public function UserInputHandler($error){ public function UserInputHandler($error){
$this->app->setOutput("Error", "UserInputError"); $this->app->setOutput("Error", "UserInputError");
@ -108,9 +108,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to an other error in the output * Put an error message corresponding to an other error in the output
* *
* @param $error the error triggered * @param Exception $error the exception triggered
* *
* @return String error message * @return NULL
*/ */
public function OtherException($error){ public function OtherException($error){
$this->app->setOutput("Error", $error->getMessage()); $this->app->setOutput("Error", $error->getMessage());

View file

@ -7,15 +7,13 @@
* *
* @author Eole 'eoledev at outlook . fr' * @author Eole 'eoledev at outlook . fr'
* *
* @todo Complete the functions and finish the descriptions
*/ */
use OpenCloud\Common\Error; use OpenCloud\Common\Error;
/** /**
* Identity Class of the back-end application * Identity Class of the back-end application
* *
* This class allow the communication between the front-end application and * This class implements the management for the identity request
* the library which allow to send requests to an Openstack instance.
* *
*/ */
class identity implements Core{ class identity implements Core{
@ -31,8 +29,6 @@ class identity implements Core{
* *
* @param App $app the main app object * @param App $app the main app object
* *
* @throws [Type] [<description>]
*
* @return identity * @return identity
*/ */
public function __construct($app){ public function __construct($app){
@ -47,7 +43,7 @@ class identity implements Core{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
@ -65,7 +61,7 @@ class identity implements Core{
* @param String $type Required Type of credential : ec2, cert... * @param String $type Required Type of credential : ec2, cert...
* @param String $userId Required Id of the user which own the credential * @param String $userId Required Id of the user which own the credential
* *
* @return void * @return NULL
*/ */
private function addCredential(){ private function addCredential(){
@ -103,7 +99,7 @@ class identity implements Core{
/** /**
* List the credentials for a given user. * List the credentials for a given user.
* *
* @return void * @return NULL
*/ */
private function listCredentials(){ private function listCredentials(){
try{ try{
@ -131,7 +127,7 @@ class identity implements Core{
* *
* @param String $credentialId Required credential id for which it retrieve the details * @param String $credentialId Required credential id for which it retrieve the details
* *
* @return void * @return NULL
*/ */
private function showCredential(){ private function showCredential(){
$credentId = $this->app->getPostParam("credentialId"); $credentId = $this->app->getPostParam("credentialId");
@ -168,7 +164,7 @@ class identity implements Core{
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" * @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
* @param String $type Required Type of credential : ec2, cert... * @param String $type Required Type of credential : ec2, cert...
* *
* @return void * @return NULL
*/ */
private function updateCredential(){ private function updateCredential(){
@ -210,7 +206,7 @@ class identity implements Core{
* *
* @param String $credentialId Required credential id to delete * @param String $credentialId Required credential id to delete
* *
* @return void * @return NULL
*/ */
private function deleteCredential(){ private function deleteCredential(){
@ -248,7 +244,7 @@ class identity implements Core{
* @param String $enabled Optional Domain enabled or not : value true or false * @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name * @param String $name Required Domain Name
* *
* @return void * @return NULL
*/ */
private function addDomain(){ private function addDomain(){
@ -293,7 +289,7 @@ class identity implements Core{
/** /**
* Retrieve the different domain's list. * Retrieve the different domain's list.
* *
* @return void * @return NULL
*/ */
private function listDomains(){ private function listDomains(){
@ -322,7 +318,7 @@ class identity implements Core{
* *
* @param String $domainId Required Domain id for which it retrieve the details * @param String $domainId Required Domain id for which it retrieve the details
* *
* @return void * @return NULL
*/ */
private function showDomain(){ private function showDomain(){
@ -360,7 +356,7 @@ class identity implements Core{
* @param String $enabled Optional Domain enabled or not : value true or false * @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name * @param String $name Required Domain Name
* *
* @return void * @return NULL
*/ */
private function updateDomain(){ private function updateDomain(){
@ -408,7 +404,7 @@ class identity implements Core{
* *
* @param String $domainId Required Domain id to delete * @param String $domainId Required Domain id to delete
* *
* @return void * @return NULL
*/ */
private function deleteDomain(){ private function deleteDomain(){
@ -441,9 +437,7 @@ class identity implements Core{
/** /**
* Retrieve the different roles of a given user in a domain. * Retrieve the different roles of a given user in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listRolesDomainUser(){ private function listRolesDomainUser(){
@ -478,9 +472,7 @@ class identity implements Core{
/** /**
* Grant a role to a given user in a domain. * Grant a role to a given user in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function grantRoleDomainUser(){ private function grantRoleDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -518,9 +510,7 @@ class identity implements Core{
/** /**
* Verify that a user has a given role in a domain. * Verify that a user has a given role in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function checkRoleDomainUser(){ private function checkRoleDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -559,9 +549,7 @@ class identity implements Core{
/** /**
* Delete a role for a given user in a domain. * Delete a role for a given user in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function revokeRoleDomainUser(){ private function revokeRoleDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -599,9 +587,7 @@ class identity implements Core{
/** /**
* Retrieve the roles of a given group in a domain. * Retrieve the roles of a given group in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listRolesDomainGroup(){ private function listRolesDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -636,9 +622,7 @@ class identity implements Core{
/** /**
* Add a role to a given group in a domain. * Add a role to a given group in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function grantRoleDomainGroup(){ private function grantRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -676,9 +660,7 @@ class identity implements Core{
/** /**
* Verify that a role is associated with a given group in a domain. * Verify that a role is associated with a given group in a domain.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function checkRoleDomainGroup(){ private function checkRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -717,15 +699,7 @@ class identity implements Core{
/** /**
* Delete a role for a given group in a domain. * Delete a role for a given group in a domain.
* *
* A *description*, that can span multiple lines, to go _in-depth_ into the details of this element * @return NULL
* and to provide some background information or textual references.
*
* @param string $myArgument With a *description* of this argument, these may also
* span multiple lines.
*
* @throws [Type] [<description>]
*
* @return void
*/ */
private function revokeRoleDomainGroup(){ private function revokeRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -764,9 +738,7 @@ class identity implements Core{
/** /**
* Add an endpoint to the Openstack instance * Add an endpoint to the Openstack instance
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addEndpoint(){ private function addEndpoint(){
$servId = $this->app->getPostParam("serviceId"); $servId = $this->app->getPostParam("serviceId");
@ -806,9 +778,7 @@ class identity implements Core{
/** /**
* Retrieve the endpoint for the given id * Retrieve the endpoint for the given id
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function getEndpoint(){ private function getEndpoint(){
@ -840,7 +810,7 @@ class identity implements Core{
/** /**
* Retrieve the list of the different endpoints * Retrieve the list of the different endpoints
* *
* @return void * @return NULL
*/ */
private function listEndpoints(){ private function listEndpoints(){
@ -866,50 +836,16 @@ class identity implements Core{
/** /**
* Update a given endpoint * Update a given endpoint
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function updateEndpoint(){ private function updateEndpoint(){
//Not Implemented Yet //Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
//TODO PARAMETERS
try{
$endpoint = $this->libClass->getEndpoint('{endpointId}');
$endpoint->interface = \OpenStack\Identity\v3\Enum::INTERFACE_PUBLIC;
$endpoint->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* Delete a given endpoint * Delete a given endpoint
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function deleteEndpoint(){ private function deleteEndpoint(){
$endId = $this->app->getPostParam("endpointId"); $endId = $this->app->getPostParam("endpointId");
@ -941,115 +877,34 @@ class identity implements Core{
/** /**
* Add a group. * Add a group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addGroup(){ private function addGroup(){
//Not Implemented Yet //Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* Retrieve the group's list. * Retrieve the group's list.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listGroups(){ private function listGroups(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* Retrieve the details of a given group. * Retrieve the details of a given group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function showGroup(){ private function showGroup(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* Update a given group. * Update a given group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function updateGroup(){ private function updateGroup(){
//Todo Argument Optional //Todo Argument Optional
@ -1090,9 +945,7 @@ class identity implements Core{
/** /**
* Delete the given group. * Delete the given group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function deleteGroup(){ private function deleteGroup(){
@ -1126,9 +979,7 @@ class identity implements Core{
/** /**
* Retrieve the users of a given group. * Retrieve the users of a given group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listGroupUsers(){ private function listGroupUsers(){
@ -1162,9 +1013,7 @@ class identity implements Core{
/** /**
* Add a user to a group. * Add a user to a group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addGroupUser(){ private function addGroupUser(){
@ -1199,9 +1048,7 @@ class identity implements Core{
/** /**
* Remove a user from a given group. * Remove a user from a given group.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function removeGroupUser(){ private function removeGroupUser(){
@ -1236,9 +1083,7 @@ class identity implements Core{
/** /**
* Check if a group contains a given user. * Check if a group contains a given user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function checkGroupUser(){ private function checkGroupUser(){
@ -1273,185 +1118,53 @@ class identity implements Core{
/** /**
* @todo * @todo
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addPolicies(){ private function addPolicies(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* @todo * @todo
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listPolicies(){ private function listPolicies(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* @todo * @todo
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function showPolicie(){ private function showPolicie(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* @todo * @todo
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function updatePolicies(){ private function updatePolicies(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* @todo * @todo
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function deletePolicies(){ private function deletePolicies(){
//Not Implemented Yet //Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
} }
/** /**
* Add a project. * Add a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addProject(){ private function addProject(){
//Todo Parameters Optional //Todo Parameters Optional
@ -1488,7 +1201,7 @@ class identity implements Core{
/** /**
* Retrieve the different projects. * Retrieve the different projects.
* *
* @return void * @return NULL
*/ */
private function listProjects(){ private function listProjects(){
@ -1514,9 +1227,7 @@ class identity implements Core{
/** /**
* Retrieve the details of a given project. * Retrieve the details of a given project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function showProject(){ private function showProject(){
@ -1549,9 +1260,7 @@ class identity implements Core{
/** /**
* Update a given project. * Update a given project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function updateProject(){ private function updateProject(){
//Todo Parameters Optionnal //Todo Parameters Optionnal
@ -1591,9 +1300,7 @@ class identity implements Core{
/** /**
* Delete a given project. * Delete a given project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function deleteProject(){ private function deleteProject(){
$projId = $this->app->getPostParam("projId"); $projId = $this->app->getPostParam("projId");
@ -1626,9 +1333,7 @@ class identity implements Core{
/** /**
* List the roles of a given user in a project. * List the roles of a given user in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listRolesProjectUser(){ private function listRolesProjectUser(){
@ -1665,9 +1370,7 @@ class identity implements Core{
/** /**
* Grant a role to an user in a project. * Grant a role to an user in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function grantRoleProjectUser(){ private function grantRoleProjectUser(){
@ -1706,9 +1409,7 @@ class identity implements Core{
/** /**
* Check if a given user has a role in a project. * Check if a given user has a role in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function checkRoleProjectUser(){ private function checkRoleProjectUser(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
@ -1749,9 +1450,7 @@ class identity implements Core{
/** /**
* Delete a role for a given user in a project. * Delete a role for a given user in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function revokeRoleProjectUser(){ private function revokeRoleProjectUser(){
@ -1790,9 +1489,7 @@ class identity implements Core{
/** /**
* List the roles of a group in a project. * List the roles of a group in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listRolesProjectGroup(){ private function listRolesProjectGroup(){
@ -1828,9 +1525,7 @@ class identity implements Core{
/** /**
* Add a role to a group in a project. * Add a role to a group in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function grantRoleProjectGroup(){ private function grantRoleProjectGroup(){
@ -1869,9 +1564,7 @@ class identity implements Core{
/** /**
* Check if a group has a given role in a project. * Check if a group has a given role in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function checkRoleProjectGroup(){ private function checkRoleProjectGroup(){
@ -1912,9 +1605,7 @@ class identity implements Core{
/** /**
* Delete a role for a group in a project. * Delete a role for a group in a project.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function revokeRoleProjectGroup(){ private function revokeRoleProjectGroup(){
@ -1953,9 +1644,7 @@ class identity implements Core{
/** /**
* Add a role. * Add a role.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addRole(){ private function addRole(){
@ -1989,7 +1678,7 @@ class identity implements Core{
/** /**
* List the different roles * List the different roles
* *
* @return void * @return NULL
*/ */
private function listRoles(){ private function listRoles(){
@ -2013,9 +1702,9 @@ class identity implements Core{
} }
/** /**
* @todo * List the different assignments for a given role
* *
* @return void * @return NULL
*/ */
private function listRoleAssignements(){ private function listRoleAssignements(){
@ -2041,9 +1730,7 @@ class identity implements Core{
/** /**
* Add a service. * Add a service.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addService(){ private function addService(){
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
@ -2078,7 +1765,7 @@ class identity implements Core{
/** /**
* Retrieve the different services. * Retrieve the different services.
* *
* @return void * @return NULL
*/ */
private function listServices(){ private function listServices(){
@ -2104,9 +1791,7 @@ class identity implements Core{
/** /**
* Retrieve the details for a given service. * Retrieve the details for a given service.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function showService(){ private function showService(){
$servId = $this->app->getPostParam("serviceId"); $servId = $this->app->getPostParam("serviceId");
@ -2137,9 +1822,7 @@ class identity implements Core{
/** /**
* Delete a given service. * Delete a given service.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function deleteService(){ private function deleteService(){
@ -2173,9 +1856,7 @@ class identity implements Core{
/** /**
* Generate a new token for a given user id. * Generate a new token for a given user id.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function genTokenUserID(){ private function genTokenUserID(){
@ -2213,9 +1894,7 @@ class identity implements Core{
/** /**
* Generate a new token for a given user name. * Generate a new token for a given user name.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function genTokenUserName(){ private function genTokenUserName(){
$username = $this->app->getPostParam("username"); $username = $this->app->getPostParam("username");
@ -2257,9 +1936,7 @@ class identity implements Core{
/** /**
* Generate a new token from another token ID. * Generate a new token from another token ID.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function genTokenID(){ private function genTokenID(){
@ -2295,9 +1972,7 @@ class identity implements Core{
/** /**
* Generate a new token scoped by a project ID. * Generate a new token scoped by a project ID.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function genTokenScopedProjectID(){ private function genTokenScopedProjectID(){
@ -2339,9 +2014,7 @@ class identity implements Core{
/** /**
* Generate a new token scoped by a project name. * Generate a new token scoped by a project name.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function genTokenScopedProjectName(){ private function genTokenScopedProjectName(){
@ -2389,9 +2062,7 @@ class identity implements Core{
/** /**
* Check if a token is validate. * Check if a token is validate.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function validateToken(){ private function validateToken(){
@ -2427,9 +2098,7 @@ class identity implements Core{
/** /**
* Delete a given token. * Delete a given token.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function revokeToken(){ private function revokeToken(){
@ -2461,9 +2130,7 @@ class identity implements Core{
/** /**
* Add a new user. * Add a new user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function addUser(){ private function addUser(){
//Todo Optionnal Parameter //Todo Optionnal Parameter
@ -2508,7 +2175,7 @@ class identity implements Core{
/** /**
* Retrieve the different users. * Retrieve the different users.
* *
* @return void * @return NULL
*/ */
private function listUsers(){ private function listUsers(){
@ -2534,9 +2201,7 @@ class identity implements Core{
/** /**
* Retrieve the details of a given user. * Retrieve the details of a given user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function showUser(){ private function showUser(){
@ -2569,9 +2234,7 @@ class identity implements Core{
/** /**
* Update a given user. * Update a given user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function updateUser(){ private function updateUser(){
@ -2610,9 +2273,7 @@ class identity implements Core{
/** /**
* Delete a given user. * Delete a given user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function deleteUser(){ private function deleteUser(){
@ -2645,9 +2306,7 @@ class identity implements Core{
/** /**
* Retrieve the groups which contains a given user. * Retrieve the groups which contains a given user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listUserGroups(){ private function listUserGroups(){
@ -2681,9 +2340,7 @@ class identity implements Core{
/** /**
* Retrieve the projects which contains a given user. * Retrieve the projects which contains a given user.
* *
* @throws [Type] [<description>] * @return NULL
*
* @return void
*/ */
private function listUserProjects(){ private function listUserProjects(){

View file

@ -51,7 +51,7 @@ class image implements Core{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
@ -272,7 +272,7 @@ class image implements Core{
* *
* @param String $id Identifier of the image * @param String $id Identifier of the image
* *
* @return void * @return NULL
*/ */
private function deleteImage(){ private function deleteImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -306,7 +306,7 @@ class image implements Core{
* *
* @param String $id Identifier of the image * @param String $id Identifier of the image
* *
* @return void * @return NULL
*/ */
private function reactivateImage(){ private function reactivateImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -343,7 +343,7 @@ class image implements Core{
* *
* @param String $id Identifier of the image * @param String $id Identifier of the image
* *
* @return void * @return NULL
*/ */
private function desactivateImage(){ private function desactivateImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -380,7 +380,7 @@ class image implements Core{
* @param String $id Identifier of the image * @param String $id Identifier of the image
* @param String $file_name Path of the image * @param String $file_name Path of the image
* *
* @return void * @return NULL
*/ */
private function uploadImage(){ private function uploadImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -591,7 +591,7 @@ class image implements Core{
* @param String $image_id Identifier of the image * @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member * @param String $member_id Identifier of the member
* *
* @return void * @return NULL
*/ */
private function removeMemberImage(){ private function removeMemberImage(){
$image_id = $this->app->getPostParam("image_id"); $image_id = $this->app->getPostParam("image_id");
@ -637,7 +637,7 @@ class image implements Core{
* @param String $member_id Identifier of the member * @param String $member_id Identifier of the member
* @param String $status New status for the member * @param String $status New status for the member
* *
* @return void * @return NULL
**/ **/
private function updateMemberImage(){ private function updateMemberImage(){
$image_id = $this->app->getPostParam("image_id"); $image_id = $this->app->getPostParam("image_id");

View file

@ -49,7 +49,7 @@ class network{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
@ -65,7 +65,7 @@ class network{
* @param String shared Specifies whether the network resource can be accessed by any tenant * @param String shared Specifies whether the network resource can be accessed by any tenant
* @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own
* *
* @return void * @return NULL
*/ */
private function create_network() private function create_network()
{ {
@ -136,7 +136,7 @@ class network{
* *
* *
* *
* @return void * @return NULL
*/ */
private function create_subnet() private function create_subnet()
@ -498,7 +498,7 @@ class network{
* @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own
* *
* *
* @return void * @return NULL
**/ **/
private function updateNetwork() private function updateNetwork()
@ -561,7 +561,7 @@ class network{
* @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports * @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports
* *
* *
* @return void * @return NULL
**/ **/
private function updateSubnet() private function updateSubnet()
@ -617,7 +617,7 @@ class network{
* @param String networkId ID if network which we want to delete * @param String networkId ID if network which we want to delete
* *
* *
* @return void * @return NULL
**/ **/
private function deleteNetwork() private function deleteNetwork()
{ {
@ -651,7 +651,7 @@ class network{
* @param String subnetId ID if network which we want to delete * @param String subnetId ID if network which we want to delete
* *
* *
* @return void * @return NULL
**/ **/
private function deleteSubnet() private function deleteSubnet()
{ {
@ -692,7 +692,7 @@ class network{
* @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String securityGroups Specifies the IDs of any security groups associated with this port
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
* *
* @return void * @return NULL
*/ */
private function createPort() private function createPort()
@ -876,7 +876,7 @@ class network{
* @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String securityGroups Specifies the IDs of any security groups associated with this port
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
* *
* @return void * @return NULL
*/ */
private function updatePort() private function updatePort()
{ {
@ -953,7 +953,7 @@ class network{
* Delete a port given * Delete a port given
* *
* @param String portId id of port which we wante to delete * @param String portId id of port which we wante to delete
* @return void * @return NULL
*/ */
private function deletePort() private function deletePort()
{ {
@ -988,7 +988,7 @@ class network{
* @param String name A human-readable name for the security group. This name might not be unique * @param String name A human-readable name for the security group. This name might not be unique
* @param String description Description of the security group * @param String description Description of the security group
* *
* @return void * @return NULL
*/ */
private function createSecurityGroup() private function createSecurityGroup()
@ -1040,7 +1040,7 @@ class network{
*@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix *@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
*@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix *@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
* *
* @return void * @return NULL
*/ */
private function createSecurityGroupRule() private function createSecurityGroupRule()
{ {
@ -1239,7 +1239,7 @@ class network{
/** /**
* Delete a specific Security Groupe given * Delete a specific Security Groupe given
* @param securityGroupeId ID of security Groupe which we want to get * @param securityGroupeId ID of security Groupe which we want to get
* @return void * @return NULL
*/ */
private function deleteSecurityGroupe() private function deleteSecurityGroupe()
{ {

View file

@ -51,7 +51,7 @@ class networkLayer3 {
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
@ -175,7 +175,7 @@ class networkLayer3 {
* *
* @param id the id of the floatingip to update * @param id the id of the floatingip to update
* *
* @return void * @return NULL
*/ */
private function updateFloatingIp(){ private function updateFloatingIp(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -224,7 +224,7 @@ class networkLayer3 {
* *
* @param string floatingip_id the floating-ip id to delete * @param string floatingip_id the floating-ip id to delete
* *
* @return void * @return NULL
*/ */
private function deleteFloatingIp(){ private function deleteFloatingIp(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -273,7 +273,7 @@ class networkLayer3 {
* *
* @param string floatingip_id the floating-ip id to retrieve * @param string floatingip_id the floating-ip id to retrieve
* *
* @return void * @return NULL
*/ */
private function retrieveFloatingIp(){ private function retrieveFloatingIp(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -437,7 +437,7 @@ class networkLayer3 {
* *
* @param string router the router to delete * @param string router the router to delete
* *
* @return void * @return NULL
*/ */
private function deleteRouter(){ private function deleteRouter(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -485,7 +485,7 @@ class networkLayer3 {
* *
* @param id the id of the floatingip to update * @param id the id of the floatingip to update
* *
* @return void * @return NULL
*/ */
private function updateRouter(){ private function updateRouter(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");

View file

@ -1,6 +1,19 @@
<?php <?php
/**
* File containing the code for the API door.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
//loading dependencies
require "vendor/autoload.php"; require "vendor/autoload.php";
//Include general config file
include_once("config.inc.php"); include_once("config.inc.php");
//Include API initialisation
include_once("init.php"); include_once("init.php");
if(isset($_POST["task"]) && isset($_POST["action"])){ if(isset($_POST["task"]) && isset($_POST["action"])){
@ -9,9 +22,12 @@
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){ }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
$task = $_POST["task"]; $task = $_POST["task"];
}else{ }else{
//Gestion Erreur $App->setOutput("Error", "Invalid Request!");
$App->show();
exit();
} }
//Authentification and deauthentification request
if($task == "Authenticate"){ if($task == "Authenticate"){
$App->authenticate(); $App->authenticate();
@ -23,6 +39,7 @@
$App->show(); $App->show();
}else if($App->checkToken()){ }else if($App->checkToken()){
//Task switcher and task's file loader
switch($task) switch($task)
{ {
case "identity": case "identity":
@ -62,6 +79,7 @@
} }
}else{ }else{
//Request without authentication
$App->setOutput("Error", "Token Invalide"); $App->setOutput("Error", "Token Invalide");
$App->show(); $App->show();
} }

View file

@ -1,4 +1,14 @@
<?php <?php
/**
* File containing the initialisation of the API.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
include_once("core/App.php"); include_once("core/App.php");
$user = ""; $user = "";
@ -6,7 +16,7 @@
$project = ""; $project = "";
//traitement requete, recuperation data //token processing
if(isset($_POST["token"])){ if(isset($_POST["token"])){
$token = $_POST["token"]; $token = $_POST["token"];
@ -17,13 +27,9 @@
$password = $_POST["password"]; $password = $_POST["password"];
$project = $_POST["project"]; $project = $_POST["project"];
} /*else { // Test Backend }
$user = "admin";
$password = "ae5or6cn";
$project = "admin";
}*/
//Library args
$Args = Array( $Args = Array(
"user" => Array( "user" => Array(
"name" => $user, "name" => $user,
@ -41,6 +47,7 @@
"authUrl" => $config["urlAuth"] "authUrl" => $config["urlAuth"]
); );
//Init core Api
$App = new App($Args); $App = new App($Args);
if(isset($token)) if(isset($token))