Beispiel #1
0
function CreateTableBasedGrantsManager()
{
    global $tableCaptions;
    $usersTable = array('TableName' => 'atig_users', 'UserName' => 'user_name', 'UserId' => 'user_id', 'Password' => 'user_password');
    $userPermsTable = array('TableName' => 'atig_user_perms', 'UserId' => 'user_id', 'PageName' => 'page_name', 'Grant' => 'perm_name');
    $passwordHasher = HashUtils::CreateHasher('MD5');
    $connectionOptions = GetGlobalConnectionOptions();
    $tableBasedGrantsManager = new TableBasedUserGrantsManager(new MyPDOConnectionFactory(), $connectionOptions, $usersTable, $userPermsTable, $tableCaptions, $passwordHasher, false);
    return $tableBasedGrantsManager;
}
Beispiel #2
0
 public function __construct($userInfos, $passwordEncryption = ENCRYPTION_NONE)
 {
     $this->userInfos = $userInfos;
     $this->passwordHasher = HashUtils::CreateHasher($passwordEncryption);
 }
 public function __construct(ConnectionFactory $connectionFactory, $connectionOptions, $tableName, $userNameFieldName, $passwordFieldName, $passwordEncryption = '', $userIdFieldName = null)
 {
     $this->userNameFieldName = $userNameFieldName;
     $this->passwordFieldName = $passwordFieldName;
     $this->passwordHasher = HashUtils::CreateHasher($passwordEncryption);
     $this->CreateDataset($connectionFactory, $connectionOptions, $tableName, $userNameFieldName, $passwordFieldName);
 }
 /**
  * Upload an object.
  *
  * @param        $path
  * @param        $body
  * @param Config $config
  *
  * @return array
  */
 protected function upload($path, $body, Config $config)
 {
     $options = $this->getOptionsFromConfig($config);
     $response = null;
     try {
         if (is_string($body)) {
             $response = $this->client->putObjectFromString($this->bucket, $path, $body, $options);
         } else {
             if (is_resource($body)) {
                 if (isset($options['file'])) {
                     $file = $options['file'];
                 } else {
                     $metadata = stream_get_meta_data($body);
                     $file = $metadata['uri'];
                 }
                 if ($file !== null) {
                     $response = $this->client->putObjectFromFile($this->bucket, $path, $file, $options);
                 } else {
                     if (!isset($options[BosOptions::CONTENT_TYPE])) {
                     }
                     if (!isset($options[BosOptions::CONTENT_LENGTH])) {
                         $contentLength = Util::getStreamSize($body);
                     } else {
                         $contentLength = $options[BosOptions::CONTENT_LENGTH];
                         unset($options[BosOptions::CONTENT_LENGTH]);
                     }
                     if (!isset($options[BosOptions::CONTENT_MD5])) {
                         $contentMd5 = base64_encode(HashUtils::md5FromStream($body, 0, $contentLength));
                     } else {
                         $contentMd5 = $options[BosOptions::CONTENT_MD5];
                         unset($options[BosOptions::CONTENT_MD5]);
                     }
                     $response = $this->client->putObject($this->bucket, $path, $body, $contentLength, $contentMd5, $options);
                     if (is_resource($body)) {
                         fclose($body);
                     }
                 }
             } else {
                 throw new \InvalidArgumentException("{$body} type should be string or resource");
             }
         }
     } catch (BceBaseException $e) {
         if (stcmp(gettype($e), "BceClientException") == 0) {
             $this->logger->debug("BceClientException: " . $e->getMessage());
         }
         if (stcmp(gettype($e), "BceServerException") == 0) {
             $this->logger->debug("BceServerException: " . $e->getMessage());
         }
         if (is_resource($body)) {
             fclose($body);
         }
         return false;
     } catch (\InvalidArgumentException $e) {
         $this->logger->debug("InvalidArgumentException: " . $e->getMessage());
         if (is_resource($body)) {
             fclose($body);
         }
         return false;
     } catch (\Exception $e) {
         $this->logger->debug("Exception: " . $e->getMessage());
         if (is_resource($body)) {
             fclose($body);
         }
         return false;
     }
     return $this->normalizeResponse($response->metadata, $path);
 }
 public function __construct($connectionFactory, $connectionOptions, $tableName, $userNameFieldName, $passwordFieldName, $passwordEncryption = '', $userIdFieldName = null)
 {
     $this->userNameFieldName = $userNameFieldName;
     $this->passwordFieldName = $passwordFieldName;
     $this->passwordHasher = HashUtils::CreateHasher($passwordEncryption);
     $this->dataset = new TableDataset($connectionFactory, $connectionOptions, $tableName);
     $field = new StringField($userNameFieldName);
     $this->dataset->AddField($field, true);
     $field = new StringField($passwordFieldName);
     $this->dataset->AddField($field, false);
 }