当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Mount_Config::encryptPasswords方法代码示例

本文整理汇总了PHP中OC_Mount_Config::encryptPasswords方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Mount_Config::encryptPasswords方法的具体用法?PHP OC_Mount_Config::encryptPasswords怎么用?PHP OC_Mount_Config::encryptPasswords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Mount_Config的用法示例。


在下文中一共展示了OC_Mount_Config::encryptPasswords方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeConfig

 /**
  * Write the storages to the configuration.
  *
  * @param array $storages map of storage id to storage config
  */
 public function writeConfig($storages)
 {
     // let the horror begin
     $mountPoints = [];
     foreach ($storages as $storageConfig) {
         $mountPoint = $storageConfig->getMountPoint();
         $oldBackendOptions = $storageConfig->getBackendOptions();
         $storageConfig->setBackendOptions(\OC_Mount_Config::encryptPasswords($oldBackendOptions));
         // system mount
         $rootMountPoint = '/$user/files/' . ltrim($mountPoint, '/');
         $applicableUsers = $storageConfig->getApplicableUsers();
         $applicableGroups = $storageConfig->getApplicableGroups();
         foreach ($applicableUsers as $applicable) {
             $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_USER, $applicable, $rootMountPoint, $storageConfig);
         }
         foreach ($applicableGroups as $applicable) {
             $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_GROUP, $applicable, $rootMountPoint, $storageConfig);
         }
         // if neither "applicableGroups" or "applicableUsers" were set, use "all" user
         if (empty($applicableUsers) && empty($applicableGroups)) {
             $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_USER, 'all', $rootMountPoint, $storageConfig);
         }
         // restore old backend options where the password was not encrypted,
         // because we don't want to change the state of the original object
         $storageConfig->setBackendOptions($oldBackendOptions);
     }
     \OC_Mount_Config::writeData(null, $mountPoints);
 }
开发者ID:samj1912,项目名称:repo,代码行数:33,代码来源:globalstoragesservice.php

示例2: writeConfig

 /**
  * Write the storages to the user's configuration.
  *
  * @param array $storages map of storage id to storage config
  */
 public function writeConfig($storages)
 {
     $user = $this->userSession->getUser()->getUID();
     // let the horror begin
     $mountPoints = [];
     foreach ($storages as $storageConfig) {
         $mountPoint = $storageConfig->getMountPoint();
         $oldBackendOptions = $storageConfig->getBackendOptions();
         $storageConfig->setBackendOptions(\OC_Mount_Config::encryptPasswords($oldBackendOptions));
         $rootMountPoint = '/' . $user . '/files/' . ltrim($mountPoint, '/');
         $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_USER, $user, $rootMountPoint, $storageConfig);
         // restore old backend options where the password was not encrypted,
         // because we don't want to change the state of the original object
         $storageConfig->setBackendOptions($oldBackendOptions);
     }
     \OC_Mount_Config::writeData($user, $mountPoints);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:22,代码来源:userstoragesservice.php

示例3: testReadLegacyConfigAndGenerateConfigId

 /**
  * Test reading in a legacy config and generating config ids.
  */
 public function testReadLegacyConfigAndGenerateConfigId()
 {
     $configFile = $this->dataDir . '/' . $this->userId . '/mount.json';
     $legacyBackendOptions = ['user' => 'someuser', 'password' => 'somepassword'];
     $legacyBackendOptions = \OC_Mount_Config::encryptPasswords($legacyBackendOptions);
     $legacyConfig = ['backend' => 'identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB', 'authMechanism' => 'identifier:\\Auth\\Mechanism', 'options' => $legacyBackendOptions, 'mountOptions' => ['preview' => false]];
     // different mount options
     $legacyConfig2 = ['backend' => 'identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB', 'authMechanism' => 'identifier:\\Auth\\Mechanism', 'options' => $legacyBackendOptions, 'mountOptions' => ['preview' => true]];
     $json = ['user' => []];
     $json['user'][$this->userId] = ['/$user/files/somemount' => $legacyConfig, '/$user/files/anothermount' => $legacyConfig2];
     file_put_contents($configFile, json_encode($json));
     $allStorages = $this->service->getAllStorages();
     $this->assertCount(2, $allStorages);
     $storage1 = $allStorages[1];
     $storage2 = $allStorages[2];
     $this->assertEquals('/somemount', $storage1->getMountPoint());
     $this->assertEquals('someuser', $storage1->getBackendOptions()['user']);
     $this->assertEquals('somepassword', $storage1->getBackendOptions()['password']);
     $this->assertEquals(['preview' => false], $storage1->getMountOptions());
     $this->assertEquals('/anothermount', $storage2->getMountPoint());
     $this->assertEquals('someuser', $storage2->getBackendOptions()['user']);
     $this->assertEquals('somepassword', $storage2->getBackendOptions()['password']);
     $this->assertEquals(['preview' => true], $storage2->getMountOptions());
 }
开发者ID:rosarion,项目名称:core,代码行数:27,代码来源:userstoragesservicetest.php

示例4: testReadLegacyConfigAndGenerateConfigId

 /**
  * Test reading in a legacy config and generating config ids.
  */
 public function testReadLegacyConfigAndGenerateConfigId()
 {
     $configFile = $this->dataDir . '/mount.json';
     $legacyBackendOptions = ['user' => 'someuser', 'password' => 'somepassword'];
     $legacyBackendOptions = \OC_Mount_Config::encryptPasswords($legacyBackendOptions);
     $legacyConfig = ['backend' => 'identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB', 'authMechanism' => 'identifier:\\Auth\\Mechanism', 'options' => $legacyBackendOptions, 'mountOptions' => ['preview' => false]];
     // different mount options
     $legacyConfig2 = ['backend' => 'identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB', 'authMechanism' => 'identifier:\\Auth\\Mechanism', 'options' => $legacyBackendOptions, 'mountOptions' => ['preview' => true]];
     $legacyBackendOptions2 = $legacyBackendOptions;
     $legacyBackendOptions2 = ['user' => 'someuser2', 'password' => 'somepassword2'];
     $legacyBackendOptions2 = \OC_Mount_Config::encryptPasswords($legacyBackendOptions2);
     // different config
     $legacyConfig3 = ['backend' => 'identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB', 'authMechanism' => 'identifier:\\Auth\\Mechanism', 'options' => $legacyBackendOptions2, 'mountOptions' => ['preview' => true]];
     $json = ['user' => ['user1' => ['/$user/files/somemount' => $legacyConfig], 'user2' => ['/$user/files/somemount' => $legacyConfig], 'user3' => ['/$user/files/somemount' => $legacyConfig2], 'user4' => ['/$user/files/anothermount' => $legacyConfig], 'user5' => ['/$user/files/somemount' => $legacyConfig3]], 'group' => ['group1' => ['/$user/files/somemount' => $legacyConfig]]];
     file_put_contents($configFile, json_encode($json));
     $allStorages = $this->service->getAllStorages();
     $this->assertCount(4, $allStorages);
     $storage1 = $allStorages[1];
     $storage2 = $allStorages[2];
     $storage3 = $allStorages[3];
     $storage4 = $allStorages[4];
     $this->assertEquals('/somemount', $storage1->getMountPoint());
     $this->assertEquals('someuser', $storage1->getBackendOptions()['user']);
     $this->assertEquals('somepassword', $storage1->getBackendOptions()['password']);
     $this->assertEquals(['user1', 'user2'], $storage1->getApplicableUsers());
     $this->assertEquals(['group1'], $storage1->getApplicableGroups());
     $this->assertEquals(['preview' => false], $storage1->getMountOptions());
     $this->assertEquals('/somemount', $storage2->getMountPoint());
     $this->assertEquals('someuser', $storage2->getBackendOptions()['user']);
     $this->assertEquals('somepassword', $storage2->getBackendOptions()['password']);
     $this->assertEquals(['user3'], $storage2->getApplicableUsers());
     $this->assertEquals([], $storage2->getApplicableGroups());
     $this->assertEquals(['preview' => true], $storage2->getMountOptions());
     $this->assertEquals('/anothermount', $storage3->getMountPoint());
     $this->assertEquals('someuser', $storage3->getBackendOptions()['user']);
     $this->assertEquals('somepassword', $storage3->getBackendOptions()['password']);
     $this->assertEquals(['user4'], $storage3->getApplicableUsers());
     $this->assertEquals([], $storage3->getApplicableGroups());
     $this->assertEquals(['preview' => false], $storage3->getMountOptions());
     $this->assertEquals('/somemount', $storage4->getMountPoint());
     $this->assertEquals('someuser2', $storage4->getBackendOptions()['user']);
     $this->assertEquals('somepassword2', $storage4->getBackendOptions()['password']);
     $this->assertEquals(['user5'], $storage4->getApplicableUsers());
     $this->assertEquals([], $storage4->getApplicableGroups());
     $this->assertEquals(['preview' => true], $storage4->getMountOptions());
 }
开发者ID:GrumpyCrouton,项目名称:core,代码行数:49,代码来源:globalstoragesservicetest.php

示例5: testVariableSubstitution

 public function testVariableSubstitution()
 {
     $legacyBackendOptions = ['user' => 'someuser', 'password' => 'somepassword', 'replacethis' => '$user'];
     $legacyBackendOptions = \OC_Mount_Config::encryptPasswords($legacyBackendOptions);
     $legacyConfig = ['class' => '\\OC\\Files\\Storage\\SMB', 'options' => $legacyBackendOptions, 'mountOptions' => ['preview' => false, 'int' => 1]];
     // different mount options
     $legacyConfig2 = ['class' => '\\OC\\Files\\Storage\\SMB', 'options' => $legacyBackendOptions, 'mountOptions' => ['preview' => true, 'string' => 'abc']];
     $json = ['user' => [self::TEST_USER1 => ['/$user/files/somemount' => $legacyConfig, '/$user/files/anothermount' => $legacyConfig2]]];
     $this->writeGlobalConfig($json);
     // re-read config, password was read correctly
     $config = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
     $config1 = $config['/' . self::TEST_USER1 . '/files/somemount'];
     $config2 = $config['/' . self::TEST_USER1 . '/files/anothermount'];
     $this->assertSame(self::TEST_USER1, $config1['options']['replacethis']);
     $this->assertSame(self::TEST_USER1, $config1['options']['replacethis']);
     $this->assertSame(1, $config1['mountOptions']['int']);
     $this->assertSame(true, $config2['mountOptions']['preview']);
     $this->assertSame('abc', $config2['mountOptions']['string']);
 }
开发者ID:samj1912,项目名称:repo,代码行数:19,代码来源:mountconfig.php


注:本文中的OC_Mount_Config::encryptPasswords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。