@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class Builtin extends AuthMechanism { |
31 | 31 | |
32 | - public function __construct(IL10N $l) { |
|
33 | - $this |
|
34 | - ->setIdentifier('builtin::builtin') |
|
35 | - ->setScheme(self::SCHEME_BUILTIN) |
|
36 | - ->setText($l->t('Builtin')) |
|
37 | - ; |
|
38 | - } |
|
32 | + public function __construct(IL10N $l) { |
|
33 | + $this |
|
34 | + ->setIdentifier('builtin::builtin') |
|
35 | + ->setScheme(self::SCHEME_BUILTIN) |
|
36 | + ->setText($l->t('Builtin')) |
|
37 | + ; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -51,71 +51,71 @@ |
||
51 | 51 | */ |
52 | 52 | class AuthMechanism implements \JsonSerializable { |
53 | 53 | |
54 | - /** Standard authentication schemes */ |
|
55 | - const SCHEME_NULL = 'null'; |
|
56 | - const SCHEME_BUILTIN = 'builtin'; |
|
57 | - const SCHEME_PASSWORD = 'password'; |
|
58 | - const SCHEME_OAUTH1 = 'oauth1'; |
|
59 | - const SCHEME_OAUTH2 = 'oauth2'; |
|
60 | - const SCHEME_PUBLICKEY = 'publickey'; |
|
61 | - const SCHEME_OPENSTACK = 'openstack'; |
|
54 | + /** Standard authentication schemes */ |
|
55 | + const SCHEME_NULL = 'null'; |
|
56 | + const SCHEME_BUILTIN = 'builtin'; |
|
57 | + const SCHEME_PASSWORD = 'password'; |
|
58 | + const SCHEME_OAUTH1 = 'oauth1'; |
|
59 | + const SCHEME_OAUTH2 = 'oauth2'; |
|
60 | + const SCHEME_PUBLICKEY = 'publickey'; |
|
61 | + const SCHEME_OPENSTACK = 'openstack'; |
|
62 | 62 | |
63 | - use VisibilityTrait; |
|
64 | - use FrontendDefinitionTrait; |
|
65 | - use StorageModifierTrait; |
|
66 | - use IdentifierTrait; |
|
63 | + use VisibilityTrait; |
|
64 | + use FrontendDefinitionTrait; |
|
65 | + use StorageModifierTrait; |
|
66 | + use IdentifierTrait; |
|
67 | 67 | |
68 | - /** @var string */ |
|
69 | - protected $scheme; |
|
68 | + /** @var string */ |
|
69 | + protected $scheme; |
|
70 | 70 | |
71 | - /** |
|
72 | - * Get the authentication scheme implemented |
|
73 | - * See self::SCHEME_* constants |
|
74 | - * |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getScheme() { |
|
78 | - return $this->scheme; |
|
79 | - } |
|
71 | + /** |
|
72 | + * Get the authentication scheme implemented |
|
73 | + * See self::SCHEME_* constants |
|
74 | + * |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getScheme() { |
|
78 | + return $this->scheme; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param string $scheme |
|
83 | - * @return self |
|
84 | - */ |
|
85 | - public function setScheme($scheme) { |
|
86 | - $this->scheme = $scheme; |
|
87 | - return $this; |
|
88 | - } |
|
81 | + /** |
|
82 | + * @param string $scheme |
|
83 | + * @return self |
|
84 | + */ |
|
85 | + public function setScheme($scheme) { |
|
86 | + $this->scheme = $scheme; |
|
87 | + return $this; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Serialize into JSON for client-side JS |
|
92 | - * |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function jsonSerialize() { |
|
96 | - $data = $this->jsonSerializeDefinition(); |
|
97 | - $data += $this->jsonSerializeIdentifier(); |
|
90 | + /** |
|
91 | + * Serialize into JSON for client-side JS |
|
92 | + * |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function jsonSerialize() { |
|
96 | + $data = $this->jsonSerializeDefinition(); |
|
97 | + $data += $this->jsonSerializeIdentifier(); |
|
98 | 98 | |
99 | - $data['scheme'] = $this->getScheme(); |
|
100 | - $data['visibility'] = $this->getVisibility(); |
|
99 | + $data['scheme'] = $this->getScheme(); |
|
100 | + $data['visibility'] = $this->getVisibility(); |
|
101 | 101 | |
102 | - return $data; |
|
103 | - } |
|
102 | + return $data; |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Check if parameters are satisfied in a StorageConfig |
|
107 | - * |
|
108 | - * @param StorageConfig $storage |
|
109 | - * @return bool |
|
110 | - */ |
|
111 | - public function validateStorage(StorageConfig $storage) { |
|
112 | - // does the backend actually support this scheme |
|
113 | - $supportedSchemes = $storage->getBackend()->getAuthSchemes(); |
|
114 | - if (!isset($supportedSchemes[$this->getScheme()])) { |
|
115 | - return false; |
|
116 | - } |
|
105 | + /** |
|
106 | + * Check if parameters are satisfied in a StorageConfig |
|
107 | + * |
|
108 | + * @param StorageConfig $storage |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | + public function validateStorage(StorageConfig $storage) { |
|
112 | + // does the backend actually support this scheme |
|
113 | + $supportedSchemes = $storage->getBackend()->getAuthSchemes(); |
|
114 | + if (!isset($supportedSchemes[$this->getScheme()])) { |
|
115 | + return false; |
|
116 | + } |
|
117 | 117 | |
118 | - return $this->validateStorageDefinition($storage); |
|
119 | - } |
|
118 | + return $this->validateStorageDefinition($storage); |
|
119 | + } |
|
120 | 120 | |
121 | 121 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | class NullMechanism extends AuthMechanism { |
31 | 31 | |
32 | - public function __construct(IL10N $l) { |
|
33 | - $this |
|
34 | - ->setIdentifier('null::null') |
|
35 | - ->setScheme(self::SCHEME_NULL) |
|
36 | - ->setText($l->t('None')) |
|
37 | - ; |
|
38 | - } |
|
32 | + public function __construct(IL10N $l) { |
|
33 | + $this |
|
34 | + ->setIdentifier('null::null') |
|
35 | + ->setScheme(self::SCHEME_NULL) |
|
36 | + ->setText($l->t('None')) |
|
37 | + ; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -29,33 +29,33 @@ |
||
29 | 29 | */ |
30 | 30 | trait PriorityTrait { |
31 | 31 | |
32 | - /** @var int initial priority */ |
|
33 | - protected $priority = BackendService::PRIORITY_DEFAULT; |
|
34 | - |
|
35 | - /** |
|
36 | - * @return int |
|
37 | - */ |
|
38 | - public function getPriority() { |
|
39 | - return $this->priority; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param int $priority |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public function setPriority($priority) { |
|
47 | - $this->priority = $priority; |
|
48 | - return $this; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @param PriorityTrait $a |
|
53 | - * @param PriorityTrait $b |
|
54 | - * @return int |
|
55 | - */ |
|
56 | - public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | - return ($a->getPriority() - $b->getPriority()); |
|
58 | - } |
|
32 | + /** @var int initial priority */ |
|
33 | + protected $priority = BackendService::PRIORITY_DEFAULT; |
|
34 | + |
|
35 | + /** |
|
36 | + * @return int |
|
37 | + */ |
|
38 | + public function getPriority() { |
|
39 | + return $this->priority; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param int $priority |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public function setPriority($priority) { |
|
47 | + $this->priority = $priority; |
|
48 | + return $this; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @param PriorityTrait $a |
|
53 | + * @param PriorityTrait $b |
|
54 | + * @return int |
|
55 | + */ |
|
56 | + public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) { |
|
57 | + return ($a->getPriority() - $b->getPriority()); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
61 | 61 |
@@ -30,10 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | interface IBackendProvider { |
32 | 32 | |
33 | - /** |
|
34 | - * @since 9.1.0 |
|
35 | - * @return Backend[] |
|
36 | - */ |
|
37 | - public function getBackends(); |
|
33 | + /** |
|
34 | + * @since 9.1.0 |
|
35 | + * @return Backend[] |
|
36 | + */ |
|
37 | + public function getBackends(); |
|
38 | 38 | |
39 | 39 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | interface IAuthMechanismProvider { |
32 | 32 | |
33 | - /** |
|
34 | - * @since 9.1.0 |
|
35 | - * @return AuthMechanism[] |
|
36 | - */ |
|
37 | - public function getAuthMechanisms(); |
|
33 | + /** |
|
34 | + * @since 9.1.0 |
|
35 | + * @return AuthMechanism[] |
|
36 | + */ |
|
37 | + public function getAuthMechanisms(); |
|
38 | 38 | |
39 | 39 | } |
@@ -31,14 +31,14 @@ |
||
31 | 31 | */ |
32 | 32 | class SessionStorageWrapper extends PermissionsMask { |
33 | 33 | |
34 | - /** |
|
35 | - * @param array $arguments ['storage' => $storage] |
|
36 | - */ |
|
37 | - public function __construct($arguments) { |
|
38 | - // disable sharing permission |
|
39 | - $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE; |
|
40 | - parent::__construct($arguments); |
|
41 | - } |
|
34 | + /** |
|
35 | + * @param array $arguments ['storage' => $storage] |
|
36 | + */ |
|
37 | + public function __construct($arguments) { |
|
38 | + // disable sharing permission |
|
39 | + $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE; |
|
40 | + parent::__construct($arguments); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
44 | 44 |
@@ -29,15 +29,15 @@ |
||
29 | 29 | * Authentication mechanism or backend has insufficient data |
30 | 30 | */ |
31 | 31 | class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException { |
32 | - /** |
|
33 | - * StorageNotAvailableException constructor. |
|
34 | - * |
|
35 | - * @param string $message |
|
36 | - * @param int $code |
|
37 | - * @param \Exception $previous |
|
38 | - * @since 6.0.0 |
|
39 | - */ |
|
40 | - public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) { |
|
41 | - parent::__construct($message, $code, $previous); |
|
42 | - } |
|
32 | + /** |
|
33 | + * StorageNotAvailableException constructor. |
|
34 | + * |
|
35 | + * @param string $message |
|
36 | + * @param int $code |
|
37 | + * @param \Exception $previous |
|
38 | + * @since 6.0.0 |
|
39 | + */ |
|
40 | + public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) { |
|
41 | + parent::__construct($message, $code, $previous); |
|
42 | + } |
|
43 | 43 | } |
@@ -30,101 +30,101 @@ |
||
30 | 30 | |
31 | 31 | abstract class StreamWrapper extends \OC\Files\Storage\Common { |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $path |
|
35 | - * @return string|null |
|
36 | - */ |
|
37 | - abstract public function constructUrl($path); |
|
38 | - |
|
39 | - public function mkdir($path) { |
|
40 | - return mkdir($this->constructUrl($path)); |
|
41 | - } |
|
42 | - |
|
43 | - public function rmdir($path) { |
|
44 | - if ($this->is_dir($path) && $this->isDeletable($path)) { |
|
45 | - $dh = $this->opendir($path); |
|
46 | - if (!is_resource($dh)) { |
|
47 | - return false; |
|
48 | - } |
|
49 | - while (($file = readdir($dh)) !== false) { |
|
50 | - if ($this->is_dir($path . '/' . $file)) { |
|
51 | - $this->rmdir($path . '/' . $file); |
|
52 | - } else { |
|
53 | - $this->unlink($path . '/' . $file); |
|
54 | - } |
|
55 | - } |
|
56 | - $url = $this->constructUrl($path); |
|
57 | - $success = rmdir($url); |
|
58 | - clearstatcache(false, $url); |
|
59 | - return $success; |
|
60 | - } else { |
|
61 | - return false; |
|
62 | - } |
|
63 | - } |
|
64 | - |
|
65 | - public function opendir($path) { |
|
66 | - return opendir($this->constructUrl($path)); |
|
67 | - } |
|
68 | - |
|
69 | - public function filetype($path) { |
|
70 | - return @filetype($this->constructUrl($path)); |
|
71 | - } |
|
72 | - |
|
73 | - public function file_exists($path) { |
|
74 | - return file_exists($this->constructUrl($path)); |
|
75 | - } |
|
76 | - |
|
77 | - public function unlink($path) { |
|
78 | - $url = $this->constructUrl($path); |
|
79 | - $success = unlink($url); |
|
80 | - // normally unlink() is supposed to do this implicitly, |
|
81 | - // but doing it anyway just to be sure |
|
82 | - clearstatcache(false, $url); |
|
83 | - return $success; |
|
84 | - } |
|
85 | - |
|
86 | - public function fopen($path, $mode) { |
|
87 | - return fopen($this->constructUrl($path), $mode); |
|
88 | - } |
|
89 | - |
|
90 | - public function touch($path, $mtime = null) { |
|
91 | - if ($this->file_exists($path)) { |
|
92 | - if (is_null($mtime)) { |
|
93 | - $fh = $this->fopen($path, 'a'); |
|
94 | - fwrite($fh, ''); |
|
95 | - fclose($fh); |
|
96 | - |
|
97 | - return true; |
|
98 | - } else { |
|
99 | - return false; //not supported |
|
100 | - } |
|
101 | - } else { |
|
102 | - $this->file_put_contents($path, ''); |
|
103 | - return true; |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $path |
|
109 | - * @param string $target |
|
110 | - */ |
|
111 | - public function getFile($path, $target) { |
|
112 | - return copy($this->constructUrl($path), $target); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @param string $target |
|
117 | - */ |
|
118 | - public function uploadFile($path, $target) { |
|
119 | - return copy($path, $this->constructUrl($target)); |
|
120 | - } |
|
121 | - |
|
122 | - public function rename($path1, $path2) { |
|
123 | - return rename($this->constructUrl($path1), $this->constructUrl($path2)); |
|
124 | - } |
|
125 | - |
|
126 | - public function stat($path) { |
|
127 | - return stat($this->constructUrl($path)); |
|
128 | - } |
|
33 | + /** |
|
34 | + * @param string $path |
|
35 | + * @return string|null |
|
36 | + */ |
|
37 | + abstract public function constructUrl($path); |
|
38 | + |
|
39 | + public function mkdir($path) { |
|
40 | + return mkdir($this->constructUrl($path)); |
|
41 | + } |
|
42 | + |
|
43 | + public function rmdir($path) { |
|
44 | + if ($this->is_dir($path) && $this->isDeletable($path)) { |
|
45 | + $dh = $this->opendir($path); |
|
46 | + if (!is_resource($dh)) { |
|
47 | + return false; |
|
48 | + } |
|
49 | + while (($file = readdir($dh)) !== false) { |
|
50 | + if ($this->is_dir($path . '/' . $file)) { |
|
51 | + $this->rmdir($path . '/' . $file); |
|
52 | + } else { |
|
53 | + $this->unlink($path . '/' . $file); |
|
54 | + } |
|
55 | + } |
|
56 | + $url = $this->constructUrl($path); |
|
57 | + $success = rmdir($url); |
|
58 | + clearstatcache(false, $url); |
|
59 | + return $success; |
|
60 | + } else { |
|
61 | + return false; |
|
62 | + } |
|
63 | + } |
|
64 | + |
|
65 | + public function opendir($path) { |
|
66 | + return opendir($this->constructUrl($path)); |
|
67 | + } |
|
68 | + |
|
69 | + public function filetype($path) { |
|
70 | + return @filetype($this->constructUrl($path)); |
|
71 | + } |
|
72 | + |
|
73 | + public function file_exists($path) { |
|
74 | + return file_exists($this->constructUrl($path)); |
|
75 | + } |
|
76 | + |
|
77 | + public function unlink($path) { |
|
78 | + $url = $this->constructUrl($path); |
|
79 | + $success = unlink($url); |
|
80 | + // normally unlink() is supposed to do this implicitly, |
|
81 | + // but doing it anyway just to be sure |
|
82 | + clearstatcache(false, $url); |
|
83 | + return $success; |
|
84 | + } |
|
85 | + |
|
86 | + public function fopen($path, $mode) { |
|
87 | + return fopen($this->constructUrl($path), $mode); |
|
88 | + } |
|
89 | + |
|
90 | + public function touch($path, $mtime = null) { |
|
91 | + if ($this->file_exists($path)) { |
|
92 | + if (is_null($mtime)) { |
|
93 | + $fh = $this->fopen($path, 'a'); |
|
94 | + fwrite($fh, ''); |
|
95 | + fclose($fh); |
|
96 | + |
|
97 | + return true; |
|
98 | + } else { |
|
99 | + return false; //not supported |
|
100 | + } |
|
101 | + } else { |
|
102 | + $this->file_put_contents($path, ''); |
|
103 | + return true; |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $path |
|
109 | + * @param string $target |
|
110 | + */ |
|
111 | + public function getFile($path, $target) { |
|
112 | + return copy($this->constructUrl($path), $target); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @param string $target |
|
117 | + */ |
|
118 | + public function uploadFile($path, $target) { |
|
119 | + return copy($path, $this->constructUrl($target)); |
|
120 | + } |
|
121 | + |
|
122 | + public function rename($path1, $path2) { |
|
123 | + return rename($this->constructUrl($path1), $this->constructUrl($path2)); |
|
124 | + } |
|
125 | + |
|
126 | + public function stat($path) { |
|
127 | + return stat($this->constructUrl($path)); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |