@@ -30,122 +30,122 @@ |
||
30 | 30 | |
31 | 31 | class OCSController extends \OCP\AppFramework\OCSController { |
32 | 32 | |
33 | - /** @var CapabilitiesManager */ |
|
34 | - private $capabilitiesManager; |
|
35 | - /** @var IUserSession */ |
|
36 | - private $userSession; |
|
37 | - /** @var IUserManager */ |
|
38 | - private $userManager; |
|
39 | - /** @var Manager */ |
|
40 | - private $keyManager; |
|
33 | + /** @var CapabilitiesManager */ |
|
34 | + private $capabilitiesManager; |
|
35 | + /** @var IUserSession */ |
|
36 | + private $userSession; |
|
37 | + /** @var IUserManager */ |
|
38 | + private $userManager; |
|
39 | + /** @var Manager */ |
|
40 | + private $keyManager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * OCSController constructor. |
|
44 | - * |
|
45 | - * @param string $appName |
|
46 | - * @param IRequest $request |
|
47 | - * @param CapabilitiesManager $capabilitiesManager |
|
48 | - * @param IUserSession $userSession |
|
49 | - * @param IUserManager $userManager |
|
50 | - * @param Manager $keyManager |
|
51 | - */ |
|
52 | - public function __construct($appName, |
|
53 | - IRequest $request, |
|
54 | - CapabilitiesManager $capabilitiesManager, |
|
55 | - IUserSession $userSession, |
|
56 | - IUserManager $userManager, |
|
57 | - Manager $keyManager) { |
|
58 | - parent::__construct($appName, $request); |
|
59 | - $this->capabilitiesManager = $capabilitiesManager; |
|
60 | - $this->userSession = $userSession; |
|
61 | - $this->userManager = $userManager; |
|
62 | - $this->keyManager = $keyManager; |
|
63 | - } |
|
42 | + /** |
|
43 | + * OCSController constructor. |
|
44 | + * |
|
45 | + * @param string $appName |
|
46 | + * @param IRequest $request |
|
47 | + * @param CapabilitiesManager $capabilitiesManager |
|
48 | + * @param IUserSession $userSession |
|
49 | + * @param IUserManager $userManager |
|
50 | + * @param Manager $keyManager |
|
51 | + */ |
|
52 | + public function __construct($appName, |
|
53 | + IRequest $request, |
|
54 | + CapabilitiesManager $capabilitiesManager, |
|
55 | + IUserSession $userSession, |
|
56 | + IUserManager $userManager, |
|
57 | + Manager $keyManager) { |
|
58 | + parent::__construct($appName, $request); |
|
59 | + $this->capabilitiesManager = $capabilitiesManager; |
|
60 | + $this->userSession = $userSession; |
|
61 | + $this->userManager = $userManager; |
|
62 | + $this->keyManager = $keyManager; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @PublicPage |
|
67 | - * |
|
68 | - * @return DataResponse |
|
69 | - */ |
|
70 | - public function getConfig() { |
|
71 | - $data = [ |
|
72 | - 'version' => '1.7', |
|
73 | - 'website' => 'Nextcloud', |
|
74 | - 'host' => $this->request->getServerHost(), |
|
75 | - 'contact' => '', |
|
76 | - 'ssl' => 'false', |
|
77 | - ]; |
|
65 | + /** |
|
66 | + * @PublicPage |
|
67 | + * |
|
68 | + * @return DataResponse |
|
69 | + */ |
|
70 | + public function getConfig() { |
|
71 | + $data = [ |
|
72 | + 'version' => '1.7', |
|
73 | + 'website' => 'Nextcloud', |
|
74 | + 'host' => $this->request->getServerHost(), |
|
75 | + 'contact' => '', |
|
76 | + 'ssl' => 'false', |
|
77 | + ]; |
|
78 | 78 | |
79 | - return new DataResponse($data); |
|
80 | - } |
|
79 | + return new DataResponse($data); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @PublicPage |
|
84 | - * |
|
85 | - * @return DataResponse |
|
86 | - */ |
|
87 | - public function getCapabilities() { |
|
88 | - $result = []; |
|
89 | - list($major, $minor, $micro) = \OCP\Util::getVersion(); |
|
90 | - $result['version'] = array( |
|
91 | - 'major' => $major, |
|
92 | - 'minor' => $minor, |
|
93 | - 'micro' => $micro, |
|
94 | - 'string' => \OC_Util::getVersionString(), |
|
95 | - 'edition' => '', |
|
96 | - ); |
|
82 | + /** |
|
83 | + * @PublicPage |
|
84 | + * |
|
85 | + * @return DataResponse |
|
86 | + */ |
|
87 | + public function getCapabilities() { |
|
88 | + $result = []; |
|
89 | + list($major, $minor, $micro) = \OCP\Util::getVersion(); |
|
90 | + $result['version'] = array( |
|
91 | + 'major' => $major, |
|
92 | + 'minor' => $minor, |
|
93 | + 'micro' => $micro, |
|
94 | + 'string' => \OC_Util::getVersionString(), |
|
95 | + 'edition' => '', |
|
96 | + ); |
|
97 | 97 | |
98 | - if($this->userSession->isLoggedIn()) { |
|
99 | - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
|
100 | - } else { |
|
101 | - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
|
102 | - } |
|
98 | + if($this->userSession->isLoggedIn()) { |
|
99 | + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
|
100 | + } else { |
|
101 | + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
|
102 | + } |
|
103 | 103 | |
104 | - return new DataResponse($result); |
|
105 | - } |
|
104 | + return new DataResponse($result); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @PublicPage |
|
109 | - * @BruteForceProtection(action=login) |
|
110 | - * |
|
111 | - * @param string $login |
|
112 | - * @param string $password |
|
113 | - * @return DataResponse |
|
114 | - */ |
|
115 | - public function personCheck($login = '', $password = '') { |
|
116 | - if ($login !== '' && $password !== '') { |
|
117 | - if ($this->userManager->checkPassword($login, $password)) { |
|
118 | - return new DataResponse([ |
|
119 | - 'person' => [ |
|
120 | - 'personid' => $login |
|
121 | - ] |
|
122 | - ]); |
|
123 | - } |
|
107 | + /** |
|
108 | + * @PublicPage |
|
109 | + * @BruteForceProtection(action=login) |
|
110 | + * |
|
111 | + * @param string $login |
|
112 | + * @param string $password |
|
113 | + * @return DataResponse |
|
114 | + */ |
|
115 | + public function personCheck($login = '', $password = '') { |
|
116 | + if ($login !== '' && $password !== '') { |
|
117 | + if ($this->userManager->checkPassword($login, $password)) { |
|
118 | + return new DataResponse([ |
|
119 | + 'person' => [ |
|
120 | + 'personid' => $login |
|
121 | + ] |
|
122 | + ]); |
|
123 | + } |
|
124 | 124 | |
125 | - $response = new DataResponse(null, 102); |
|
126 | - $response->throttle(); |
|
127 | - return $response; |
|
128 | - } |
|
129 | - return new DataResponse(null, 101); |
|
130 | - } |
|
125 | + $response = new DataResponse(null, 102); |
|
126 | + $response->throttle(); |
|
127 | + return $response; |
|
128 | + } |
|
129 | + return new DataResponse(null, 101); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @PublicPage |
|
134 | - * |
|
135 | - * @param string $cloudId |
|
136 | - * @return DataResponse |
|
137 | - */ |
|
138 | - public function getIdentityProof($cloudId) { |
|
139 | - $userObject = $this->userManager->get($cloudId); |
|
132 | + /** |
|
133 | + * @PublicPage |
|
134 | + * |
|
135 | + * @param string $cloudId |
|
136 | + * @return DataResponse |
|
137 | + */ |
|
138 | + public function getIdentityProof($cloudId) { |
|
139 | + $userObject = $this->userManager->get($cloudId); |
|
140 | 140 | |
141 | - if($userObject !== null) { |
|
142 | - $key = $this->keyManager->getKey($userObject); |
|
143 | - $data = [ |
|
144 | - 'public' => $key->getPublic(), |
|
145 | - ]; |
|
146 | - return new DataResponse($data); |
|
147 | - } |
|
141 | + if($userObject !== null) { |
|
142 | + $key = $this->keyManager->getKey($userObject); |
|
143 | + $data = [ |
|
144 | + 'public' => $key->getPublic(), |
|
145 | + ]; |
|
146 | + return new DataResponse($data); |
|
147 | + } |
|
148 | 148 | |
149 | - return new DataResponse('User not found', 404); |
|
150 | - } |
|
149 | + return new DataResponse('User not found', 404); |
|
150 | + } |
|
151 | 151 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'edition' => '', |
96 | 96 | ); |
97 | 97 | |
98 | - if($this->userSession->isLoggedIn()) { |
|
98 | + if ($this->userSession->isLoggedIn()) { |
|
99 | 99 | $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
100 | 100 | } else { |
101 | 101 | $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function getIdentityProof($cloudId) { |
139 | 139 | $userObject = $this->userManager->get($cloudId); |
140 | 140 | |
141 | - if($userObject !== null) { |
|
141 | + if ($userObject !== null) { |
|
142 | 142 | $key = $this->keyManager->getKey($userObject); |
143 | 143 | $data = [ |
144 | 144 | 'public' => $key->getPublic(), |
@@ -34,45 +34,45 @@ |
||
34 | 34 | */ |
35 | 35 | class Capabilities implements IPublicCapability { |
36 | 36 | |
37 | - /** @var ThemingDefaults */ |
|
38 | - protected $theming; |
|
37 | + /** @var ThemingDefaults */ |
|
38 | + protected $theming; |
|
39 | 39 | |
40 | - /** @var IURLGenerator */ |
|
41 | - protected $url; |
|
40 | + /** @var IURLGenerator */ |
|
41 | + protected $url; |
|
42 | 42 | |
43 | - /** @var IConfig */ |
|
44 | - protected $config; |
|
43 | + /** @var IConfig */ |
|
44 | + protected $config; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param ThemingDefaults $theming |
|
48 | - * @param IURLGenerator $url |
|
49 | - * @param IConfig $config |
|
50 | - */ |
|
51 | - public function __construct(ThemingDefaults $theming, IURLGenerator $url, IConfig $config) { |
|
52 | - $this->theming = $theming; |
|
53 | - $this->url = $url; |
|
54 | - $this->config = $config; |
|
55 | - } |
|
46 | + /** |
|
47 | + * @param ThemingDefaults $theming |
|
48 | + * @param IURLGenerator $url |
|
49 | + * @param IConfig $config |
|
50 | + */ |
|
51 | + public function __construct(ThemingDefaults $theming, IURLGenerator $url, IConfig $config) { |
|
52 | + $this->theming = $theming; |
|
53 | + $this->url = $url; |
|
54 | + $this->config = $config; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Return this classes capabilities |
|
59 | - * |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function getCapabilities() { |
|
63 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
57 | + /** |
|
58 | + * Return this classes capabilities |
|
59 | + * |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function getCapabilities() { |
|
63 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
64 | 64 | |
65 | - return [ |
|
66 | - 'theming' => [ |
|
67 | - 'name' => $this->theming->getName(), |
|
68 | - 'url' => $this->theming->getBaseUrl(), |
|
69 | - 'slogan' => $this->theming->getSlogan(), |
|
70 | - 'color' => $this->theming->getColorPrimary(), |
|
71 | - 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
72 | - 'background' => $backgroundLogo === 'backgroundColor' ? |
|
73 | - $this->theming->getColorPrimary() : |
|
74 | - $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
75 | - ], |
|
76 | - ]; |
|
77 | - } |
|
65 | + return [ |
|
66 | + 'theming' => [ |
|
67 | + 'name' => $this->theming->getName(), |
|
68 | + 'url' => $this->theming->getBaseUrl(), |
|
69 | + 'slogan' => $this->theming->getSlogan(), |
|
70 | + 'color' => $this->theming->getColorPrimary(), |
|
71 | + 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
72 | + 'background' => $backgroundLogo === 'backgroundColor' ? |
|
73 | + $this->theming->getColorPrimary() : |
|
74 | + $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
75 | + ], |
|
76 | + ]; |
|
77 | + } |
|
78 | 78 | } |
@@ -29,54 +29,54 @@ |
||
29 | 29 | |
30 | 30 | class CapabilitiesManager { |
31 | 31 | |
32 | - /** @var \Closure[] */ |
|
33 | - private $capabilities = array(); |
|
32 | + /** @var \Closure[] */ |
|
33 | + private $capabilities = array(); |
|
34 | 34 | |
35 | - /** @var ILogger */ |
|
36 | - private $logger; |
|
35 | + /** @var ILogger */ |
|
36 | + private $logger; |
|
37 | 37 | |
38 | - public function __construct(ILogger $logger) { |
|
39 | - $this->logger = $logger; |
|
40 | - } |
|
38 | + public function __construct(ILogger $logger) { |
|
39 | + $this->logger = $logger; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Get an array of al the capabilities that are registered at this manager |
|
42 | + /** |
|
43 | + * Get an array of al the capabilities that are registered at this manager |
|
44 | 44 | * |
45 | - * @param bool $public get public capabilities only |
|
46 | - * @throws \InvalidArgumentException |
|
47 | - * @return array |
|
48 | - */ |
|
49 | - public function getCapabilities($public = false) { |
|
50 | - $capabilities = []; |
|
51 | - foreach($this->capabilities as $capability) { |
|
52 | - try { |
|
53 | - $c = $capability(); |
|
54 | - } catch (QueryException $e) { |
|
55 | - $this->logger->error('CapabilitiesManager: {message}', ['app' => 'core', 'message' => $e->getMessage()]); |
|
56 | - continue; |
|
57 | - } |
|
45 | + * @param bool $public get public capabilities only |
|
46 | + * @throws \InvalidArgumentException |
|
47 | + * @return array |
|
48 | + */ |
|
49 | + public function getCapabilities($public = false) { |
|
50 | + $capabilities = []; |
|
51 | + foreach($this->capabilities as $capability) { |
|
52 | + try { |
|
53 | + $c = $capability(); |
|
54 | + } catch (QueryException $e) { |
|
55 | + $this->logger->error('CapabilitiesManager: {message}', ['app' => 'core', 'message' => $e->getMessage()]); |
|
56 | + continue; |
|
57 | + } |
|
58 | 58 | |
59 | - if ($c instanceof ICapability) { |
|
60 | - if(!$public || $c instanceof IPublicCapability) { |
|
61 | - $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
|
62 | - } |
|
63 | - } else { |
|
64 | - throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
65 | - } |
|
66 | - } |
|
59 | + if ($c instanceof ICapability) { |
|
60 | + if(!$public || $c instanceof IPublicCapability) { |
|
61 | + $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
|
62 | + } |
|
63 | + } else { |
|
64 | + throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - return $capabilities; |
|
69 | - } |
|
68 | + return $capabilities; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
73 | - * capabilities are actually requested |
|
74 | - * |
|
75 | - * $callable has to return an instance of OCP\Capabilities\ICapability |
|
76 | - * |
|
77 | - * @param \Closure $callable |
|
78 | - */ |
|
79 | - public function registerCapability(\Closure $callable) { |
|
80 | - array_push($this->capabilities, $callable); |
|
81 | - } |
|
71 | + /** |
|
72 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
73 | + * capabilities are actually requested |
|
74 | + * |
|
75 | + * $callable has to return an instance of OCP\Capabilities\ICapability |
|
76 | + * |
|
77 | + * @param \Closure $callable |
|
78 | + */ |
|
79 | + public function registerCapability(\Closure $callable) { |
|
80 | + array_push($this->capabilities, $callable); |
|
81 | + } |
|
82 | 82 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getCapabilities($public = false) { |
50 | 50 | $capabilities = []; |
51 | - foreach($this->capabilities as $capability) { |
|
51 | + foreach ($this->capabilities as $capability) { |
|
52 | 52 | try { |
53 | 53 | $c = $capability(); |
54 | 54 | } catch (QueryException $e) { |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | if ($c instanceof ICapability) { |
60 | - if(!$public || $c instanceof IPublicCapability) { |
|
60 | + if (!$public || $c instanceof IPublicCapability) { |
|
61 | 61 | $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
62 | 62 | } |
63 | 63 | } else { |
64 | - throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
64 | + throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface'); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 |