@@ -32,65 +32,65 @@ |
||
| 32 | 32 | |
| 33 | 33 | class Admin implements ISettings { |
| 34 | 34 | |
| 35 | - /** @var IManager */ |
|
| 36 | - private $encryptionManager; |
|
| 35 | + /** @var IManager */ |
|
| 36 | + private $encryptionManager; |
|
| 37 | 37 | |
| 38 | - /** @var GlobalStoragesService */ |
|
| 39 | - private $globalStoragesService; |
|
| 38 | + /** @var GlobalStoragesService */ |
|
| 39 | + private $globalStoragesService; |
|
| 40 | 40 | |
| 41 | - /** @var BackendService */ |
|
| 42 | - private $backendService; |
|
| 41 | + /** @var BackendService */ |
|
| 42 | + private $backendService; |
|
| 43 | 43 | |
| 44 | - /** @var GlobalAuth */ |
|
| 45 | - private $globalAuth; |
|
| 44 | + /** @var GlobalAuth */ |
|
| 45 | + private $globalAuth; |
|
| 46 | 46 | |
| 47 | - public function __construct( |
|
| 48 | - IManager $encryptionManager, |
|
| 49 | - GlobalStoragesService $globalStoragesService, |
|
| 50 | - BackendService $backendService, |
|
| 51 | - GlobalAuth $globalAuth |
|
| 52 | - ) { |
|
| 53 | - $this->encryptionManager = $encryptionManager; |
|
| 54 | - $this->globalStoragesService = $globalStoragesService; |
|
| 55 | - $this->backendService = $backendService; |
|
| 56 | - $this->globalAuth = $globalAuth; |
|
| 57 | - } |
|
| 47 | + public function __construct( |
|
| 48 | + IManager $encryptionManager, |
|
| 49 | + GlobalStoragesService $globalStoragesService, |
|
| 50 | + BackendService $backendService, |
|
| 51 | + GlobalAuth $globalAuth |
|
| 52 | + ) { |
|
| 53 | + $this->encryptionManager = $encryptionManager; |
|
| 54 | + $this->globalStoragesService = $globalStoragesService; |
|
| 55 | + $this->backendService = $backendService; |
|
| 56 | + $this->globalAuth = $globalAuth; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return TemplateResponse |
|
| 61 | - */ |
|
| 62 | - public function getForm() { |
|
| 63 | - $parameters = [ |
|
| 64 | - 'encryptionEnabled' => $this->encryptionManager->isEnabled(), |
|
| 65 | - 'visibilityType' => BackendService::VISIBILITY_ADMIN, |
|
| 66 | - 'storages' => $this->globalStoragesService->getStorages(), |
|
| 67 | - 'backends' => $this->backendService->getAvailableBackends(), |
|
| 68 | - 'authMechanisms' => $this->backendService->getAuthMechanisms(), |
|
| 69 | - 'dependencies' => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()), |
|
| 70 | - 'allowUserMounting' => $this->backendService->isUserMountingAllowed(), |
|
| 71 | - 'globalCredentials' => $this->globalAuth->getAuth(''), |
|
| 72 | - 'globalCredentialsUid' => '', |
|
| 73 | - ]; |
|
| 59 | + /** |
|
| 60 | + * @return TemplateResponse |
|
| 61 | + */ |
|
| 62 | + public function getForm() { |
|
| 63 | + $parameters = [ |
|
| 64 | + 'encryptionEnabled' => $this->encryptionManager->isEnabled(), |
|
| 65 | + 'visibilityType' => BackendService::VISIBILITY_ADMIN, |
|
| 66 | + 'storages' => $this->globalStoragesService->getStorages(), |
|
| 67 | + 'backends' => $this->backendService->getAvailableBackends(), |
|
| 68 | + 'authMechanisms' => $this->backendService->getAuthMechanisms(), |
|
| 69 | + 'dependencies' => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()), |
|
| 70 | + 'allowUserMounting' => $this->backendService->isUserMountingAllowed(), |
|
| 71 | + 'globalCredentials' => $this->globalAuth->getAuth(''), |
|
| 72 | + 'globalCredentialsUid' => '', |
|
| 73 | + ]; |
|
| 74 | 74 | |
| 75 | - return new TemplateResponse('files_external', 'settings', $parameters, ''); |
|
| 76 | - } |
|
| 75 | + return new TemplateResponse('files_external', 'settings', $parameters, ''); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @return string the section ID, e.g. 'sharing' |
|
| 80 | - */ |
|
| 81 | - public function getSection() { |
|
| 82 | - return 'externalstorages'; |
|
| 83 | - } |
|
| 78 | + /** |
|
| 79 | + * @return string the section ID, e.g. 'sharing' |
|
| 80 | + */ |
|
| 81 | + public function getSection() { |
|
| 82 | + return 'externalstorages'; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @return int whether the form should be rather on the top or bottom of |
|
| 87 | - * the admin section. The forms are arranged in ascending order of the |
|
| 88 | - * priority values. It is required to return a value between 0 and 100. |
|
| 89 | - * |
|
| 90 | - * E.g.: 70 |
|
| 91 | - */ |
|
| 92 | - public function getPriority() { |
|
| 93 | - return 40; |
|
| 94 | - } |
|
| 85 | + /** |
|
| 86 | + * @return int whether the form should be rather on the top or bottom of |
|
| 87 | + * the admin section. The forms are arranged in ascending order of the |
|
| 88 | + * priority values. It is required to return a value between 0 and 100. |
|
| 89 | + * |
|
| 90 | + * E.g.: 70 |
|
| 91 | + */ |
|
| 92 | + public function getPriority() { |
|
| 93 | + return 40; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | } |
@@ -29,43 +29,43 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | trait LegacyDependencyCheckPolyfill { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return string |
|
| 34 | - */ |
|
| 35 | - abstract public function getStorageClass(); |
|
| 32 | + /** |
|
| 33 | + * @return string |
|
| 34 | + */ |
|
| 35 | + abstract public function getStorageClass(); |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Check if object is valid for use |
|
| 39 | - * |
|
| 40 | - * @return MissingDependency[] Unsatisfied dependencies |
|
| 41 | - */ |
|
| 42 | - public function checkDependencies() { |
|
| 43 | - $ret = []; |
|
| 37 | + /** |
|
| 38 | + * Check if object is valid for use |
|
| 39 | + * |
|
| 40 | + * @return MissingDependency[] Unsatisfied dependencies |
|
| 41 | + */ |
|
| 42 | + public function checkDependencies() { |
|
| 43 | + $ret = []; |
|
| 44 | 44 | |
| 45 | - $result = call_user_func([$this->getStorageClass(), 'checkDependencies']); |
|
| 46 | - if ($result !== true) { |
|
| 47 | - if (!is_array($result)) { |
|
| 48 | - $result = [$result]; |
|
| 49 | - } |
|
| 50 | - foreach ($result as $key => $value) { |
|
| 51 | - if (!($value instanceof MissingDependency)) { |
|
| 52 | - $module = null; |
|
| 53 | - $message = null; |
|
| 54 | - if (is_numeric($key)) { |
|
| 55 | - $module = $value; |
|
| 56 | - } else { |
|
| 57 | - $module = $key; |
|
| 58 | - $message = $value; |
|
| 59 | - } |
|
| 60 | - $value = new MissingDependency($module, $this); |
|
| 61 | - $value->setMessage($message); |
|
| 62 | - } |
|
| 63 | - $ret[] = $value; |
|
| 64 | - } |
|
| 65 | - } |
|
| 45 | + $result = call_user_func([$this->getStorageClass(), 'checkDependencies']); |
|
| 46 | + if ($result !== true) { |
|
| 47 | + if (!is_array($result)) { |
|
| 48 | + $result = [$result]; |
|
| 49 | + } |
|
| 50 | + foreach ($result as $key => $value) { |
|
| 51 | + if (!($value instanceof MissingDependency)) { |
|
| 52 | + $module = null; |
|
| 53 | + $message = null; |
|
| 54 | + if (is_numeric($key)) { |
|
| 55 | + $module = $value; |
|
| 56 | + } else { |
|
| 57 | + $module = $key; |
|
| 58 | + $message = $value; |
|
| 59 | + } |
|
| 60 | + $value = new MissingDependency($module, $this); |
|
| 61 | + $value->setMessage($message); |
|
| 62 | + } |
|
| 63 | + $ret[] = $value; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $ret; |
|
| 68 | - } |
|
| 67 | + return $ret; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
@@ -36,102 +36,102 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | trait VisibilityTrait { |
| 38 | 38 | |
| 39 | - /** @var int visibility */ |
|
| 40 | - protected $visibility = BackendService::VISIBILITY_DEFAULT; |
|
| 41 | - |
|
| 42 | - /** @var int allowed visibilities */ |
|
| 43 | - protected $allowedVisibility = BackendService::VISIBILITY_DEFAULT; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @return int |
|
| 47 | - */ |
|
| 48 | - public function getVisibility() { |
|
| 49 | - return $this->visibility; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Check if the backend is visible for a user type |
|
| 54 | - * |
|
| 55 | - * @param int $visibility |
|
| 56 | - * @return bool |
|
| 57 | - */ |
|
| 58 | - public function isVisibleFor($visibility) { |
|
| 59 | - if ($this->visibility & $visibility) { |
|
| 60 | - return true; |
|
| 61 | - } |
|
| 62 | - return false; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param int $visibility |
|
| 67 | - * @return self |
|
| 68 | - */ |
|
| 69 | - public function setVisibility($visibility) { |
|
| 70 | - $this->visibility = $visibility; |
|
| 71 | - $this->allowedVisibility |= $visibility; |
|
| 72 | - return $this; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @param int $visibility |
|
| 77 | - * @return self |
|
| 78 | - */ |
|
| 79 | - public function addVisibility($visibility) { |
|
| 80 | - return $this->setVisibility($this->visibility | $visibility); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @param int $visibility |
|
| 85 | - * @return self |
|
| 86 | - */ |
|
| 87 | - public function removeVisibility($visibility) { |
|
| 88 | - return $this->setVisibility($this->visibility & ~$visibility); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return int |
|
| 93 | - */ |
|
| 94 | - public function getAllowedVisibility() { |
|
| 95 | - return $this->allowedVisibility; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Check if the backend is allowed to be visible for a user type |
|
| 100 | - * |
|
| 101 | - * @param int $allowedVisibility |
|
| 102 | - * @return bool |
|
| 103 | - */ |
|
| 104 | - public function isAllowedVisibleFor($allowedVisibility) { |
|
| 105 | - if ($this->allowedVisibility & $allowedVisibility) { |
|
| 106 | - return true; |
|
| 107 | - } |
|
| 108 | - return false; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @param int $allowedVisibility |
|
| 113 | - * @return self |
|
| 114 | - */ |
|
| 115 | - public function setAllowedVisibility($allowedVisibility) { |
|
| 116 | - $this->allowedVisibility = $allowedVisibility; |
|
| 117 | - $this->visibility &= $allowedVisibility; |
|
| 118 | - return $this; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @param int $allowedVisibility |
|
| 123 | - * @return self |
|
| 124 | - */ |
|
| 125 | - public function addAllowedVisibility($allowedVisibility) { |
|
| 126 | - return $this->setAllowedVisibility($this->allowedVisibility | $allowedVisibility); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @param int $allowedVisibility |
|
| 131 | - * @return self |
|
| 132 | - */ |
|
| 133 | - public function removeAllowedVisibility($allowedVisibility) { |
|
| 134 | - return $this->setAllowedVisibility($this->allowedVisibility & ~$allowedVisibility); |
|
| 135 | - } |
|
| 39 | + /** @var int visibility */ |
|
| 40 | + protected $visibility = BackendService::VISIBILITY_DEFAULT; |
|
| 41 | + |
|
| 42 | + /** @var int allowed visibilities */ |
|
| 43 | + protected $allowedVisibility = BackendService::VISIBILITY_DEFAULT; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @return int |
|
| 47 | + */ |
|
| 48 | + public function getVisibility() { |
|
| 49 | + return $this->visibility; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Check if the backend is visible for a user type |
|
| 54 | + * |
|
| 55 | + * @param int $visibility |
|
| 56 | + * @return bool |
|
| 57 | + */ |
|
| 58 | + public function isVisibleFor($visibility) { |
|
| 59 | + if ($this->visibility & $visibility) { |
|
| 60 | + return true; |
|
| 61 | + } |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param int $visibility |
|
| 67 | + * @return self |
|
| 68 | + */ |
|
| 69 | + public function setVisibility($visibility) { |
|
| 70 | + $this->visibility = $visibility; |
|
| 71 | + $this->allowedVisibility |= $visibility; |
|
| 72 | + return $this; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @param int $visibility |
|
| 77 | + * @return self |
|
| 78 | + */ |
|
| 79 | + public function addVisibility($visibility) { |
|
| 80 | + return $this->setVisibility($this->visibility | $visibility); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param int $visibility |
|
| 85 | + * @return self |
|
| 86 | + */ |
|
| 87 | + public function removeVisibility($visibility) { |
|
| 88 | + return $this->setVisibility($this->visibility & ~$visibility); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return int |
|
| 93 | + */ |
|
| 94 | + public function getAllowedVisibility() { |
|
| 95 | + return $this->allowedVisibility; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Check if the backend is allowed to be visible for a user type |
|
| 100 | + * |
|
| 101 | + * @param int $allowedVisibility |
|
| 102 | + * @return bool |
|
| 103 | + */ |
|
| 104 | + public function isAllowedVisibleFor($allowedVisibility) { |
|
| 105 | + if ($this->allowedVisibility & $allowedVisibility) { |
|
| 106 | + return true; |
|
| 107 | + } |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @param int $allowedVisibility |
|
| 113 | + * @return self |
|
| 114 | + */ |
|
| 115 | + public function setAllowedVisibility($allowedVisibility) { |
|
| 116 | + $this->allowedVisibility = $allowedVisibility; |
|
| 117 | + $this->visibility &= $allowedVisibility; |
|
| 118 | + return $this; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @param int $allowedVisibility |
|
| 123 | + * @return self |
|
| 124 | + */ |
|
| 125 | + public function addAllowedVisibility($allowedVisibility) { |
|
| 126 | + return $this->setAllowedVisibility($this->allowedVisibility | $allowedVisibility); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param int $allowedVisibility |
|
| 131 | + * @return self |
|
| 132 | + */ |
|
| 133 | + public function removeAllowedVisibility($allowedVisibility) { |
|
| 134 | + return $this->setAllowedVisibility($this->allowedVisibility & ~$allowedVisibility); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | 137 | } |
@@ -28,167 +28,167 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class DefinitionParameter implements \JsonSerializable { |
| 30 | 30 | |
| 31 | - /** Value constants */ |
|
| 32 | - const VALUE_TEXT = 0; |
|
| 33 | - const VALUE_BOOLEAN = 1; |
|
| 34 | - const VALUE_PASSWORD = 2; |
|
| 35 | - const VALUE_HIDDEN = 3; |
|
| 36 | - |
|
| 37 | - /** Flag constants */ |
|
| 38 | - const FLAG_NONE = 0; |
|
| 39 | - const FLAG_OPTIONAL = 1; |
|
| 40 | - const FLAG_USER_PROVIDED = 2; |
|
| 41 | - |
|
| 42 | - /** @var string name of parameter */ |
|
| 43 | - private $name; |
|
| 44 | - |
|
| 45 | - /** @var string human-readable parameter text */ |
|
| 46 | - private $text; |
|
| 47 | - |
|
| 48 | - /** @var int value type, see self::VALUE_* constants */ |
|
| 49 | - private $type = self::VALUE_TEXT; |
|
| 50 | - |
|
| 51 | - /** @var int flags, see self::FLAG_* constants */ |
|
| 52 | - private $flags = self::FLAG_NONE; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @param string $name |
|
| 56 | - * @param string $text |
|
| 57 | - */ |
|
| 58 | - public function __construct($name, $text) { |
|
| 59 | - $this->name = $name; |
|
| 60 | - $this->text = $text; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 66 | - public function getName() { |
|
| 67 | - return $this->name; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function getText() { |
|
| 74 | - return $this->text; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Get value type |
|
| 79 | - * |
|
| 80 | - * @return int |
|
| 81 | - */ |
|
| 82 | - public function getType() { |
|
| 83 | - return $this->type; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Set value type |
|
| 88 | - * |
|
| 89 | - * @param int $type |
|
| 90 | - * @return self |
|
| 91 | - */ |
|
| 92 | - public function setType($type) { |
|
| 93 | - $this->type = $type; |
|
| 94 | - return $this; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @return string |
|
| 99 | - */ |
|
| 100 | - public function getTypeName() { |
|
| 101 | - switch ($this->type) { |
|
| 102 | - case self::VALUE_BOOLEAN: |
|
| 103 | - return 'boolean'; |
|
| 104 | - case self::VALUE_TEXT: |
|
| 105 | - return 'text'; |
|
| 106 | - case self::VALUE_PASSWORD: |
|
| 107 | - return 'password'; |
|
| 108 | - default: |
|
| 109 | - return 'unknown'; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return int |
|
| 115 | - */ |
|
| 116 | - public function getFlags() { |
|
| 117 | - return $this->flags; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @param int $flags |
|
| 122 | - * @return self |
|
| 123 | - */ |
|
| 124 | - public function setFlags($flags) { |
|
| 125 | - $this->flags = $flags; |
|
| 126 | - return $this; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @param int $flag |
|
| 131 | - * @return self |
|
| 132 | - */ |
|
| 133 | - public function setFlag($flag) { |
|
| 134 | - $this->flags |= $flag; |
|
| 135 | - return $this; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @param int $flag |
|
| 140 | - * @return bool |
|
| 141 | - */ |
|
| 142 | - public function isFlagSet($flag) { |
|
| 143 | - return (bool)($this->flags & $flag); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Serialize into JSON for client-side JS |
|
| 148 | - * |
|
| 149 | - * @return string |
|
| 150 | - */ |
|
| 151 | - public function jsonSerialize() { |
|
| 152 | - return [ |
|
| 153 | - 'value' => $this->getText(), |
|
| 154 | - 'flags' => $this->getFlags(), |
|
| 155 | - 'type' => $this->getType() |
|
| 156 | - ]; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - public function isOptional() { |
|
| 160 | - return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Validate a parameter value against this |
|
| 165 | - * Convert type as necessary |
|
| 166 | - * |
|
| 167 | - * @param mixed $value Value to check |
|
| 168 | - * @return bool success |
|
| 169 | - */ |
|
| 170 | - public function validateValue(&$value) { |
|
| 171 | - switch ($this->getType()) { |
|
| 172 | - case self::VALUE_BOOLEAN: |
|
| 173 | - if (!is_bool($value)) { |
|
| 174 | - switch ($value) { |
|
| 175 | - case 'true': |
|
| 176 | - $value = true; |
|
| 177 | - break; |
|
| 178 | - case 'false': |
|
| 179 | - $value = false; |
|
| 180 | - break; |
|
| 181 | - default: |
|
| 182 | - return false; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - break; |
|
| 186 | - default: |
|
| 187 | - if (!$value && !$this->isOptional()) { |
|
| 188 | - return false; |
|
| 189 | - } |
|
| 190 | - break; |
|
| 191 | - } |
|
| 192 | - return true; |
|
| 193 | - } |
|
| 31 | + /** Value constants */ |
|
| 32 | + const VALUE_TEXT = 0; |
|
| 33 | + const VALUE_BOOLEAN = 1; |
|
| 34 | + const VALUE_PASSWORD = 2; |
|
| 35 | + const VALUE_HIDDEN = 3; |
|
| 36 | + |
|
| 37 | + /** Flag constants */ |
|
| 38 | + const FLAG_NONE = 0; |
|
| 39 | + const FLAG_OPTIONAL = 1; |
|
| 40 | + const FLAG_USER_PROVIDED = 2; |
|
| 41 | + |
|
| 42 | + /** @var string name of parameter */ |
|
| 43 | + private $name; |
|
| 44 | + |
|
| 45 | + /** @var string human-readable parameter text */ |
|
| 46 | + private $text; |
|
| 47 | + |
|
| 48 | + /** @var int value type, see self::VALUE_* constants */ |
|
| 49 | + private $type = self::VALUE_TEXT; |
|
| 50 | + |
|
| 51 | + /** @var int flags, see self::FLAG_* constants */ |
|
| 52 | + private $flags = self::FLAG_NONE; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param string $name |
|
| 56 | + * @param string $text |
|
| 57 | + */ |
|
| 58 | + public function __construct($name, $text) { |
|
| 59 | + $this->name = $name; |
|
| 60 | + $this->text = $text; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | + public function getName() { |
|
| 67 | + return $this->name; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function getText() { |
|
| 74 | + return $this->text; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Get value type |
|
| 79 | + * |
|
| 80 | + * @return int |
|
| 81 | + */ |
|
| 82 | + public function getType() { |
|
| 83 | + return $this->type; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Set value type |
|
| 88 | + * |
|
| 89 | + * @param int $type |
|
| 90 | + * @return self |
|
| 91 | + */ |
|
| 92 | + public function setType($type) { |
|
| 93 | + $this->type = $type; |
|
| 94 | + return $this; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @return string |
|
| 99 | + */ |
|
| 100 | + public function getTypeName() { |
|
| 101 | + switch ($this->type) { |
|
| 102 | + case self::VALUE_BOOLEAN: |
|
| 103 | + return 'boolean'; |
|
| 104 | + case self::VALUE_TEXT: |
|
| 105 | + return 'text'; |
|
| 106 | + case self::VALUE_PASSWORD: |
|
| 107 | + return 'password'; |
|
| 108 | + default: |
|
| 109 | + return 'unknown'; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return int |
|
| 115 | + */ |
|
| 116 | + public function getFlags() { |
|
| 117 | + return $this->flags; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @param int $flags |
|
| 122 | + * @return self |
|
| 123 | + */ |
|
| 124 | + public function setFlags($flags) { |
|
| 125 | + $this->flags = $flags; |
|
| 126 | + return $this; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param int $flag |
|
| 131 | + * @return self |
|
| 132 | + */ |
|
| 133 | + public function setFlag($flag) { |
|
| 134 | + $this->flags |= $flag; |
|
| 135 | + return $this; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param int $flag |
|
| 140 | + * @return bool |
|
| 141 | + */ |
|
| 142 | + public function isFlagSet($flag) { |
|
| 143 | + return (bool)($this->flags & $flag); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Serialize into JSON for client-side JS |
|
| 148 | + * |
|
| 149 | + * @return string |
|
| 150 | + */ |
|
| 151 | + public function jsonSerialize() { |
|
| 152 | + return [ |
|
| 153 | + 'value' => $this->getText(), |
|
| 154 | + 'flags' => $this->getFlags(), |
|
| 155 | + 'type' => $this->getType() |
|
| 156 | + ]; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + public function isOptional() { |
|
| 160 | + return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Validate a parameter value against this |
|
| 165 | + * Convert type as necessary |
|
| 166 | + * |
|
| 167 | + * @param mixed $value Value to check |
|
| 168 | + * @return bool success |
|
| 169 | + */ |
|
| 170 | + public function validateValue(&$value) { |
|
| 171 | + switch ($this->getType()) { |
|
| 172 | + case self::VALUE_BOOLEAN: |
|
| 173 | + if (!is_bool($value)) { |
|
| 174 | + switch ($value) { |
|
| 175 | + case 'true': |
|
| 176 | + $value = true; |
|
| 177 | + break; |
|
| 178 | + case 'false': |
|
| 179 | + $value = false; |
|
| 180 | + break; |
|
| 181 | + default: |
|
| 182 | + return false; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + break; |
|
| 186 | + default: |
|
| 187 | + if (!$value && !$this->isOptional()) { |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 190 | + break; |
|
| 191 | + } |
|
| 192 | + return true; |
|
| 193 | + } |
|
| 194 | 194 | } |
@@ -39,31 +39,31 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class SessionCredentials extends AuthMechanism { |
| 41 | 41 | |
| 42 | - /** @var CredentialsStore */ |
|
| 43 | - private $credentialsStore; |
|
| 42 | + /** @var CredentialsStore */ |
|
| 43 | + private $credentialsStore; |
|
| 44 | 44 | |
| 45 | - public function __construct(IL10N $l, CredentialsStore $credentialsStore) { |
|
| 46 | - $this->credentialsStore = $credentialsStore; |
|
| 45 | + public function __construct(IL10N $l, CredentialsStore $credentialsStore) { |
|
| 46 | + $this->credentialsStore = $credentialsStore; |
|
| 47 | 47 | |
| 48 | - $this->setIdentifier('password::sessioncredentials') |
|
| 49 | - ->setScheme(self::SCHEME_PASSWORD) |
|
| 50 | - ->setText($l->t('Log-in credentials, save in session')) |
|
| 51 | - ->addParameters([]); |
|
| 52 | - } |
|
| 48 | + $this->setIdentifier('password::sessioncredentials') |
|
| 49 | + ->setScheme(self::SCHEME_PASSWORD) |
|
| 50 | + ->setText($l->t('Log-in credentials, save in session')) |
|
| 51 | + ->addParameters([]); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 55 | - try { |
|
| 56 | - $credentials = $this->credentialsStore->getLoginCredentials(); |
|
| 57 | - } catch (CredentialsUnavailableException $e) { |
|
| 58 | - throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved'); |
|
| 59 | - } |
|
| 54 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 55 | + try { |
|
| 56 | + $credentials = $this->credentialsStore->getLoginCredentials(); |
|
| 57 | + } catch (CredentialsUnavailableException $e) { |
|
| 58 | + throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved'); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $storage->setBackendOption('user', $credentials->getLoginName()); |
|
| 62 | - $storage->setBackendOption('password', $credentials->getPassword()); |
|
| 63 | - } |
|
| 61 | + $storage->setBackendOption('user', $credentials->getLoginName()); |
|
| 62 | + $storage->setBackendOption('password', $credentials->getPassword()); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function wrapStorage(Storage $storage) { |
|
| 66 | - return new SessionStorageWrapper(['storage' => $storage]); |
|
| 67 | - } |
|
| 65 | + public function wrapStorage(Storage $storage) { |
|
| 66 | + return new SessionStorageWrapper(['storage' => $storage]); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
@@ -38,56 +38,56 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | class LoginCredentials extends AuthMechanism { |
| 40 | 40 | |
| 41 | - const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials'; |
|
| 41 | + const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials'; |
|
| 42 | 42 | |
| 43 | - /** @var ISession */ |
|
| 44 | - protected $session; |
|
| 43 | + /** @var ISession */ |
|
| 44 | + protected $session; |
|
| 45 | 45 | |
| 46 | - /** @var ICredentialsManager */ |
|
| 47 | - protected $credentialsManager; |
|
| 46 | + /** @var ICredentialsManager */ |
|
| 47 | + protected $credentialsManager; |
|
| 48 | 48 | |
| 49 | - public function __construct(IL10N $l, ISession $session, ICredentialsManager $credentialsManager) { |
|
| 50 | - $this->session = $session; |
|
| 51 | - $this->credentialsManager = $credentialsManager; |
|
| 49 | + public function __construct(IL10N $l, ISession $session, ICredentialsManager $credentialsManager) { |
|
| 50 | + $this->session = $session; |
|
| 51 | + $this->credentialsManager = $credentialsManager; |
|
| 52 | 52 | |
| 53 | - $this |
|
| 54 | - ->setIdentifier('password::logincredentials') |
|
| 55 | - ->setScheme(self::SCHEME_PASSWORD) |
|
| 56 | - ->setText($l->t('Log-in credentials, save in database')) |
|
| 57 | - ->addParameters([ |
|
| 58 | - ]) |
|
| 59 | - ; |
|
| 53 | + $this |
|
| 54 | + ->setIdentifier('password::logincredentials') |
|
| 55 | + ->setScheme(self::SCHEME_PASSWORD) |
|
| 56 | + ->setText($l->t('Log-in credentials, save in database')) |
|
| 57 | + ->addParameters([ |
|
| 58 | + ]) |
|
| 59 | + ; |
|
| 60 | 60 | |
| 61 | - \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); |
|
| 62 | - } |
|
| 61 | + \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Hook listener on post login |
|
| 66 | - * |
|
| 67 | - * @param array $params |
|
| 68 | - */ |
|
| 69 | - public function authenticate(array $params) { |
|
| 70 | - $userId = $params['uid']; |
|
| 71 | - $credentials = [ |
|
| 72 | - 'user' => $this->session->get('loginname'), |
|
| 73 | - 'password' => $params['password'] |
|
| 74 | - ]; |
|
| 75 | - $this->credentialsManager->store($userId, self::CREDENTIALS_IDENTIFIER, $credentials); |
|
| 76 | - } |
|
| 64 | + /** |
|
| 65 | + * Hook listener on post login |
|
| 66 | + * |
|
| 67 | + * @param array $params |
|
| 68 | + */ |
|
| 69 | + public function authenticate(array $params) { |
|
| 70 | + $userId = $params['uid']; |
|
| 71 | + $credentials = [ |
|
| 72 | + 'user' => $this->session->get('loginname'), |
|
| 73 | + 'password' => $params['password'] |
|
| 74 | + ]; |
|
| 75 | + $this->credentialsManager->store($userId, self::CREDENTIALS_IDENTIFIER, $credentials); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 79 | - if (!isset($user)) { |
|
| 80 | - throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved'); |
|
| 81 | - } |
|
| 82 | - $uid = $user->getUID(); |
|
| 83 | - $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
| 78 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 79 | + if (!isset($user)) { |
|
| 80 | + throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved'); |
|
| 81 | + } |
|
| 82 | + $uid = $user->getUID(); |
|
| 83 | + $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
| 84 | 84 | |
| 85 | - if (!isset($credentials)) { |
|
| 86 | - throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved'); |
|
| 87 | - } |
|
| 85 | + if (!isset($credentials)) { |
|
| 86 | + throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $storage->setBackendOption('user', $credentials['user']); |
|
| 90 | - $storage->setBackendOption('password', $credentials['password']); |
|
| 91 | - } |
|
| 89 | + $storage->setBackendOption('user', $credentials['user']); |
|
| 90 | + $storage->setBackendOption('password', $credentials['password']); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | } |
@@ -38,52 +38,52 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | class UserProvided extends AuthMechanism implements IUserProvided { |
| 40 | 40 | |
| 41 | - const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; |
|
| 41 | + const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; |
|
| 42 | 42 | |
| 43 | - /** @var ICredentialsManager */ |
|
| 44 | - protected $credentialsManager; |
|
| 43 | + /** @var ICredentialsManager */ |
|
| 44 | + protected $credentialsManager; |
|
| 45 | 45 | |
| 46 | - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
| 47 | - $this->credentialsManager = $credentialsManager; |
|
| 46 | + public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
| 47 | + $this->credentialsManager = $credentialsManager; |
|
| 48 | 48 | |
| 49 | - $this |
|
| 50 | - ->setIdentifier('password::userprovided') |
|
| 51 | - ->setVisibility(BackendService::VISIBILITY_ADMIN) |
|
| 52 | - ->setScheme(self::SCHEME_PASSWORD) |
|
| 53 | - ->setText($l->t('User entered, store in database')) |
|
| 54 | - ->addParameters([ |
|
| 55 | - (new DefinitionParameter('user', $l->t('Username'))) |
|
| 56 | - ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
| 57 | - (new DefinitionParameter('password', $l->t('Password'))) |
|
| 58 | - ->setType(DefinitionParameter::VALUE_PASSWORD) |
|
| 59 | - ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
| 60 | - ]); |
|
| 61 | - } |
|
| 49 | + $this |
|
| 50 | + ->setIdentifier('password::userprovided') |
|
| 51 | + ->setVisibility(BackendService::VISIBILITY_ADMIN) |
|
| 52 | + ->setScheme(self::SCHEME_PASSWORD) |
|
| 53 | + ->setText($l->t('User entered, store in database')) |
|
| 54 | + ->addParameters([ |
|
| 55 | + (new DefinitionParameter('user', $l->t('Username'))) |
|
| 56 | + ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
| 57 | + (new DefinitionParameter('password', $l->t('Password'))) |
|
| 58 | + ->setType(DefinitionParameter::VALUE_PASSWORD) |
|
| 59 | + ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED), |
|
| 60 | + ]); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - private function getCredentialsIdentifier($storageId) { |
|
| 64 | - return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
| 65 | - } |
|
| 63 | + private function getCredentialsIdentifier($storageId) { |
|
| 64 | + return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function saveBackendOptions(IUser $user, $id, array $options) { |
|
| 68 | - $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ |
|
| 69 | - 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array |
|
| 70 | - 'password' => $options['password'] // this way we prevent users from being able to modify any other field |
|
| 71 | - ]); |
|
| 72 | - } |
|
| 67 | + public function saveBackendOptions(IUser $user, $id, array $options) { |
|
| 68 | + $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ |
|
| 69 | + 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array |
|
| 70 | + 'password' => $options['password'] // this way we prevent users from being able to modify any other field |
|
| 71 | + ]); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 75 | - if (!isset($user)) { |
|
| 76 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
| 77 | - } |
|
| 78 | - $uid = $user->getUID(); |
|
| 79 | - $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId())); |
|
| 74 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 75 | + if (!isset($user)) { |
|
| 76 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
| 77 | + } |
|
| 78 | + $uid = $user->getUID(); |
|
| 79 | + $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId())); |
|
| 80 | 80 | |
| 81 | - if (!isset($credentials)) { |
|
| 82 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
| 83 | - } |
|
| 81 | + if (!isset($credentials)) { |
|
| 82 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - $storage->setBackendOption('user', $credentials['user']); |
|
| 86 | - $storage->setBackendOption('password', $credentials['password']); |
|
| 87 | - } |
|
| 85 | + $storage->setBackendOption('user', $credentials['user']); |
|
| 86 | + $storage->setBackendOption('password', $credentials['password']); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | } |
@@ -36,54 +36,54 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class GlobalAuth extends AuthMechanism { |
| 38 | 38 | |
| 39 | - const CREDENTIALS_IDENTIFIER = 'password::global'; |
|
| 39 | + const CREDENTIALS_IDENTIFIER = 'password::global'; |
|
| 40 | 40 | |
| 41 | - /** @var ICredentialsManager */ |
|
| 42 | - protected $credentialsManager; |
|
| 41 | + /** @var ICredentialsManager */ |
|
| 42 | + protected $credentialsManager; |
|
| 43 | 43 | |
| 44 | - public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
| 45 | - $this->credentialsManager = $credentialsManager; |
|
| 44 | + public function __construct(IL10N $l, ICredentialsManager $credentialsManager) { |
|
| 45 | + $this->credentialsManager = $credentialsManager; |
|
| 46 | 46 | |
| 47 | - $this |
|
| 48 | - ->setIdentifier('password::global') |
|
| 49 | - ->setVisibility(BackendService::VISIBILITY_DEFAULT) |
|
| 50 | - ->setScheme(self::SCHEME_PASSWORD) |
|
| 51 | - ->setText($l->t('Global credentials')); |
|
| 52 | - } |
|
| 47 | + $this |
|
| 48 | + ->setIdentifier('password::global') |
|
| 49 | + ->setVisibility(BackendService::VISIBILITY_DEFAULT) |
|
| 50 | + ->setScheme(self::SCHEME_PASSWORD) |
|
| 51 | + ->setText($l->t('Global credentials')); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getAuth($uid) { |
|
| 55 | - $auth = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
| 56 | - if (!is_array($auth)) { |
|
| 57 | - return [ |
|
| 58 | - 'user' => '', |
|
| 59 | - 'password' => '' |
|
| 60 | - ]; |
|
| 61 | - } else { |
|
| 62 | - return $auth; |
|
| 63 | - } |
|
| 64 | - } |
|
| 54 | + public function getAuth($uid) { |
|
| 55 | + $auth = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
| 56 | + if (!is_array($auth)) { |
|
| 57 | + return [ |
|
| 58 | + 'user' => '', |
|
| 59 | + 'password' => '' |
|
| 60 | + ]; |
|
| 61 | + } else { |
|
| 62 | + return $auth; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function saveAuth($uid, $user, $password) { |
|
| 67 | - $this->credentialsManager->store($uid, self::CREDENTIALS_IDENTIFIER, [ |
|
| 68 | - 'user' => $user, |
|
| 69 | - 'password' => $password |
|
| 70 | - ]); |
|
| 71 | - } |
|
| 66 | + public function saveAuth($uid, $user, $password) { |
|
| 67 | + $this->credentialsManager->store($uid, self::CREDENTIALS_IDENTIFIER, [ |
|
| 68 | + 'user' => $user, |
|
| 69 | + 'password' => $password |
|
| 70 | + ]); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 74 | - if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) { |
|
| 75 | - $uid = ''; |
|
| 76 | - } elseif (is_null($user)) { |
|
| 77 | - throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
| 78 | - } else { |
|
| 79 | - $uid = $user->getUID(); |
|
| 80 | - } |
|
| 81 | - $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
| 73 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 74 | + if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) { |
|
| 75 | + $uid = ''; |
|
| 76 | + } elseif (is_null($user)) { |
|
| 77 | + throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); |
|
| 78 | + } else { |
|
| 79 | + $uid = $user->getUID(); |
|
| 80 | + } |
|
| 81 | + $credentials = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER); |
|
| 82 | 82 | |
| 83 | - if (is_array($credentials)) { |
|
| 84 | - $storage->setBackendOption('user', $credentials['user']); |
|
| 85 | - $storage->setBackendOption('password', $credentials['password']); |
|
| 86 | - } |
|
| 87 | - } |
|
| 83 | + if (is_array($credentials)) { |
|
| 84 | + $storage->setBackendOption('user', $credentials['user']); |
|
| 85 | + $storage->setBackendOption('password', $credentials['password']); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | } |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | * For auth mechanisms where the user needs to provide credentials |
| 29 | 29 | */ |
| 30 | 30 | interface IUserProvided { |
| 31 | - /** |
|
| 32 | - * @param IUser $user the user for which to save the user provided options |
|
| 33 | - * @param int $mountId the mount id to save the options for |
|
| 34 | - * @param array $options the user provided options |
|
| 35 | - */ |
|
| 36 | - public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
| 31 | + /** |
|
| 32 | + * @param IUser $user the user for which to save the user provided options |
|
| 33 | + * @param int $mountId the mount id to save the options for |
|
| 34 | + * @param array $options the user provided options |
|
| 35 | + */ |
|
| 36 | + public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
| 37 | 37 | } |