@@ -27,51 +27,51 @@ |
||
27 | 27 | namespace OC\Security\FeaturePolicy; |
28 | 28 | |
29 | 29 | class FeaturePolicy extends \OCP\AppFramework\Http\FeaturePolicy { |
30 | - public function getAutoplayDomains(): array { |
|
31 | - return $this->autoplayDomains; |
|
32 | - } |
|
30 | + public function getAutoplayDomains(): array { |
|
31 | + return $this->autoplayDomains; |
|
32 | + } |
|
33 | 33 | |
34 | - public function setAutoplayDomains(array $autoplayDomains): void { |
|
35 | - $this->autoplayDomains = $autoplayDomains; |
|
36 | - } |
|
34 | + public function setAutoplayDomains(array $autoplayDomains): void { |
|
35 | + $this->autoplayDomains = $autoplayDomains; |
|
36 | + } |
|
37 | 37 | |
38 | - public function getCameraDomains(): array { |
|
39 | - return $this->cameraDomains; |
|
40 | - } |
|
38 | + public function getCameraDomains(): array { |
|
39 | + return $this->cameraDomains; |
|
40 | + } |
|
41 | 41 | |
42 | - public function setCameraDomains(array $cameraDomains): void { |
|
43 | - $this->cameraDomains = $cameraDomains; |
|
44 | - } |
|
42 | + public function setCameraDomains(array $cameraDomains): void { |
|
43 | + $this->cameraDomains = $cameraDomains; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getFullscreenDomains(): array { |
|
47 | - return $this->fullscreenDomains; |
|
48 | - } |
|
46 | + public function getFullscreenDomains(): array { |
|
47 | + return $this->fullscreenDomains; |
|
48 | + } |
|
49 | 49 | |
50 | - public function setFullscreenDomains(array $fullscreenDomains): void { |
|
51 | - $this->fullscreenDomains = $fullscreenDomains; |
|
52 | - } |
|
50 | + public function setFullscreenDomains(array $fullscreenDomains): void { |
|
51 | + $this->fullscreenDomains = $fullscreenDomains; |
|
52 | + } |
|
53 | 53 | |
54 | - public function getGeolocationDomains(): array { |
|
55 | - return $this->geolocationDomains; |
|
56 | - } |
|
54 | + public function getGeolocationDomains(): array { |
|
55 | + return $this->geolocationDomains; |
|
56 | + } |
|
57 | 57 | |
58 | - public function setGeolocationDomains(array $geolocationDomains): void { |
|
59 | - $this->geolocationDomains = $geolocationDomains; |
|
60 | - } |
|
58 | + public function setGeolocationDomains(array $geolocationDomains): void { |
|
59 | + $this->geolocationDomains = $geolocationDomains; |
|
60 | + } |
|
61 | 61 | |
62 | - public function getMicrophoneDomains(): array { |
|
63 | - return $this->microphoneDomains; |
|
64 | - } |
|
62 | + public function getMicrophoneDomains(): array { |
|
63 | + return $this->microphoneDomains; |
|
64 | + } |
|
65 | 65 | |
66 | - public function setMicrophoneDomains(array $microphoneDomains): void { |
|
67 | - $this->microphoneDomains = $microphoneDomains; |
|
68 | - } |
|
66 | + public function setMicrophoneDomains(array $microphoneDomains): void { |
|
67 | + $this->microphoneDomains = $microphoneDomains; |
|
68 | + } |
|
69 | 69 | |
70 | - public function getPaymentDomains(): array { |
|
71 | - return $this->paymentDomains; |
|
72 | - } |
|
70 | + public function getPaymentDomains(): array { |
|
71 | + return $this->paymentDomains; |
|
72 | + } |
|
73 | 73 | |
74 | - public function setPaymentDomains(array $paymentDomains): void { |
|
75 | - $this->paymentDomains = $paymentDomains; |
|
76 | - } |
|
74 | + public function setPaymentDomains(array $paymentDomains): void { |
|
75 | + $this->paymentDomains = $paymentDomains; |
|
76 | + } |
|
77 | 77 | } |
@@ -32,76 +32,76 @@ |
||
32 | 32 | use OCP\IUserManager; |
33 | 33 | |
34 | 34 | class Signer { |
35 | - /** @var Manager */ |
|
36 | - private $keyManager; |
|
37 | - /** @var ITimeFactory */ |
|
38 | - private $timeFactory; |
|
39 | - /** @var IUserManager */ |
|
40 | - private $userManager; |
|
35 | + /** @var Manager */ |
|
36 | + private $keyManager; |
|
37 | + /** @var ITimeFactory */ |
|
38 | + private $timeFactory; |
|
39 | + /** @var IUserManager */ |
|
40 | + private $userManager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param Manager $keyManager |
|
44 | - * @param ITimeFactory $timeFactory |
|
45 | - * @param IUserManager $userManager |
|
46 | - */ |
|
47 | - public function __construct(Manager $keyManager, |
|
48 | - ITimeFactory $timeFactory, |
|
49 | - IUserManager $userManager) { |
|
50 | - $this->keyManager = $keyManager; |
|
51 | - $this->timeFactory = $timeFactory; |
|
52 | - $this->userManager = $userManager; |
|
53 | - } |
|
42 | + /** |
|
43 | + * @param Manager $keyManager |
|
44 | + * @param ITimeFactory $timeFactory |
|
45 | + * @param IUserManager $userManager |
|
46 | + */ |
|
47 | + public function __construct(Manager $keyManager, |
|
48 | + ITimeFactory $timeFactory, |
|
49 | + IUserManager $userManager) { |
|
50 | + $this->keyManager = $keyManager; |
|
51 | + $this->timeFactory = $timeFactory; |
|
52 | + $this->userManager = $userManager; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns a signed blob for $data |
|
57 | - * |
|
58 | - * @param string $type |
|
59 | - * @param array $data |
|
60 | - * @param IUser $user |
|
61 | - * @return array ['message', 'signature'] |
|
62 | - */ |
|
63 | - public function sign(string $type, array $data, IUser $user): array { |
|
64 | - $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
65 | - $data = [ |
|
66 | - 'data' => $data, |
|
67 | - 'type' => $type, |
|
68 | - 'signer' => $user->getCloudId(), |
|
69 | - 'timestamp' => $this->timeFactory->getTime(), |
|
70 | - ]; |
|
71 | - openssl_sign(json_encode($data), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
55 | + /** |
|
56 | + * Returns a signed blob for $data |
|
57 | + * |
|
58 | + * @param string $type |
|
59 | + * @param array $data |
|
60 | + * @param IUser $user |
|
61 | + * @return array ['message', 'signature'] |
|
62 | + */ |
|
63 | + public function sign(string $type, array $data, IUser $user): array { |
|
64 | + $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
65 | + $data = [ |
|
66 | + 'data' => $data, |
|
67 | + 'type' => $type, |
|
68 | + 'signer' => $user->getCloudId(), |
|
69 | + 'timestamp' => $this->timeFactory->getTime(), |
|
70 | + ]; |
|
71 | + openssl_sign(json_encode($data), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
72 | 72 | |
73 | - return [ |
|
74 | - 'message' => $data, |
|
75 | - 'signature' => base64_encode($signature), |
|
76 | - ]; |
|
77 | - } |
|
73 | + return [ |
|
74 | + 'message' => $data, |
|
75 | + 'signature' => base64_encode($signature), |
|
76 | + ]; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Whether the data is signed properly |
|
81 | - * |
|
82 | - * @param array $data |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function verify(array $data): bool { |
|
86 | - if (isset($data['message']) |
|
87 | - && isset($data['signature']) |
|
88 | - && isset($data['message']['signer']) |
|
89 | - ) { |
|
90 | - $location = strrpos($data['message']['signer'], '@'); |
|
91 | - $userId = substr($data['message']['signer'], 0, $location); |
|
79 | + /** |
|
80 | + * Whether the data is signed properly |
|
81 | + * |
|
82 | + * @param array $data |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function verify(array $data): bool { |
|
86 | + if (isset($data['message']) |
|
87 | + && isset($data['signature']) |
|
88 | + && isset($data['message']['signer']) |
|
89 | + ) { |
|
90 | + $location = strrpos($data['message']['signer'], '@'); |
|
91 | + $userId = substr($data['message']['signer'], 0, $location); |
|
92 | 92 | |
93 | - $user = $this->userManager->get($userId); |
|
94 | - if ($user !== null) { |
|
95 | - $key = $this->keyManager->getKey($user); |
|
96 | - return (bool)openssl_verify( |
|
97 | - json_encode($data['message']), |
|
98 | - base64_decode($data['signature']), |
|
99 | - $key->getPublic(), |
|
100 | - OPENSSL_ALGO_SHA512 |
|
101 | - ); |
|
102 | - } |
|
103 | - } |
|
93 | + $user = $this->userManager->get($userId); |
|
94 | + if ($user !== null) { |
|
95 | + $key = $this->keyManager->getKey($user); |
|
96 | + return (bool)openssl_verify( |
|
97 | + json_encode($data['message']), |
|
98 | + base64_decode($data['signature']), |
|
99 | + $key->getPublic(), |
|
100 | + OPENSSL_ALGO_SHA512 |
|
101 | + ); |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - return false; |
|
106 | - } |
|
105 | + return false; |
|
106 | + } |
|
107 | 107 | } |
@@ -36,46 +36,46 @@ |
||
36 | 36 | * @package OC\Security\CSRF |
37 | 37 | */ |
38 | 38 | class CsrfToken { |
39 | - /** @var string */ |
|
40 | - private $value; |
|
41 | - /** @var string */ |
|
42 | - private $encryptedValue = ''; |
|
39 | + /** @var string */ |
|
40 | + private $value; |
|
41 | + /** @var string */ |
|
42 | + private $encryptedValue = ''; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string $value Value of the token. Can be encrypted or not encrypted. |
|
46 | - */ |
|
47 | - public function __construct(string $value) { |
|
48 | - $this->value = $value; |
|
49 | - } |
|
44 | + /** |
|
45 | + * @param string $value Value of the token. Can be encrypted or not encrypted. |
|
46 | + */ |
|
47 | + public function __construct(string $value) { |
|
48 | + $this->value = $value; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Encrypted value of the token. This is used to mitigate BREACH alike |
|
53 | - * vulnerabilities. For display measures do use this functionality. |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getEncryptedValue(): string { |
|
58 | - if ($this->encryptedValue === '') { |
|
59 | - $sharedSecret = random_bytes(\strlen($this->value)); |
|
60 | - $this->encryptedValue = base64_encode($this->value ^ $sharedSecret) . ':' . base64_encode($sharedSecret); |
|
61 | - } |
|
51 | + /** |
|
52 | + * Encrypted value of the token. This is used to mitigate BREACH alike |
|
53 | + * vulnerabilities. For display measures do use this functionality. |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getEncryptedValue(): string { |
|
58 | + if ($this->encryptedValue === '') { |
|
59 | + $sharedSecret = random_bytes(\strlen($this->value)); |
|
60 | + $this->encryptedValue = base64_encode($this->value ^ $sharedSecret) . ':' . base64_encode($sharedSecret); |
|
61 | + } |
|
62 | 62 | |
63 | - return $this->encryptedValue; |
|
64 | - } |
|
63 | + return $this->encryptedValue; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * The unencrypted value of the token. Used for decrypting an already |
|
68 | - * encrypted token. |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getDecryptedValue(): string { |
|
73 | - $token = explode(':', $this->value); |
|
74 | - if (\count($token) !== 2) { |
|
75 | - return ''; |
|
76 | - } |
|
77 | - $obfuscatedToken = $token[0]; |
|
78 | - $secret = $token[1]; |
|
79 | - return base64_decode($obfuscatedToken) ^ base64_decode($secret); |
|
80 | - } |
|
66 | + /** |
|
67 | + * The unencrypted value of the token. Used for decrypting an already |
|
68 | + * encrypted token. |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getDecryptedValue(): string { |
|
73 | + $token = explode(':', $this->value); |
|
74 | + if (\count($token) !== 2) { |
|
75 | + return ''; |
|
76 | + } |
|
77 | + $obfuscatedToken = $token[0]; |
|
78 | + $secret = $token[1]; |
|
79 | + return base64_decode($obfuscatedToken) ^ base64_decode($secret); |
|
80 | + } |
|
81 | 81 | } |
@@ -35,59 +35,59 @@ |
||
35 | 35 | * @package OC\Security\CSRF\TokenStorage |
36 | 36 | */ |
37 | 37 | class SessionStorage { |
38 | - /** @var ISession */ |
|
39 | - private $session; |
|
38 | + /** @var ISession */ |
|
39 | + private $session; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param ISession $session |
|
43 | - */ |
|
44 | - public function __construct(ISession $session) { |
|
45 | - $this->session = $session; |
|
46 | - } |
|
41 | + /** |
|
42 | + * @param ISession $session |
|
43 | + */ |
|
44 | + public function __construct(ISession $session) { |
|
45 | + $this->session = $session; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param ISession $session |
|
50 | - */ |
|
51 | - public function setSession(ISession $session) { |
|
52 | - $this->session = $session; |
|
53 | - } |
|
48 | + /** |
|
49 | + * @param ISession $session |
|
50 | + */ |
|
51 | + public function setSession(ISession $session) { |
|
52 | + $this->session = $session; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns the current token or throws an exception if none is found. |
|
57 | - * |
|
58 | - * @return string |
|
59 | - * @throws \Exception |
|
60 | - */ |
|
61 | - public function getToken(): string { |
|
62 | - $token = $this->session->get('requesttoken'); |
|
63 | - if (empty($token)) { |
|
64 | - throw new \Exception('Session does not contain a requesttoken'); |
|
65 | - } |
|
55 | + /** |
|
56 | + * Returns the current token or throws an exception if none is found. |
|
57 | + * |
|
58 | + * @return string |
|
59 | + * @throws \Exception |
|
60 | + */ |
|
61 | + public function getToken(): string { |
|
62 | + $token = $this->session->get('requesttoken'); |
|
63 | + if (empty($token)) { |
|
64 | + throw new \Exception('Session does not contain a requesttoken'); |
|
65 | + } |
|
66 | 66 | |
67 | - return $token; |
|
68 | - } |
|
67 | + return $token; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Set the valid current token to $value. |
|
72 | - * |
|
73 | - * @param string $value |
|
74 | - */ |
|
75 | - public function setToken(string $value) { |
|
76 | - $this->session->set('requesttoken', $value); |
|
77 | - } |
|
70 | + /** |
|
71 | + * Set the valid current token to $value. |
|
72 | + * |
|
73 | + * @param string $value |
|
74 | + */ |
|
75 | + public function setToken(string $value) { |
|
76 | + $this->session->set('requesttoken', $value); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Removes the current token. |
|
81 | - */ |
|
82 | - public function removeToken() { |
|
83 | - $this->session->remove('requesttoken'); |
|
84 | - } |
|
85 | - /** |
|
86 | - * Whether the storage has a storage. |
|
87 | - * |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function hasToken(): bool { |
|
91 | - return $this->session->exists('requesttoken'); |
|
92 | - } |
|
79 | + /** |
|
80 | + * Removes the current token. |
|
81 | + */ |
|
82 | + public function removeToken() { |
|
83 | + $this->session->remove('requesttoken'); |
|
84 | + } |
|
85 | + /** |
|
86 | + * Whether the storage has a storage. |
|
87 | + * |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function hasToken(): bool { |
|
91 | + return $this->session->exists('requesttoken'); |
|
92 | + } |
|
93 | 93 | } |
@@ -34,78 +34,78 @@ |
||
34 | 34 | * @package OC\Security\CSRF |
35 | 35 | */ |
36 | 36 | class CsrfTokenManager { |
37 | - /** @var CsrfTokenGenerator */ |
|
38 | - private $tokenGenerator; |
|
39 | - /** @var SessionStorage */ |
|
40 | - private $sessionStorage; |
|
41 | - /** @var CsrfToken|null */ |
|
42 | - private $csrfToken = null; |
|
37 | + /** @var CsrfTokenGenerator */ |
|
38 | + private $tokenGenerator; |
|
39 | + /** @var SessionStorage */ |
|
40 | + private $sessionStorage; |
|
41 | + /** @var CsrfToken|null */ |
|
42 | + private $csrfToken = null; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param CsrfTokenGenerator $tokenGenerator |
|
46 | - * @param SessionStorage $storageInterface |
|
47 | - */ |
|
48 | - public function __construct(CsrfTokenGenerator $tokenGenerator, |
|
49 | - SessionStorage $storageInterface) { |
|
50 | - $this->tokenGenerator = $tokenGenerator; |
|
51 | - $this->sessionStorage = $storageInterface; |
|
52 | - } |
|
44 | + /** |
|
45 | + * @param CsrfTokenGenerator $tokenGenerator |
|
46 | + * @param SessionStorage $storageInterface |
|
47 | + */ |
|
48 | + public function __construct(CsrfTokenGenerator $tokenGenerator, |
|
49 | + SessionStorage $storageInterface) { |
|
50 | + $this->tokenGenerator = $tokenGenerator; |
|
51 | + $this->sessionStorage = $storageInterface; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Returns the current CSRF token, if none set it will create a new one. |
|
56 | - * |
|
57 | - * @return CsrfToken |
|
58 | - */ |
|
59 | - public function getToken(): CsrfToken { |
|
60 | - if (!\is_null($this->csrfToken)) { |
|
61 | - return $this->csrfToken; |
|
62 | - } |
|
54 | + /** |
|
55 | + * Returns the current CSRF token, if none set it will create a new one. |
|
56 | + * |
|
57 | + * @return CsrfToken |
|
58 | + */ |
|
59 | + public function getToken(): CsrfToken { |
|
60 | + if (!\is_null($this->csrfToken)) { |
|
61 | + return $this->csrfToken; |
|
62 | + } |
|
63 | 63 | |
64 | - if ($this->sessionStorage->hasToken()) { |
|
65 | - $value = $this->sessionStorage->getToken(); |
|
66 | - } else { |
|
67 | - $value = $this->tokenGenerator->generateToken(); |
|
68 | - $this->sessionStorage->setToken($value); |
|
69 | - } |
|
64 | + if ($this->sessionStorage->hasToken()) { |
|
65 | + $value = $this->sessionStorage->getToken(); |
|
66 | + } else { |
|
67 | + $value = $this->tokenGenerator->generateToken(); |
|
68 | + $this->sessionStorage->setToken($value); |
|
69 | + } |
|
70 | 70 | |
71 | - $this->csrfToken = new CsrfToken($value); |
|
72 | - return $this->csrfToken; |
|
73 | - } |
|
71 | + $this->csrfToken = new CsrfToken($value); |
|
72 | + return $this->csrfToken; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Invalidates any current token and sets a new one. |
|
77 | - * |
|
78 | - * @return CsrfToken |
|
79 | - */ |
|
80 | - public function refreshToken(): CsrfToken { |
|
81 | - $value = $this->tokenGenerator->generateToken(); |
|
82 | - $this->sessionStorage->setToken($value); |
|
83 | - $this->csrfToken = new CsrfToken($value); |
|
84 | - return $this->csrfToken; |
|
85 | - } |
|
75 | + /** |
|
76 | + * Invalidates any current token and sets a new one. |
|
77 | + * |
|
78 | + * @return CsrfToken |
|
79 | + */ |
|
80 | + public function refreshToken(): CsrfToken { |
|
81 | + $value = $this->tokenGenerator->generateToken(); |
|
82 | + $this->sessionStorage->setToken($value); |
|
83 | + $this->csrfToken = new CsrfToken($value); |
|
84 | + return $this->csrfToken; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Remove the current token from the storage. |
|
89 | - */ |
|
90 | - public function removeToken() { |
|
91 | - $this->csrfToken = null; |
|
92 | - $this->sessionStorage->removeToken(); |
|
93 | - } |
|
87 | + /** |
|
88 | + * Remove the current token from the storage. |
|
89 | + */ |
|
90 | + public function removeToken() { |
|
91 | + $this->csrfToken = null; |
|
92 | + $this->sessionStorage->removeToken(); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Verifies whether the provided token is valid. |
|
97 | - * |
|
98 | - * @param CsrfToken $token |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - public function isTokenValid(CsrfToken $token): bool { |
|
102 | - if (!$this->sessionStorage->hasToken()) { |
|
103 | - return false; |
|
104 | - } |
|
95 | + /** |
|
96 | + * Verifies whether the provided token is valid. |
|
97 | + * |
|
98 | + * @param CsrfToken $token |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + public function isTokenValid(CsrfToken $token): bool { |
|
102 | + if (!$this->sessionStorage->hasToken()) { |
|
103 | + return false; |
|
104 | + } |
|
105 | 105 | |
106 | - return hash_equals( |
|
107 | - $this->sessionStorage->getToken(), |
|
108 | - $token->getDecryptedValue() |
|
109 | - ); |
|
110 | - } |
|
106 | + return hash_equals( |
|
107 | + $this->sessionStorage->getToken(), |
|
108 | + $token->getDecryptedValue() |
|
109 | + ); |
|
110 | + } |
|
111 | 111 | } |
@@ -27,48 +27,48 @@ |
||
27 | 27 | use OCP\Command\ICommand; |
28 | 28 | |
29 | 29 | class QueueBus implements IBus { |
30 | - /** |
|
31 | - * @var ICommand[]|callable[] |
|
32 | - */ |
|
33 | - private $queue = []; |
|
30 | + /** |
|
31 | + * @var ICommand[]|callable[] |
|
32 | + */ |
|
33 | + private $queue = []; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Schedule a command to be fired |
|
37 | - * |
|
38 | - * @param \OCP\Command\ICommand | callable $command |
|
39 | - */ |
|
40 | - public function push($command) { |
|
41 | - $this->queue[] = $command; |
|
42 | - } |
|
35 | + /** |
|
36 | + * Schedule a command to be fired |
|
37 | + * |
|
38 | + * @param \OCP\Command\ICommand | callable $command |
|
39 | + */ |
|
40 | + public function push($command) { |
|
41 | + $this->queue[] = $command; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Require all commands using a trait to be run synchronous |
|
46 | - * |
|
47 | - * @param string $trait |
|
48 | - */ |
|
49 | - public function requireSync($trait) { |
|
50 | - } |
|
44 | + /** |
|
45 | + * Require all commands using a trait to be run synchronous |
|
46 | + * |
|
47 | + * @param string $trait |
|
48 | + */ |
|
49 | + public function requireSync($trait) { |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param \OCP\Command\ICommand | callable $command |
|
54 | - */ |
|
55 | - private function runCommand($command) { |
|
56 | - if ($command instanceof ICommand) { |
|
57 | - // ensure the command can be serialized |
|
58 | - $serialized = serialize($command); |
|
59 | - if (strlen($serialized) > 4000) { |
|
60 | - throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)'); |
|
61 | - } |
|
62 | - $unserialized = unserialize($serialized); |
|
63 | - $unserialized->handle(); |
|
64 | - } else { |
|
65 | - $command(); |
|
66 | - } |
|
67 | - } |
|
52 | + /** |
|
53 | + * @param \OCP\Command\ICommand | callable $command |
|
54 | + */ |
|
55 | + private function runCommand($command) { |
|
56 | + if ($command instanceof ICommand) { |
|
57 | + // ensure the command can be serialized |
|
58 | + $serialized = serialize($command); |
|
59 | + if (strlen($serialized) > 4000) { |
|
60 | + throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)'); |
|
61 | + } |
|
62 | + $unserialized = unserialize($serialized); |
|
63 | + $unserialized->handle(); |
|
64 | + } else { |
|
65 | + $command(); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - public function run() { |
|
70 | - while ($command = array_shift($this->queue)) { |
|
71 | - $this->runCommand($command); |
|
72 | - } |
|
73 | - } |
|
69 | + public function run() { |
|
70 | + while ($command = array_shift($this->queue)) { |
|
71 | + $this->runCommand($command); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
@@ -25,92 +25,92 @@ |
||
25 | 25 | namespace OC\OCS; |
26 | 26 | |
27 | 27 | class Provider extends \OCP\AppFramework\Controller { |
28 | - /** @var \OCP\App\IAppManager */ |
|
29 | - private $appManager; |
|
28 | + /** @var \OCP\App\IAppManager */ |
|
29 | + private $appManager; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param string $appName |
|
33 | - * @param \OCP\IRequest $request |
|
34 | - * @param \OCP\App\IAppManager $appManager |
|
35 | - */ |
|
36 | - public function __construct($appName, |
|
37 | - \OCP\IRequest $request, |
|
38 | - \OCP\App\IAppManager $appManager) { |
|
39 | - parent::__construct($appName, $request); |
|
40 | - $this->appManager = $appManager; |
|
41 | - } |
|
31 | + /** |
|
32 | + * @param string $appName |
|
33 | + * @param \OCP\IRequest $request |
|
34 | + * @param \OCP\App\IAppManager $appManager |
|
35 | + */ |
|
36 | + public function __construct($appName, |
|
37 | + \OCP\IRequest $request, |
|
38 | + \OCP\App\IAppManager $appManager) { |
|
39 | + parent::__construct($appName, $request); |
|
40 | + $this->appManager = $appManager; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return \OCP\AppFramework\Http\JSONResponse |
|
45 | - */ |
|
46 | - public function buildProviderList() { |
|
47 | - $services = [ |
|
48 | - 'PRIVATE_DATA' => [ |
|
49 | - 'version' => 1, |
|
50 | - 'endpoints' => [ |
|
51 | - 'store' => '/ocs/v2.php/privatedata/setattribute', |
|
52 | - 'read' => '/ocs/v2.php/privatedata/getattribute', |
|
53 | - 'delete' => '/ocs/v2.php/privatedata/deleteattribute', |
|
54 | - ], |
|
55 | - ], |
|
56 | - ]; |
|
43 | + /** |
|
44 | + * @return \OCP\AppFramework\Http\JSONResponse |
|
45 | + */ |
|
46 | + public function buildProviderList() { |
|
47 | + $services = [ |
|
48 | + 'PRIVATE_DATA' => [ |
|
49 | + 'version' => 1, |
|
50 | + 'endpoints' => [ |
|
51 | + 'store' => '/ocs/v2.php/privatedata/setattribute', |
|
52 | + 'read' => '/ocs/v2.php/privatedata/getattribute', |
|
53 | + 'delete' => '/ocs/v2.php/privatedata/deleteattribute', |
|
54 | + ], |
|
55 | + ], |
|
56 | + ]; |
|
57 | 57 | |
58 | - if ($this->appManager->isEnabledForUser('files_sharing')) { |
|
59 | - $services['SHARING'] = [ |
|
60 | - 'version' => 1, |
|
61 | - 'endpoints' => [ |
|
62 | - 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', |
|
63 | - ], |
|
64 | - ]; |
|
65 | - $services['FEDERATED_SHARING'] = [ |
|
66 | - 'version' => 1, |
|
67 | - 'endpoints' => [ |
|
68 | - 'share' => '/ocs/v2.php/cloud/shares', |
|
69 | - 'webdav' => '/public.php/webdav/', |
|
70 | - ], |
|
71 | - ]; |
|
72 | - } |
|
58 | + if ($this->appManager->isEnabledForUser('files_sharing')) { |
|
59 | + $services['SHARING'] = [ |
|
60 | + 'version' => 1, |
|
61 | + 'endpoints' => [ |
|
62 | + 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', |
|
63 | + ], |
|
64 | + ]; |
|
65 | + $services['FEDERATED_SHARING'] = [ |
|
66 | + 'version' => 1, |
|
67 | + 'endpoints' => [ |
|
68 | + 'share' => '/ocs/v2.php/cloud/shares', |
|
69 | + 'webdav' => '/public.php/webdav/', |
|
70 | + ], |
|
71 | + ]; |
|
72 | + } |
|
73 | 73 | |
74 | - if ($this->appManager->isEnabledForUser('federation')) { |
|
75 | - if (isset($services['FEDERATED_SHARING'])) { |
|
76 | - $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret'; |
|
77 | - $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system'; |
|
78 | - $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system'; |
|
79 | - } else { |
|
80 | - $services['FEDERATED_SHARING'] = [ |
|
81 | - 'version' => 1, |
|
82 | - 'endpoints' => [ |
|
83 | - 'shared-secret' => '/ocs/v2.php/cloud/shared-secret', |
|
84 | - 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system', |
|
85 | - 'carddav-user' => 'system' |
|
86 | - ], |
|
87 | - ]; |
|
88 | - } |
|
89 | - } |
|
74 | + if ($this->appManager->isEnabledForUser('federation')) { |
|
75 | + if (isset($services['FEDERATED_SHARING'])) { |
|
76 | + $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret'; |
|
77 | + $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system'; |
|
78 | + $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system'; |
|
79 | + } else { |
|
80 | + $services['FEDERATED_SHARING'] = [ |
|
81 | + 'version' => 1, |
|
82 | + 'endpoints' => [ |
|
83 | + 'shared-secret' => '/ocs/v2.php/cloud/shared-secret', |
|
84 | + 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system', |
|
85 | + 'carddav-user' => 'system' |
|
86 | + ], |
|
87 | + ]; |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - if ($this->appManager->isEnabledForUser('activity')) { |
|
92 | - $services['ACTIVITY'] = [ |
|
93 | - 'version' => 1, |
|
94 | - 'endpoints' => [ |
|
95 | - 'list' => '/ocs/v2.php/cloud/activity', |
|
96 | - ], |
|
97 | - ]; |
|
98 | - } |
|
91 | + if ($this->appManager->isEnabledForUser('activity')) { |
|
92 | + $services['ACTIVITY'] = [ |
|
93 | + 'version' => 1, |
|
94 | + 'endpoints' => [ |
|
95 | + 'list' => '/ocs/v2.php/cloud/activity', |
|
96 | + ], |
|
97 | + ]; |
|
98 | + } |
|
99 | 99 | |
100 | - if ($this->appManager->isEnabledForUser('provisioning_api')) { |
|
101 | - $services['PROVISIONING'] = [ |
|
102 | - 'version' => 1, |
|
103 | - 'endpoints' => [ |
|
104 | - 'user' => '/ocs/v2.php/cloud/users', |
|
105 | - 'groups' => '/ocs/v2.php/cloud/groups', |
|
106 | - 'apps' => '/ocs/v2.php/cloud/apps', |
|
107 | - ], |
|
108 | - ]; |
|
109 | - } |
|
100 | + if ($this->appManager->isEnabledForUser('provisioning_api')) { |
|
101 | + $services['PROVISIONING'] = [ |
|
102 | + 'version' => 1, |
|
103 | + 'endpoints' => [ |
|
104 | + 'user' => '/ocs/v2.php/cloud/users', |
|
105 | + 'groups' => '/ocs/v2.php/cloud/groups', |
|
106 | + 'apps' => '/ocs/v2.php/cloud/apps', |
|
107 | + ], |
|
108 | + ]; |
|
109 | + } |
|
110 | 110 | |
111 | - return new \OCP\AppFramework\Http\JSONResponse([ |
|
112 | - 'version' => 2, |
|
113 | - 'services' => $services, |
|
114 | - ]); |
|
115 | - } |
|
111 | + return new \OCP\AppFramework\Http\JSONResponse([ |
|
112 | + 'version' => 2, |
|
113 | + 'services' => $services, |
|
114 | + ]); |
|
115 | + } |
|
116 | 116 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | use Throwable; |
31 | 31 | |
32 | 32 | class InvalidProviderException extends Exception { |
33 | - public function __construct(string $providerId, Throwable $previous = null) { |
|
34 | - parent::__construct("The provider '$providerId' does not exist'", 0, $previous); |
|
35 | - } |
|
33 | + public function __construct(string $providerId, Throwable $previous = null) { |
|
34 | + parent::__construct("The provider '$providerId' does not exist'", 0, $previous); |
|
35 | + } |
|
36 | 36 | } |
@@ -28,16 +28,16 @@ |
||
28 | 28 | namespace OC\DB; |
29 | 29 | |
30 | 30 | class MissingIndexInformation { |
31 | - private $listOfMissingIndexes = []; |
|
31 | + private $listOfMissingIndexes = []; |
|
32 | 32 | |
33 | - public function addHintForMissingSubject(string $tableName, string $indexName) { |
|
34 | - $this->listOfMissingIndexes[] = [ |
|
35 | - 'tableName' => $tableName, |
|
36 | - 'indexName' => $indexName |
|
37 | - ]; |
|
38 | - } |
|
33 | + public function addHintForMissingSubject(string $tableName, string $indexName) { |
|
34 | + $this->listOfMissingIndexes[] = [ |
|
35 | + 'tableName' => $tableName, |
|
36 | + 'indexName' => $indexName |
|
37 | + ]; |
|
38 | + } |
|
39 | 39 | |
40 | - public function getListOfMissingIndexes(): array { |
|
41 | - return $this->listOfMissingIndexes; |
|
42 | - } |
|
40 | + public function getListOfMissingIndexes(): array { |
|
41 | + return $this->listOfMissingIndexes; |
|
42 | + } |
|
43 | 43 | } |