Ejemplo n.º 1
1
 private function createCassandraDb(Cassandra $storage)
 {
     // create the cassandra keyspace and column family
     $sys = new \phpcassa\SystemManager('localhost:9160');
     $sys->create_keyspace('oauth2_test', array("strategy_class" => \phpcassa\Schema\StrategyClass::SIMPLE_STRATEGY, "strategy_options" => array('replication_factor' => '1')));
     $sys->create_column_family('oauth2_test', 'auth');
     $cassandra = new \phpcassa\Connection\ConnectionPool('oauth2_test', array('127.0.0.1:9160'));
     $cf = new \phpcassa\ColumnFamily($cassandra, 'auth');
     // populate the data
     $storage->setClientDetails("oauth_test_client", "testpass", "http://example.com", 'implicit password');
     $storage->setAccessToken("testtoken", "Some Client", '', time() + 1000);
     $storage->setAuthorizationCode("testcode", "Some Client", '', '', time() + 1000);
     $storage->setScope('supportedscope1 supportedscope2 supportedscope3 supportedscope4');
     $storage->setScope('defaultscope1 defaultscope2', null, 'default');
     $storage->setScope('clientscope1 clientscope2', 'Test Client ID');
     $storage->setScope('clientscope1 clientscope2', 'Test Client ID', 'default');
     $storage->setScope('clientscope1 clientscope2 clientscope3', 'Test Client ID 2');
     $storage->setScope('clientscope1 clientscope2', 'Test Client ID 2', 'default');
     $storage->setScope('clientscope1 clientscope2', 'Test Default Scope Client ID');
     $storage->setScope('clientscope1 clientscope2', 'Test Default Scope Client ID', 'default');
     $storage->setScope('clientscope1 clientscope2 clientscope3', 'Test Default Scope Client ID 2');
     $storage->setScope('clientscope3', 'Test Default Scope Client ID 2', 'default');
     $storage->setClientKey('oauth_test_client', $this->getTestPublicKey(), 'test_subject');
     $cf->insert("oauth_public_keys:ClientID_One", array('__data' => json_encode(array("public_key" => "client_1_public", "private_key" => "client_1_private", "encryption_algorithm" => "RS256"))));
     $cf->insert("oauth_public_keys:ClientID_Two", array('__data' => json_encode(array("public_key" => "client_2_public", "private_key" => "client_2_private", "encryption_algorithm" => "RS256"))));
     $cf->insert("oauth_public_keys:", array('__data' => json_encode(array("public_key" => $this->getTestPublicKey(), "private_key" => $this->getTestPrivateKey(), "encryption_algorithm" => "RS256"))));
     $cf->insert("oauth_users:testuser", array('__data' => json_encode(array("password" => "password", "email" => "*****@*****.**", "email_verified" => true))));
 }
 /**
  * Add a deletion to the buffer.
  *
  * @param phpcassa\ColumnFamily $column_family an initialized
  *        ColumnFamily instance
  * @param mixed $key the row key
  * @param mixed[] $columns a list of columns or super columns to delete
  * @param mixed $supercolumn if you want to delete only some subcolumns from
  *        a single super column, set this to the super column name
  * @param int $timestamp an optional timestamp (default is "now", when
  *        this function is called, not when send() is called)
  */
 public function remove($column_family, $key, $columns = null, $super_column = null, $timestamp = null)
 {
     if ($timestamp === null) {
         $timestamp = Clock::get_time();
     }
     $deletion = new Deletion();
     $deletion->timestamp = $timestamp;
     if ($super_column !== null) {
         $deletion->super_column = $column_family->pack_name($super_column, true);
     }
     if ($columns !== null) {
         $is_super = $column_family->is_super && $super_column === null;
         $packed_cols = array();
         foreach ($columns as $col) {
             $packed_cols[] = $column_family->pack_name($col, $is_super);
         }
         $predicate = new SlicePredicate();
         $predicate->column_names = $packed_cols;
         $deletion->predicate = $predicate;
     }
     $mutation = new Mutation();
     $mutation->deletion = $deletion;
     $packed_key = $column_family->pack_key($key);
     $this->enqueue($packed_key, $column_family, array($mutation));
     return $this;
 }