/**
  * @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;
 }
Example #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);
 }
Example #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);
 }
Example #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());
     }
 }
 protected static function getTokenStore()
 {
     if (!self::$tokenStore instanceof ObjectStorage_TokenStore_Interface) {
         self::$tokenStore = ObjectStorage_TokenStore::factory('memory');
     }
     return self::$tokenStore;
 }
 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;
 }
Example #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();
 }