/**
  * @expectedException ObjectStorage_Exception_Http_Unauthorized
  */
 public function testAuthenticationWithBadCredentials()
 {
     $options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
     $objectStorage = new ObjectStorage(self::$host, self::$username, 'bad-password-' . time(), $options);
     // Make sure we are not using cached auth data
     ObjectStorage::setTokenStore(new AuthenticationTest_TokenStore());
     $authData = $objectStorage->getAuthenticationData();
 }
 public static function setUpBeforeClass()
 {
     self::$tokenStore = ObjectStorage_TokenStore::factory('file', array('ttl' => 3600, 'path' => '/tmp'));
     $options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
     ObjectStorage::setTokenStore(self::$tokenStore);
     $objectStorage01 = new ObjectStorage(self::$host, self::$username, self::$password, $options);
     self::$objectStorage = $objectStorage01;
 }
Ejemplo n.º 3
0
 public function attach($obj, $inf = array())
 {
     /* {{{ */
     if (!$obj instanceof Format) {
         throw new InvalidArgumentException('All formats *MUST* inherit ' . __NAMESPACE__ . '\\Format');
     }
     $obj->notify(Render::STANDALONE, true);
     return parent::attach($obj, $inf);
 }
Ejemplo n.º 4
0
 public final function attach($obj, $inf = array())
 {
     if (!$obj instanceof $this && get_class($obj) != get_class($this)) {
         throw new \InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " . get_class($this) . ", got " . get_class($obj));
     }
     $obj->notify(Render::STANDALONE, false);
     return parent::attach($obj, $inf);
 }
Ejemplo n.º 5
0
 /**
  * Adds all objects-data pairs from a different storage in the current storage.
  *
  * @param ObjectStorage $objectStorage
  * @return void
  */
 public function addAll(ObjectStorage $objectStorage)
 {
     foreach ($objectStorage as $object) {
         $this->attach($object, $objectStorage->getInfo());
     }
 }
Ejemplo n.º 6
0
 protected static function getTokenStore()
 {
     if (!self::$tokenStore instanceof ObjectStorage_TokenStore_Interface) {
         self::$tokenStore = ObjectStorage_TokenStore::factory('memory');
     }
     return self::$tokenStore;
 }
Ejemplo n.º 7
0
 public function deleteFile($fname)
 {
     $options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
     $host = Yii::app()->params['host'];
     $folder = Yii::app()->params['folder'];
     $username = Yii::app()->params['username'];
     $password = Yii::app()->params['password'];
     try {
         $fOname = hash('sha512', $fname);
         $objectStorage = new ObjectStorage($host, $username, $password, $options);
         $result = $objectStorage->with($folder . '/' . $fOname)->delete();
     } catch (Exception $e) {
         try {
             @unlink(Yii::app()->basePath . '/attachments/' . $fname);
         } catch (Exception $e) {
         }
     }
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Returns an iterator for this storage.
  *
  * This method is part of the IteratorAggregate interface.
  *
  * @return \Generator
  */
 public function getIterator()
 {
     return $this->storage->getIterator();
 }