/**
  * Parses the given array into signed identifiers
  * 
  * @param string    $publicAccess container public access
  * @param string    $etag         container etag
  * @param \DateTime $lastModified last modification date
  * @param array     $parsed       parsed response into array
  * representation
  * 
  * @return none.
  */
 public static function create($publicAccess, $etag, $lastModified, $parsed)
 {
     $result = new GetContainerAclResult();
     $result->setETag($etag);
     $result->setLastModified($lastModified);
     $acl = ContainerAcl::create($publicAccess, $parsed);
     $result->setContainerAcl($acl);
     return $result;
 }
Пример #2
0
 /**
  * Parses the given array into signed identifiers.
  * 
  * @param string $publicAccess The container public access.
  * @param array  $parsed       The parsed response into array representation.
  * 
  * @return none
  */
 public static function create($publicAccess, $parsed)
 {
     $result = new ContainerAcl();
     $result->_publicAccess = $publicAccess;
     $result->_signedIdentifiers = array();
     if (!empty($parsed) && is_array($parsed['SignedIdentifier'])) {
         $entries = $parsed['SignedIdentifier'];
         $temp = Utilities::getArray($entries);
         foreach ($temp as $value) {
             $startString = urldecode($value['AccessPolicy']['Start']);
             $expiryString = urldecode($value['AccessPolicy']['Expiry']);
             $start = Utilities::convertToDateTime($startString);
             $expiry = Utilities::convertToDateTime($expiryString);
             $permission = $value['AccessPolicy']['Permission'];
             $id = $value['Id'];
             $result->addSignedIdentifier($id, $start, $expiry, $permission);
         }
     }
     return $result;
 }
Пример #3
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\Models\ContainerAcl::toXml
  * @covers MicrosoftAzure\Storage\Blob\Models\ContainerAcl::toArray
  * @depends testCreateMultipleEntries
  */
 public function testToXml($acl)
 {
     // Setup
     $sample = TestResources::getContainerAclMultipleEntriesSample();
     $expected = ContainerAcl::create('container', $sample['SignedIdentifiers']);
     $xmlSerializer = new XmlSerializer();
     // Test
     $xml = $acl->toXml($xmlSerializer);
     // Assert
     $array = Utilities::unserialize($xml);
     $acl = ContainerAcl::create('container', $array);
     $this->assertEquals($expected->getSignedIdentifiers(), $acl->getSignedIdentifiers());
 }
 public static function getInterestingACL()
 {
     $ret = array();
     $past = new \DateTime("01/01/2010");
     $future = new \DateTime("01/01/2020");
     $acl = new ContainerAcl();
     array_push($ret, $acl);
     $acl = new ContainerAcl();
     $acl->setPublicAccess(PublicAccessType::NONE);
     array_push($ret, $acl);
     $acl = new ContainerAcl();
     $acl->setPublicAccess(PublicAccessType::BLOBS_ONLY);
     array_push($ret, $acl);
     $acl = new ContainerAcl();
     $acl->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
     array_push($ret, $acl);
     $acl = new ContainerAcl();
     $acl->addSignedIdentifier('123', $past, $future, 'rw');
     array_push($ret, $acl);
     return $ret;
 }
Пример #5
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setContainerAcl
  */
 public function testSetContainerAcl()
 {
     // Setup
     $name = 'setcontaineracl' . $this->createSuffix();
     $this->createContainer($name);
     $sample = TestResources::getContainerAclMultipleEntriesSample();
     $expectedETag = '0x8CAFB82EFF70C46';
     $expectedLastModified = new \DateTime('Sun, 25 Sep 2011 19:42:18 GMT');
     $expectedPublicAccess = 'container';
     $acl = ContainerAcl::create($expectedPublicAccess, $sample['SignedIdentifiers']);
     // Test
     $this->restProxy->setContainerAcl($name, $acl);
     // Assert
     $actual = $this->restProxy->getContainerAcl($name);
     $this->assertEquals($acl->getPublicAccess(), $actual->getContainerAcl()->getPublicAccess());
     $this->assertEquals($acl->getSignedIdentifiers(), $actual->getContainerAcl()->getSignedIdentifiers());
 }