本文整理汇总了PHP中OCA\Files_External\Lib\StorageConfig::getAuthMechanism方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageConfig::getAuthMechanism方法的具体用法?PHP StorageConfig::getAuthMechanism怎么用?PHP StorageConfig::getAuthMechanism使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCA\Files_External\Lib\StorageConfig
的用法示例。
在下文中一共展示了StorageConfig::getAuthMechanism方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: 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;
}
示例3: manipulateStorageConfig
private function manipulateStorageConfig(StorageConfig $storage)
{
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage);
/** @var Backend */
$backend = $storage->getBackend();
$backend->manipulateStorageConfig($storage);
}
示例4: prepareMountPointEntry
/**
* Convert a StorageConfig to the legacy mountPoints array format
* There's a lot of extra information in here, to satisfy all of the legacy functions
*
* @param StorageConfig $storage
* @param bool $isPersonal
* @return array
*/
private static function prepareMountPointEntry(StorageConfig $storage, $isPersonal)
{
$mountEntry = [];
$mountEntry['mountpoint'] = substr($storage->getMountPoint(), 1);
// remove leading slash
$mountEntry['class'] = $storage->getBackend()->getIdentifier();
$mountEntry['backend'] = $storage->getBackend()->getText();
$mountEntry['authMechanism'] = $storage->getAuthMechanism()->getIdentifier();
$mountEntry['personal'] = $isPersonal;
$mountEntry['options'] = self::decryptPasswords($storage->getBackendOptions());
$mountEntry['mountOptions'] = $storage->getMountOptions();
$mountEntry['priority'] = $storage->getPriority();
$mountEntry['applicable'] = ['groups' => $storage->getApplicableGroups(), 'users' => $storage->getApplicableUsers()];
// if mountpoint is applicable to all users the old API expects ['all']
if (empty($mountEntry['applicable']['groups']) && empty($mountEntry['applicable']['users'])) {
$mountEntry['applicable']['users'] = ['all'];
}
$mountEntry['id'] = $storage->getId();
return $mountEntry;
}
示例5: addStorage
/**
* Add new storage to the configuration
*
* @param StorageConfig $newStorage storage attributes
*
* @return StorageConfig storage config, with added id
*/
public function addStorage(StorageConfig $newStorage)
{
$allStorages = $this->readConfig();
$configId = $this->dbConfig->addMount($newStorage->getMountPoint(), $newStorage->getBackend()->getIdentifier(), $newStorage->getAuthMechanism()->getIdentifier(), $newStorage->getPriority(), $this->getType());
$newStorage->setId($configId);
foreach ($newStorage->getApplicableUsers() as $user) {
$this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_USER, $user);
}
foreach ($newStorage->getApplicableGroups() as $group) {
$this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
}
foreach ($newStorage->getBackendOptions() as $key => $value) {
$this->dbConfig->setConfig($configId, $key, $value);
}
foreach ($newStorage->getMountOptions() as $key => $value) {
$this->dbConfig->setOption($configId, $key, $value);
}
if (count($newStorage->getApplicableUsers()) === 0 && count($newStorage->getApplicableGroups()) === 0) {
$this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
}
// add new storage
$allStorages[$configId] = $newStorage;
$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
$newStorage->setStatus(StorageNotAvailableException::STATUS_SUCCESS);
return $newStorage;
}
示例6: validateStorage
/**
* Validate storage
* FIXME: De-duplicate with StoragesController::validate()
*
* @param StorageConfig $storage
* @return bool
*/
protected function validateStorage(StorageConfig $storage)
{
/** @var Backend */
$backend = $storage->getBackend();
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
if (!$backend->isVisibleFor($this->getVisibilityType())) {
// not permitted to use backend
return false;
}
if (!$authMechanism->isVisibleFor($this->getVisibilityType())) {
// not permitted to use auth mechanism
return false;
}
return true;
}
示例7: getStorageId
/**
* Construct the storage implementation
*
* @param StorageConfig $storageConfig
* @return int
*/
private function getStorageId(StorageConfig $storageConfig)
{
try {
$class = $storageConfig->getBackend()->getStorageClass();
/** @var \OC\Files\Storage\Storage $storage */
$storage = new $class($storageConfig->getBackendOptions());
// auth mechanism should fire first
$storage = $storageConfig->getBackend()->wrapStorage($storage);
$storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
return $storage->getStorageCache()->getNumericId();
} catch (\Exception $e) {
return -1;
}
}
示例8: updateStorageStatus
/**
* Check whether the given storage is available / valid.
*
* Note that this operation can be time consuming depending
* on whether the remote storage is available or not.
*
* @param StorageConfig $storage storage configuration
*/
protected function updateStorageStatus(StorageConfig &$storage)
{
try {
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage);
/** @var Backend */
$backend = $storage->getBackend();
$backend->manipulateStorageConfig($storage);
// update status (can be time-consuming)
$storage->setStatus(\OC_Mount_Config::getBackendStatus($backend->getStorageClass(), $storage->getBackendOptions(), false));
} catch (InsufficientDataForMeaningfulAnswerException $e) {
$storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE, $this->l10n->t('Insufficient data: %s', [$e->getMessage()]));
} catch (StorageNotAvailableException $e) {
$storage->setStatus(\OC_Mount_Config::STATUS_ERROR, $e->getMessage());
} catch (\Exception $e) {
// FIXME: convert storage exceptions to StorageNotAvailableException
$storage->setStatus(\OC_Mount_Config::STATUS_ERROR, get_class($e) . ': ' . $e->getMessage());
}
}
示例9: sanitizeStorage
/**
* Remove sensitive data from a StorageConfig before returning it to the user
*
* @param StorageConfig $storage
*/
protected function sanitizeStorage(StorageConfig $storage)
{
$storage->setBackendOptions([]);
$storage->setMountOptions([]);
if ($storage->getAuthMechanism() instanceof IUserProvided) {
try {
$storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser());
} catch (InsufficientDataForMeaningfulAnswerException $e) {
// not configured yet
}
}
}
示例10: updateStorage
/**
* Update storage to the configuration
*
* @param StorageConfig $updatedStorage storage attributes
*
* @return StorageConfig storage config
* @throws NotFoundException if the given storage does not exist in the config
*/
public function updateStorage(StorageConfig $updatedStorage)
{
$id = $updatedStorage->getId();
$existingMount = $this->dbConfig->getMountById($id);
if (!is_array($existingMount)) {
throw new NotFoundException('Storage with id "' . $id . '" not found while updating storage');
}
$oldStorage = $this->getStorageConfigFromDBMount($existingMount);
$removedUsers = array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers());
$removedGroups = array_diff($oldStorage->getApplicableGroups(), $updatedStorage->getApplicableGroups());
$addedUsers = array_diff($updatedStorage->getApplicableUsers(), $oldStorage->getApplicableUsers());
$addedGroups = array_diff($updatedStorage->getApplicableGroups(), $oldStorage->getApplicableGroups());
$oldUserCount = count($oldStorage->getApplicableUsers());
$oldGroupCount = count($oldStorage->getApplicableGroups());
$newUserCount = count($oldStorage->getApplicableUsers());
$newGroupCount = count($oldStorage->getApplicableGroups());
$wasGlobal = $oldUserCount + $oldGroupCount === 0;
$isGlobal = $newUserCount + $newGroupCount === 0;
foreach ($removedUsers as $user) {
$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
}
foreach ($removedGroups as $group) {
$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
}
foreach ($addedUsers as $user) {
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
}
foreach ($addedGroups as $group) {
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
}
if ($wasGlobal && !$isGlobal) {
$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
} else {
if (!$wasGlobal && $isGlobal) {
$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
}
}
$changedConfig = array_diff_assoc($updatedStorage->getBackendOptions(), $oldStorage->getBackendOptions());
$changedOptions = array_diff_assoc($updatedStorage->getMountOptions(), $oldStorage->getMountOptions());
foreach ($changedConfig as $key => $value) {
$this->dbConfig->setConfig($id, $key, $value);
}
foreach ($changedOptions as $key => $value) {
$this->dbConfig->setOption($id, $key, $value);
}
if ($updatedStorage->getMountPoint() !== $oldStorage->getMountPoint()) {
$this->dbConfig->setMountPoint($id, $updatedStorage->getMountPoint());
}
if ($updatedStorage->getAuthMechanism()->getIdentifier() !== $oldStorage->getAuthMechanism()->getIdentifier()) {
$this->dbConfig->setAuthBackend($id, $updatedStorage->getAuthMechanism()->getIdentifier());
}
$this->triggerChangeHooks($oldStorage, $updatedStorage);
return $this->getStorage($id);
}
示例11: prepareMountPointEntry
/**
* Convert a StorageConfig to the legacy mountPoints array format
* There's a lot of extra information in here, to satisfy all of the legacy functions
*
* @param StorageConfig $storage
* @param bool $isPersonal
* @return array
*/
private static function prepareMountPointEntry(StorageConfig $storage, $isPersonal)
{
$mountEntry = [];
$mountEntry['mountpoint'] = substr($storage->getMountPoint(), 1);
// remove leading slash
$mountEntry['class'] = $storage->getBackend()->getIdentifier();
$mountEntry['backend'] = $storage->getBackend()->getText();
$mountEntry['authMechanism'] = $storage->getAuthMechanism()->getIdentifier();
$mountEntry['personal'] = $isPersonal;
$mountEntry['options'] = self::decryptPasswords($storage->getBackendOptions());
$mountEntry['mountOptions'] = $storage->getMountOptions();
$mountEntry['priority'] = $storage->getPriority();
$mountEntry['applicable'] = ['groups' => $storage->getApplicableGroups(), 'users' => $storage->getApplicableUsers()];
$mountEntry['id'] = $storage->getId();
// $mountEntry['storage_id'] = null; // we don't store this!
return $mountEntry;
}
示例12: updateStorageStatus
/**
* Check whether the given storage is available / valid.
*
* Note that this operation can be time consuming depending
* on whether the remote storage is available or not.
*
* @param StorageConfig $storage storage configuration
*/
protected function updateStorageStatus(StorageConfig &$storage)
{
try {
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage);
/** @var Backend */
$backend = $storage->getBackend();
$backend->manipulateStorageConfig($storage);
// update status (can be time-consuming)
$storage->setStatus(\OC_Mount_Config::getBackendStatus($backend->getStorageClass(), $storage->getBackendOptions(), false));
} catch (InsufficientDataForMeaningfulAnswerException $e) {
$storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE);
} catch (StorageNotAvailableException $e) {
$storage->setStatus(\OC_Mount_Config::STATUS_ERROR);
}
}