From 6960c81a1f2d4f39135e7d8cc5fa32c42e36b21c Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 15:45:25 +0100 Subject: [PATCH] Identity Class first function --- server/core/Identity.php | 59 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/server/core/Identity.php b/server/core/Identity.php index 1dc8373..df07f5d 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -53,7 +53,10 @@ class identity implements Core{ * 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. * - * @throws [Type] [] + * @param JsonString $blob credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" + * @param String $projectId project's UUID + * @param String $type Type of credential : ec2, cert... + * @param String $userId Id of the user which own the credential * * @return void */ @@ -73,36 +76,68 @@ class identity implements Core{ $opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId); $res = $this->libClass->createCredential($opt); - }catch(Exception $e){ - - } - - ] + }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. * - * @throws [Type] [] - * * @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 user’s access/secret pair by the access key. * - * @throws [Type] [] + * @param String $credentialId credential id for which it retrieve the details * * @return void */ $credentials["showCredential"] = function(){ - $credential = $identity->getCredential('credentialId'); -$credential->retrieve(); + $credentId = $this->app->getPostParam("credentialId"); + + 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); + } }