本文整理汇总了PHP中OCA\Files_External\Lib\StorageConfig类的典型用法代码示例。如果您正苦于以下问题:PHP StorageConfig类的具体用法?PHP StorageConfig怎么用?PHP StorageConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StorageConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testJsonSerialization
public function testJsonSerialization()
{
$backend = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Backend\\Backend')->disableOriginalConstructor()->getMock();
$parameter = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\DefinitionParameter')->disableOriginalConstructor()->getMock();
$parameter->expects($this->once())->method('getType')->willReturn(1);
$backend->expects($this->once())->method('getParameters')->willReturn(['secure' => $parameter]);
$backend->method('getIdentifier')->willReturn('storage::identifier');
$authMech = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\AuthMechanism')->disableOriginalConstructor()->getMock();
$authMech->method('getIdentifier')->willReturn('auth::identifier');
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint('test');
$storageConfig->setBackend($backend);
$storageConfig->setAuthMechanism($authMech);
$storageConfig->setBackendOptions(['user' => 'test', 'password' => 'password123', 'secure' => '1']);
$storageConfig->setPriority(128);
$storageConfig->setApplicableUsers(['user1', 'user2']);
$storageConfig->setApplicableGroups(['group1', 'group2']);
$storageConfig->setMountOptions(['preview' => false]);
$json = $storageConfig->jsonSerialize();
$this->assertSame(1, $json['id']);
$this->assertSame('/test', $json['mountPoint']);
$this->assertSame('storage::identifier', $json['backend']);
$this->assertSame('auth::identifier', $json['authMechanism']);
$this->assertSame('test', $json['backendOptions']['user']);
$this->assertSame('password123', $json['backendOptions']['password']);
$this->assertSame(true, $json['backendOptions']['secure']);
$this->assertSame(128, $json['priority']);
$this->assertSame(['user1', 'user2'], $json['applicableUsers']);
$this->assertSame(['group1', 'group2'], $json['applicableGroups']);
$this->assertSame(['preview' => false], $json['mountOptions']);
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:31,代码来源:StorageConfigTest.php
示例2: manipulateStorageConfig
/**
* @param StorageConfig $storage
* @param IUser $user
*/
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
$user = $storage->getBackendOption('user');
if ($domain = $storage->getBackendOption('domain')) {
$storage->setBackendOption('user', $domain . '\\' . $user);
}
}
开发者ID:farukuzun,项目名称:core-1,代码行数:11,代码来源:smb.php
示例3: triggerChangeHooks
/**
* Triggers signal_create_mount or signal_delete_mount to
* accomodate for additions/deletions in applicableUsers
* and applicableGroups fields.
*
* @param StorageConfig $oldStorage old storage config
* @param StorageConfig $newStorage new storage config
*/
protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage)
{
// if mount point changed, it's like a deletion + creation
if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
$this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
return;
}
$userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers());
$userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers());
$groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups());
$groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups());
// FIXME: Use as expression in empty once PHP 5.4 support is dropped
// if no applicable were set, raise a signal for "all"
$oldApplicableUsers = $oldStorage->getApplicableUsers();
$oldApplicableGroups = $oldStorage->getApplicableGroups();
if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) {
$this->triggerApplicableHooks(Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, ['all']);
}
// trigger delete for removed users
$this->triggerApplicableHooks(Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, $userDeletions);
// trigger delete for removed groups
$this->triggerApplicableHooks(Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_GROUP, $groupDeletions);
// and now add the new users
$this->triggerApplicableHooks(Filesystem::signal_create_mount, $newStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, $userAdditions);
// and now add the new groups
$this->triggerApplicableHooks(Filesystem::signal_create_mount, $newStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_GROUP, $groupAdditions);
// FIXME: Use as expression in empty once PHP 5.4 support is dropped
// if no applicable, raise a signal for "all"
$newApplicableUsers = $newStorage->getApplicableUsers();
$newApplicableGroups = $newStorage->getApplicableGroups();
if (empty($newApplicableUsers) && empty($newApplicableGroups)) {
$this->triggerApplicableHooks(Filesystem::signal_create_mount, $newStorage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, ['all']);
}
}
开发者ID:kenwi,项目名称:core,代码行数:43,代码来源:globalstoragesservice.php
示例4: triggerChangeHooks
/**
* Triggers signal_create_mount or signal_delete_mount to
* accomodate for additions/deletions in applicableUsers
* and applicableGroups fields.
*
* @param StorageConfig $oldStorage old storage data
* @param StorageConfig $newStorage new storage data
*/
protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage)
{
// if mount point changed, it's like a deletion + creation
if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
$this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
}
}
开发者ID:fabricecetic,项目名称:core,代码行数:16,代码来源:userstoragesservice.php
示例5: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage)
{
$username_as_share = $storage->getBackendOption('username_as_share') === true;
if ($username_as_share) {
$share = '/' . $storage->getBackendOption('user');
$storage->setBackendOption('share', $share);
}
}
开发者ID:hyb148,项目名称:core,代码行数:8,代码来源:smb_oc.php
示例6: manipulateStorageConfig
protected function manipulateStorageConfig(StorageConfig $storage)
{
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
/** @var Backend */
$backend = $storage->getBackend();
$backend->manipulateStorageConfig($storage, $this->userSession->getUser());
}
开发者ID:farukuzun,项目名称:core-1,代码行数:9,代码来源:userstoragescontroller.php
示例7: manipulateStorageConfig
private function manipulateStorageConfig(StorageConfig $storage)
{
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage);
/** @var Backend */
$backend = $storage->getBackend();
$backend->manipulateStorageConfig($storage);
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:9,代码来源:Verify.php
示例8: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
$auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
}
$storage->setBackendOption('public_key_auth', $auth);
}
开发者ID:farukuzun,项目名称:core-1,代码行数:9,代码来源:rsa.php
示例9: setOption
/**
* @param StorageConfig $mount
* @param string $key
* @param string $value
* @param OutputInterface $output
*/
protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output)
{
$decoded = json_decode($value, true);
if (!is_null($decoded)) {
$value = $decoded;
}
$mount->setMountOption($key, $value);
$this->globalService->updateStorage($mount);
}
开发者ID:kenwi,项目名称:core,代码行数:15,代码来源:option.php
示例10: constructStorage
/**
* Construct the storage implementation
*
* @param StorageConfig $storageConfig
* @return Storage
*/
private function constructStorage(StorageConfig $storageConfig)
{
$class = $storageConfig->getBackend()->getStorageClass();
$storage = new $class($storageConfig->getBackendOptions());
// auth mechanism should fire first
$storage = $storageConfig->getBackend()->wrapStorage($storage);
$storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
return $storage;
}
开发者ID:GrumpyCrouton,项目名称:core,代码行数:15,代码来源:configadapter.php
示例11: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage)
{
$encrypted = $this->session->get('password::sessioncredentials/credentials');
if (!isset($encrypted)) {
throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
}
$credentials = json_decode($this->crypto->decrypt($encrypted), true);
$storage->setBackendOption('user', $this->session->get('loginname'));
$storage->setBackendOption('password', $credentials['password']);
}
开发者ID:kenwi,项目名称:core,代码行数:10,代码来源:sessioncredentials.php
示例12: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) {
$uid = '';
} else {
$uid = $user->getUID();
}
$credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
if (is_array($credentials)) {
$storage->setBackendOption('user', $credentials['user']);
$storage->setBackendOption('password', $credentials['password']);
}
}
开发者ID:farukuzun,项目名称:core-1,代码行数:13,代码来源:globalauth.php
示例13: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
if (!isset($user)) {
throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
}
$uid = $user->getUID();
$credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
if (!isset($credentials)) {
throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
}
$storage->setBackendOption('user', $credentials['user']);
$storage->setBackendOption('password', $credentials['password']);
}
开发者ID:farukuzun,项目名称:core-1,代码行数:13,代码来源:logincredentials.php
示例14: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null)
{
if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) {
$uid = '';
} elseif (is_null($user)) {
throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
} else {
$uid = $user->getUID();
}
$credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
if (is_array($credentials)) {
$storage->setBackendOption('user', $credentials['user']);
$storage->setBackendOption('password', $credentials['password']);
}
}
开发者ID:ZverAleksey,项目名称:core,代码行数:15,代码来源:globalauth.php
示例15: testDeleteStorage
public function testDeleteStorage()
{
$storage = new StorageConfig(255);
$storage->setMountPoint('mountpoint');
$storage->setBackendClass('\\OC\\Files\\Storage\\SMB');
$storage->setBackendOptions(['password' => 'testPassword']);
$newStorage = $this->service->addStorage($storage);
$this->assertEquals(1, $newStorage->getId());
$newStorage = $this->service->removeStorage(1);
$caught = false;
try {
$this->service->getStorage(1);
} catch (NotFoundException $e) {
$caught = true;
}
$this->assertTrue($caught);
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:17,代码来源:storagesservicetest.php
示例16: testListAuthIdentifier
public function testListAuthIdentifier()
{
$l10n = $this->getMock('\\OC_L10N', null, [], '', false);
$credentialsManager = $this->getMock('\\OCP\\Security\\ICredentialsManager');
$instance = $this->getInstance();
$mount1 = new StorageConfig();
$mount1->setAuthMechanism(new Password($l10n));
$mount1->setBackend(new Local($l10n, new NullMechanism($l10n)));
$mount2 = new StorageConfig();
$mount2->setAuthMechanism(new UserProvided($l10n, $credentialsManager));
$mount2->setBackend(new Local($l10n, new NullMechanism($l10n)));
$input = $this->getInput($instance, [], ['output' => 'json']);
$output = new BufferedOutput();
$instance->listMounts('', [$mount1, $mount2], $input, $output);
$output = json_decode($output->fetch(), true);
$this->assertNotEquals($output[0]['authentication_type'], $output[1]['authentication_type']);
}
开发者ID:ZverAleksey,项目名称:core,代码行数:17,代码来源:listcommandtest.php
示例17: getMount
/**
* @param $id
* @param $mountPoint
* @param $backendClass
* @param string $applicableIdentifier
* @param array $config
* @param array $options
* @param array $users
* @param array $groups
* @return StorageConfig
*/
protected function getMount($id, $mountPoint, $backendClass, $applicableIdentifier = 'password::password', $config = [], $options = [], $users = [], $groups = [])
{
$mount = new StorageConfig($id);
$mount->setMountPoint($mountPoint);
$mount->setBackendOptions($config);
$mount->setMountOptions($options);
$mount->setApplicableUsers($users);
$mount->setApplicableGroups($groups);
return $mount;
}
开发者ID:farukuzun,项目名称:core-1,代码行数:21,代码来源:commandtest.php
示例18: testJsonSerialization
public function testJsonSerialization()
{
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint('test');
$storageConfig->setBackendClass('\\OC\\Files\\Storage\\SMB');
$storageConfig->setBackendOptions(['user' => 'test', 'password' => 'password123']);
$storageConfig->setPriority(128);
$storageConfig->setApplicableUsers(['user1', 'user2']);
$storageConfig->setApplicableGroups(['group1', 'group2']);
$storageConfig->setMountOptions(['preview' => false]);
$json = $storageConfig->jsonSerialize();
$this->assertEquals(1, $json['id']);
$this->assertEquals('/test', $json['mountPoint']);
$this->assertEquals('\\OC\\Files\\Storage\\SMB', $json['backendClass']);
$this->assertEquals('test', $json['backendOptions']['user']);
$this->assertEquals('password123', $json['backendOptions']['password']);
$this->assertEquals(128, $json['priority']);
$this->assertEquals(['user1', 'user2'], $json['applicableUsers']);
$this->assertEquals(['group1', 'group2'], $json['applicableGroups']);
$this->assertEquals(['preview' => false], $json['mountOptions']);
}
开发者ID:samj1912,项目名称:repo,代码行数:21,代码来源:storageconfigtest.php
示例19: update
/**
* Update an external storage entry.
*
* @param int $id storage id
* @param string $mountPoint storage mount point
* @param string $backendClass backend class name
* @param array $backendOptions backend-specific options
* @param array $mountOptions mount-specific options
* @param array $applicableUsers users for which to mount the storage
* @param array $applicableGroups groups for which to mount the storage
* @param int $priority priority
*
* @return DataResponse
*/
public function update($id, $mountPoint, $backendClass, $backendOptions, $mountOptions, $applicableUsers, $applicableGroups, $priority)
{
$storage = new StorageConfig($id);
$storage->setMountPoint($mountPoint);
$storage->setBackendClass($backendClass);
$storage->setBackendOptions($backendOptions);
$storage->setMountOptions($mountOptions);
$storage->setApplicableUsers($applicableUsers);
$storage->setApplicableGroups($applicableGroups);
$storage->setPriority($priority);
$response = $this->validate($storage);
if (!empty($response)) {
return $response;
}
try {
$storage = $this->service->updateStorage($storage);
} catch (NotFoundException $e) {
return new DataResponse(['message' => (string) $this->l10n->t('Storage with id "%i" not found', array($id))], Http::STATUS_NOT_FOUND);
}
$this->updateStorageStatus($storage);
return new DataResponse($storage, Http::STATUS_OK);
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:36,代码来源:globalstoragescontroller.php
示例20: testAddOrUpdateStorageDisallowedBackend
public function testAddOrUpdateStorageDisallowedBackend()
{
$backend = $this->getBackendMock();
$backend->method('isVisibleFor')->with(BackendService::VISIBILITY_PERSONAL)->willReturn(false);
$authMech = $this->getAuthMechMock();
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint('mount');
$storageConfig->setBackend($backend);
$storageConfig->setAuthMechanism($authMech);
$storageConfig->setBackendOptions([]);
$this->service->expects($this->exactly(2))->method('createStorage')->will($this->returnValue($storageConfig));
$this->service->expects($this->never())->method('addStorage');
$this->service->expects($this->never())->method('updateStorage');
$response = $this->controller->create('mount', '\\OC\\Files\\Storage\\SMB', '\\Auth\\Mechanism', array(), [], [], [], null);
$this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
$response = $this->controller->update(1, 'mount', '\\OC\\Files\\Storage\\SMB', '\\Auth\\Mechanism', array(), [], [], [], null);
$this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
}
开发者ID:evanjt,项目名称:core,代码行数:18,代码来源:userstoragescontrollertest.php
注:本文中的OCA\Files_External\Lib\StorageConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论