Ejemplo n.º 1
0
 /**
  *
  * Retrieve an authentication bucket
  * @param string $policyID
  * @param string $abId
  * @throws Exception
  * @return AuthIdsType
  */
 public function getAuthBucket($policyId, $abID)
 {
     $ab = new AuthIdsType();
     $ab->setId($abID);
     $url = E3_PROV_URL_POLICY . "/" . rawurlencode($policyId) . "/quotaRLBuckets/" . rawurlencode($ab->getId());
     $restClient = new RestClient();
     $reply = $restClient->makeCall($url, "GET");
     $xml = simplexml_load_string($reply->getPayload());
     $ab = AuthIdsType::fromXML($xml->api);
     return $ab;
 }
Ejemplo n.º 2
0
 public static function fromXML(SimpleXMLElement $xml)
 {
     $policy = new Policy();
     $policy->id = (string) $xml->id;
     if ($xml->apiIds->apiId) {
         foreach ($xml->apiIds->apiId as $apiId) {
             $policy->apiIds[] = current($apiId);
         }
     }
     if ($xml->authIds->quotaRLBucket) {
         foreach ($xml->authIds->quotaRLBucket as $bucket) {
             $policy->authIds[] = AuthIdsType::fromXML($bucket);
         }
     }
     if ($xml->contexts->context) {
         foreach ($xml->contexts->context as $contextXML) {
             $policy->contexts[] = Context::fromXML($contextXML);
         }
     }
     $policy->tdrOnLimitReached = (string) $xml->tdrOnLimitReached['type'];
     $policy->tdr = $xml->tdr ? TdrData::fromXML($xml->tdr) : new TdrData();
     if ($xml->properties && $xml->properties->property) {
         foreach ($xml->properties->property as $prop) {
             $policy->properties[(string) $prop['name']] = (string) $prop;
         }
     }
     if (!empty($policy->properties)) {
         ksort($policy->properties);
     }
     if ($xml->headerTransformations && $xml->headerTransformations->headerTransformation) {
         foreach ($xml->headerTransformations->headerTransformation as $transform) {
             $policy->headerTransformations[] = HeaderTransformation::fromXML($transform);
         }
     }
     return $policy;
 }