Esempio n. 1
0
 /**
  * Builds an ListAccessTokensResult object from an XML string.
  * @param string $data
  */
 public static function fromXml($data)
 {
     $dom = new DOMDocument();
     $parseOk = false;
     $parseOk = $dom->loadXML($data);
     if (!$parseOk) {
         throw new EsuException('Failed to parse Policy XML');
     }
     $listAccessTokensResult = new ListAccessTokensResult();
     $root = $dom->firstChild;
     if ($root->localName != 'list-access-tokens-result') {
         throw new EsuException('Expected root node to be \'list-access-tokens-result\'.  It was ' . $root->localName);
     }
     $listAccessTokensResult->loadFromElement($root);
     return $listAccessTokensResult;
 }
Esempio n. 2
0
 /**
  * Lists access tokens for the current subtenant.  After calling this 
  * function, check the paginationToken field on the result.  If it's not 
  * NULL, there are more results to fetch.
  * @param string $paginationToken the pagination token.  Set to null for
  * the first page.
  * @param number $limit the number of objects to return per page.
  * @return ListAccessTokensResult the list of access tokens.
  */
 public function listAccessTokens($paginationToken = NULL, $limit = 0)
 {
     // Build the request
     $resource = $this->context . "/accesstokens";
     $req = $this->buildRequest($resource, null);
     $headers = array();
     $headers['x-emc-uid'] = $this->uid;
     $headers['Date'] = gmdate('r');
     // Limit number of results if desired
     if (!empty($limit)) {
         $headers['x-emc-limit'] = $limit;
     }
     if (!empty($token)) {
         $headers['x-emc-token'] = $paginationToken;
     }
     // Sign and send the request
     $this->signRequest($req, 'GET', $resource, $headers, null);
     try {
         $response = @$req->send();
     } catch (HTTP_Request2_Exception $e) {
         throw new EsuException('Sending request failed: ' . $e->__toString());
     }
     // Return the response
     if ($response->getStatus() > 299) {
         $this->handleError($response);
     }
     $body = $response->getBody();
     if ($checksum) {
         // Update expected checksum
         $checksum->setExpectedValue($response->getHeader('x-emc-wschecksum'));
         $checksum->update($body);
     }
     $resToken = $response->getHeader('x-emc-token');
     $tokenList = ListAccessTokensResult::fromXml($body);
     $tokenList->paginationToken = $resToken;
     return $tokenList;
 }