istic-openstack/server/core/Identity.php

1179 lines
21 KiB
PHP
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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'
*
* @todo Complete the functions and finish the descriptions
*/
use OpenStack\Common\Error;
/**
* Identity 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 identity implements Core{
/** @var App $app protected, contains the main app object */
protected $app;
/** @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
*
* @param App $app the main app object
*
* @throws [Type] [<description>]
*
* @return identity
*/
public function __construct($app){
$this->app = $app;
$this->libClass = $app->getLibClass("Identity");
}
$credentials = array();
/**
* Add a credential for the given user/project.
*
* Create a secret/access pair for use with ec2 style auth.
* This operation will generates a new set of credentials that map the user/project pair.
*
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
* @param String $projectId Required project's UUID
* @param String $type Required Type of credential : ec2, cert...
* @param String $userId Required Id of the user which own the credential
*
* @return void
*/
$credentials["addCredential"] = function(){
$blob = $this->app->getPostParam("blob");
$projectId = $this->app->getPostParam("projectId");
$type = $this->app->getPostParam("type");
$userId = $this->app->getPostParam("userId");
if(!isset($blob) || !isset($projectId) || !isset($type) || !isset($userId)){
$this->app->setOutput("Error", "Parameters Incorrect");
return;
}
try{
$opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId);
$res = $this->libClass->createCredential($opt);
//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);
}
}
/**
* List the credentials for a given user.
*
* @return void
*/
$credentials["listCredentials"] = function(){
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);
}
}
/**
* Retrieve a users access/secret pair by the access key.
*
* @param String $credentialId Required credential id for which it retrieve the details
*
* @return void
*/
$credentials["showCredential"] = function(){
$credentId = $this->app->getPostParam("credentialId");
if(!isset($credentId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$cred = $this->libClass->getCredential($credentId);
$cred->retrieve();
//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);
}
}
/**
* Update a users access/secret pair.
*
* @param String $credentialId Required credential id to update
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
* @param String $type Required Type of credential : ec2, cert...
*
* @return void
*/
$credentials["updateCredential"] = function(){
$credentId = $this->app->getPostParam("credentialId");
$blob = $this->app->getPostParam("blob");
$type = $this->app->getPostParam("type");
if(!isset($blob) || !isset($credentId) || !isset($type)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$credential = $this->libClass->getCredential($credentId);
$credential->type = $type;
$credential->blob = $blob;
$credential->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);
}
}
/**
* Delete a users access/secret pair.
*
* @param String $credentialId Required credential id to delete
*
* @return void
*/
$credentials["deleteCredential"] = function(){
$credentId = $this->app->getPostParam("credentialId");
if(!isset($credentId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$credential = $this->libClass->getCredential($credentId);
$credential->delete();
//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);
}
}-
$domains = array();
/**
* Add a domain to an OpenStack instance.
*
* @param String $desc Optional Domain Description
* @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name
*
* @return void
*/
$domains["addDomain"] = function(){
$description = $this->app->getPostParam("desc");
$enabled = $this->app->getPostParam("enabled");
$name = $this->app->getPostParam("name");
if(!isset($name)){
$this->app->setOutput("Error", "Parameters Incorrect");
return;
}
if(isset($enabled) && isset($description))
$opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name);
elseif(isset($enabled))
$opt = array('enabled' => $enabled, 'name' => $name);
elseif(isset($description))
$opt = array('description' => $description, 'name' => $name);
else
$opt = array('name' => $name);
try{
$res = $this->libClass->createCredential($opt);
//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);
}
}
/**
* Retrieve the different domain's list.
*
* @return void
*/
$domains["listDomains"] = function(){
try{
$this->libClass->listDomains()
//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);
}
}
/**
* Retrieve the details of a given domain.
*
* @param String $domainId Required Domain id for which it retrieve the details
*
* @return void
*/
$domains["showDomain"] = function(){
$domId = $this->app->getPostParam("domainId");
if(!isset($domId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$domain = $this->libClass->getDomain($domId);
$domain->retrieve();
//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);
}
}
/**
* Update the given domain.
*
* @param String $domainId Required domain id to update
* @param String $desc Optional Domain Description
* @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name
*
* @return void
*/
$domains["updateDomain"] = function(){
$domId = $this->app->getPostParam("domainId");
$description = $this->app->getPostParam("desc");
$enabled = $this->app->getPostParam("enabled");
$name = $this->app->getPostParam("name");
if(!isset($domId)){
$this->app->setOutput("Error", "Parameters Incorrect");
return;
}
try{
$domain = $this->libClass->getDomain($domId);
if(isset($name))
$domain->name = $name;
if(isset($enabled))
$domain->enabled = $enabled;
if(isset($description))
$domain->description = $description;
$domain->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);
}
}
/**
* Delete the given domain.
*
* @param String $domainId Required Domain id to delete
*
* @return void
*/
$domains["deleteDomain"] = function(){
$domId = $this->app->getPostParam("domainId");
if(!isset($domId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$domain = $this->libClass->getDomain($domId);
$domain->delete();
//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);
}
}
/**
* Retrieve the different roles of a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["listRolesDomainUser"] = function(){
}
/**
* Grant a role to a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["grantRoleDomainUser"] = function(){
}
/**
* Verify that a user has a given role in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["checkRoleDomainUser"] = function(){
}
/**
* Delete a role for a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["revokeRoleDomainUser"] = function(){
}
/**
* Retrieve the roles of a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["listRolesDomainGroup"] = function(){
}
/**
* Add a role to a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["grantRoleDomainGroup"] = function(){
}
/**
* Verify that a role is associated with a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["checkRoleDomainGroup"] = function(){
}
/**
* 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
* 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
*/
$domains["revokeRoleDomainGroup"] = function(){
}
$endpoints = array();
/**
* Add an endpoint to the Openstack instance
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["addEndpoint"] = function(){
}
/**
* Retrieve the endpoint for the given id
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["getEndpoint"] = function(){
}
/**
* Retrieve the list of the different endpoints
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["listEndpoints"] = function(){
}
/**
* Update a given endpoint
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["updateEndpoint"] = function(){
}
/**
* Delete a given endpoint
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["deleteEndpoint"] = function(){
}
$groups = array();
/**
* Add a group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["addGroup"] = function(){
}
/**
* Retrieve the group's list.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["listGroups"] = function(){
}
/**
* Retrieve the details of a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["showGroup"] = function(){
}
/**
* Update a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["updateGroup"] = function(){
}
/**
* Delete the given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["deleteGroup"] = function(){
}
/**
* Retrieve the users of a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["listGroupUsers"] = function(){
}
/**
* Add a user to a group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["addGroupUser"] = function(){
}
/**
* Remove a user from a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["removeGroupUser"] = function(){
}
/**
* Check if a group contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["checkGroupUser"] = function(){
}
$policies = array();
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["addPolicies"] = function(){
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["listPolicies"] = function(){
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["showPolicie"] = function(){
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["updatePolicies"] = function(){
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["deletePolicies"] = function(){
}
$projects = array();
/**
* Add a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["addProject"] = function(){
}
/**
* Retrieve the different projects.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["listProjects"] = function(){
}
/**
* Retrieve the details of a given project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["showProject"] = function(){
}
/**
* Update a given project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["updateProject"] = function(){
}
/**
* Delete a given project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["deleteProject"] = function(){
}
/**
* List the roles of a given user in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["listRolesProjectUser"] = function(){
}
/**
* Grant a role to an user in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["grantRoleProjectUser"] = function(){
}
/**
* Check if a given user has a role in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["checkRoleProjectUser"] = function(){
}
/**
* Delete a role for a given user in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["revokeRoleProjectUser"] = function(){
}
/**
* List the roles of a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["listRolesProjectGroup"] = function(){
}
/**
* Add a role to a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["grantRoleProjectGroup"] = function(){
}
/**
* Check if a group has a given role in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["checkRoleProjectGroup"] = function(){
}
/**
* Delete a role for a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["revokeRoleProjectGroup"] = function(){
}
$roles = array();
/**
* Add a role.
*
* @throws [Type] [<description>]
*
* @return void
*/
$roles["addRole"] = function(){
}
/**
* List the different roles
*
* @throws [Type] [<description>]
*
* @return void
*/
$roles["listRoles"] = function(){
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$roles["listRoleAssignements"] = function(){
}
$services = array();
/**
* Add a service.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["addService"] = function(){
}
/**
* Retrieve the different services.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["listServices"] = function(){
}
/**
* Retrieve the details for a given service.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["showService"] = function(){
}
/**
* Delete a given service.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["deleteService"] = function(){
}
$tokens = array();
/**
* Generate a new token for a given user id.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenUserID"] = function(){
}
/**
* Generate a new token for a given user name.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenUserName"] = function(){
}
/**
* Generate a new token from another token ID.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["geneTokenID"] = function(){
}
/**
* Generate a new token scoped by a project ID.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenScopedProjectID"] = function(){
}
/**
* Generate a new token scoped by a project name.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenScopedProjectName"] = function(){
}
/**
* Check if a token is validate.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["validateToken"] = function(){
}
/**
* Delete a given token.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["revokeToken"] = function(){
}
$users = array();
/**
* Add a new user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["addUser"] = function(){
}
/**
* Retrieve the different users.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["listUsers"] = function(){
}
/**
* Retrieve the details of a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["showUser"] = function(){
}
/**
* Update a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["updateUser"] = function(){
}
/**
* Delete a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["deleteUser"] = function(){
}
/**
* Retrieve the groups which contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["listUserGroups"] = function(){
}
/**
* Retrieve the projects which contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["listUserProjects"] = function(){
}
$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;
}