@@ -84,7 +84,7 @@ |
||
84 | 84 | |
85 | 85 | if (isset($this->namespaces[$namespace])) { |
86 | 86 | if (!isset($this->hasNoAppContainer[$namespace])) { |
87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
87 | + $applicationClassName = 'OCA\\'.$sensitiveNamespace.'\\AppInfo\\Application'; |
|
88 | 88 | if (class_exists($applicationClassName)) { |
89 | 89 | new $applicationClassName(); |
90 | 90 | if (isset($this->appContainers[$namespace])) { |
@@ -34,101 +34,101 @@ |
||
34 | 34 | * @package OC |
35 | 35 | */ |
36 | 36 | class ServerContainer extends SimpleContainer { |
37 | - /** @var DIContainer[] */ |
|
38 | - protected $appContainers; |
|
37 | + /** @var DIContainer[] */ |
|
38 | + protected $appContainers; |
|
39 | 39 | |
40 | - /** @var string[] */ |
|
41 | - protected $hasNoAppContainer; |
|
40 | + /** @var string[] */ |
|
41 | + protected $hasNoAppContainer; |
|
42 | 42 | |
43 | - /** @var string[] */ |
|
44 | - protected $namespaces; |
|
43 | + /** @var string[] */ |
|
44 | + protected $namespaces; |
|
45 | 45 | |
46 | - /** |
|
47 | - * ServerContainer constructor. |
|
48 | - */ |
|
49 | - public function __construct() { |
|
50 | - parent::__construct(); |
|
51 | - $this->appContainers = []; |
|
52 | - $this->namespaces = []; |
|
53 | - $this->hasNoAppContainer = []; |
|
54 | - } |
|
46 | + /** |
|
47 | + * ServerContainer constructor. |
|
48 | + */ |
|
49 | + public function __construct() { |
|
50 | + parent::__construct(); |
|
51 | + $this->appContainers = []; |
|
52 | + $this->namespaces = []; |
|
53 | + $this->hasNoAppContainer = []; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $appName |
|
58 | - * @param string $appNamespace |
|
59 | - */ |
|
60 | - public function registerNamespace($appName, $appNamespace) { |
|
61 | - // Cut of OCA\ and lowercase |
|
62 | - $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
63 | - $this->namespaces[$appNamespace] = $appName; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @param string $appName |
|
58 | + * @param string $appNamespace |
|
59 | + */ |
|
60 | + public function registerNamespace($appName, $appNamespace) { |
|
61 | + // Cut of OCA\ and lowercase |
|
62 | + $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
63 | + $this->namespaces[$appNamespace] = $appName; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string $appName |
|
68 | - * @param DIContainer $container |
|
69 | - */ |
|
70 | - public function registerAppContainer($appName, DIContainer $container) { |
|
71 | - $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @param string $appName |
|
68 | + * @param DIContainer $container |
|
69 | + */ |
|
70 | + public function registerAppContainer($appName, DIContainer $container) { |
|
71 | + $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $namespace |
|
76 | - * @param string $sensitiveNamespace |
|
77 | - * @return DIContainer |
|
78 | - * @throws QueryException |
|
79 | - */ |
|
80 | - protected function getAppContainer($namespace, $sensitiveNamespace) { |
|
81 | - if (isset($this->appContainers[$namespace])) { |
|
82 | - return $this->appContainers[$namespace]; |
|
83 | - } |
|
74 | + /** |
|
75 | + * @param string $namespace |
|
76 | + * @param string $sensitiveNamespace |
|
77 | + * @return DIContainer |
|
78 | + * @throws QueryException |
|
79 | + */ |
|
80 | + protected function getAppContainer($namespace, $sensitiveNamespace) { |
|
81 | + if (isset($this->appContainers[$namespace])) { |
|
82 | + return $this->appContainers[$namespace]; |
|
83 | + } |
|
84 | 84 | |
85 | - if (isset($this->namespaces[$namespace])) { |
|
86 | - if (!isset($this->hasNoAppContainer[$namespace])) { |
|
87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
88 | - if (class_exists($applicationClassName)) { |
|
89 | - new $applicationClassName(); |
|
90 | - if (isset($this->appContainers[$namespace])) { |
|
91 | - return $this->appContainers[$namespace]; |
|
92 | - } |
|
93 | - } |
|
94 | - $this->hasNoAppContainer[$namespace] = true; |
|
95 | - } |
|
85 | + if (isset($this->namespaces[$namespace])) { |
|
86 | + if (!isset($this->hasNoAppContainer[$namespace])) { |
|
87 | + $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
88 | + if (class_exists($applicationClassName)) { |
|
89 | + new $applicationClassName(); |
|
90 | + if (isset($this->appContainers[$namespace])) { |
|
91 | + return $this->appContainers[$namespace]; |
|
92 | + } |
|
93 | + } |
|
94 | + $this->hasNoAppContainer[$namespace] = true; |
|
95 | + } |
|
96 | 96 | |
97 | - return new DIContainer($this->namespaces[$namespace]); |
|
98 | - } |
|
99 | - throw new QueryException(); |
|
100 | - } |
|
97 | + return new DIContainer($this->namespaces[$namespace]); |
|
98 | + } |
|
99 | + throw new QueryException(); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @param string $name name of the service to query for |
|
104 | - * @return mixed registered service for the given $name |
|
105 | - * @throws QueryException if the query could not be resolved |
|
106 | - */ |
|
107 | - public function query($name) { |
|
108 | - $name = $this->sanitizeName($name); |
|
102 | + /** |
|
103 | + * @param string $name name of the service to query for |
|
104 | + * @return mixed registered service for the given $name |
|
105 | + * @throws QueryException if the query could not be resolved |
|
106 | + */ |
|
107 | + public function query($name) { |
|
108 | + $name = $this->sanitizeName($name); |
|
109 | 109 | |
110 | - // In case the service starts with OCA\ we try to find the service in |
|
111 | - // the apps container first. |
|
112 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
113 | - $segments = explode('\\', $name); |
|
114 | - try { |
|
115 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
116 | - return $appContainer->queryNoFallback($name); |
|
117 | - } catch (QueryException $e) { |
|
118 | - // Didn't find the service or the respective app container, |
|
119 | - // ignore it and fall back to the core container. |
|
120 | - } |
|
121 | - } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
122 | - $segments = explode('\\', $name); |
|
123 | - try { |
|
124 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
125 | - return $appContainer->queryNoFallback($name); |
|
126 | - } catch (QueryException $e) { |
|
127 | - // Didn't find the service or the respective app container, |
|
128 | - // ignore it and fall back to the core container. |
|
129 | - } |
|
130 | - } |
|
110 | + // In case the service starts with OCA\ we try to find the service in |
|
111 | + // the apps container first. |
|
112 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
113 | + $segments = explode('\\', $name); |
|
114 | + try { |
|
115 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
116 | + return $appContainer->queryNoFallback($name); |
|
117 | + } catch (QueryException $e) { |
|
118 | + // Didn't find the service or the respective app container, |
|
119 | + // ignore it and fall back to the core container. |
|
120 | + } |
|
121 | + } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
122 | + $segments = explode('\\', $name); |
|
123 | + try { |
|
124 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
125 | + return $appContainer->queryNoFallback($name); |
|
126 | + } catch (QueryException $e) { |
|
127 | + // Didn't find the service or the respective app container, |
|
128 | + // ignore it and fall back to the core container. |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - return parent::query($name); |
|
133 | - } |
|
132 | + return parent::query($name); |
|
133 | + } |
|
134 | 134 | } |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OC\Files\Cache\Wrapper; |
25 | 25 | |
26 | 26 | class CachePermissionsMask extends CacheWrapper { |
27 | - /** |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - protected $mask; |
|
27 | + /** |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + protected $mask; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param \OCP\Files\Cache\ICache $cache |
|
34 | - * @param int $mask |
|
35 | - */ |
|
36 | - public function __construct($cache, $mask) { |
|
37 | - parent::__construct($cache); |
|
38 | - $this->mask = $mask; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param \OCP\Files\Cache\ICache $cache |
|
34 | + * @param int $mask |
|
35 | + */ |
|
36 | + public function __construct($cache, $mask) { |
|
37 | + parent::__construct($cache); |
|
38 | + $this->mask = $mask; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function formatCacheEntry($entry) { |
|
42 | - if (isset($entry['permissions'])) { |
|
43 | - $entry['scan_permissions'] = $entry['permissions']; |
|
44 | - $entry['permissions'] &= $this->mask; |
|
45 | - } |
|
46 | - return $entry; |
|
47 | - } |
|
41 | + protected function formatCacheEntry($entry) { |
|
42 | + if (isset($entry['permissions'])) { |
|
43 | + $entry['scan_permissions'] = $entry['permissions']; |
|
44 | + $entry['permissions'] &= $this->mask; |
|
45 | + } |
|
46 | + return $entry; |
|
47 | + } |
|
48 | 48 | } |
@@ -28,62 +28,62 @@ |
||
28 | 28 | |
29 | 29 | class ClientMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * @param IDBConnection $db |
|
33 | - */ |
|
34 | - public function __construct(IDBConnection $db) { |
|
35 | - parent::__construct($db, 'oauth2_clients'); |
|
36 | - } |
|
31 | + /** |
|
32 | + * @param IDBConnection $db |
|
33 | + */ |
|
34 | + public function __construct(IDBConnection $db) { |
|
35 | + parent::__construct($db, 'oauth2_clients'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $clientIdentifier |
|
40 | - * @return Client |
|
41 | - * @throws ClientNotFoundException |
|
42 | - */ |
|
43 | - public function getByIdentifier($clientIdentifier) { |
|
44 | - $qb = $this->db->getQueryBuilder(); |
|
45 | - $qb |
|
46 | - ->select('*') |
|
47 | - ->from($this->tableName) |
|
48 | - ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
49 | - $result = $qb->execute(); |
|
50 | - $row = $result->fetch(); |
|
51 | - $result->closeCursor(); |
|
52 | - if($row === false) { |
|
53 | - throw new ClientNotFoundException(); |
|
54 | - } |
|
55 | - return Client::fromRow($row); |
|
56 | - } |
|
38 | + /** |
|
39 | + * @param string $clientIdentifier |
|
40 | + * @return Client |
|
41 | + * @throws ClientNotFoundException |
|
42 | + */ |
|
43 | + public function getByIdentifier($clientIdentifier) { |
|
44 | + $qb = $this->db->getQueryBuilder(); |
|
45 | + $qb |
|
46 | + ->select('*') |
|
47 | + ->from($this->tableName) |
|
48 | + ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
49 | + $result = $qb->execute(); |
|
50 | + $row = $result->fetch(); |
|
51 | + $result->closeCursor(); |
|
52 | + if($row === false) { |
|
53 | + throw new ClientNotFoundException(); |
|
54 | + } |
|
55 | + return Client::fromRow($row); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param string $uid internal uid of the client |
|
60 | - * @return Client |
|
61 | - * @throws ClientNotFoundException |
|
62 | - */ |
|
63 | - public function getByUid($uid) { |
|
64 | - $qb = $this->db->getQueryBuilder(); |
|
65 | - $qb |
|
66 | - ->select('*') |
|
67 | - ->from($this->tableName) |
|
68 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
69 | - $result = $qb->execute(); |
|
70 | - $row = $result->fetch(); |
|
71 | - $result->closeCursor(); |
|
72 | - if($row === false) { |
|
73 | - throw new ClientNotFoundException(); |
|
74 | - } |
|
75 | - return Client::fromRow($row); |
|
76 | - } |
|
58 | + /** |
|
59 | + * @param string $uid internal uid of the client |
|
60 | + * @return Client |
|
61 | + * @throws ClientNotFoundException |
|
62 | + */ |
|
63 | + public function getByUid($uid) { |
|
64 | + $qb = $this->db->getQueryBuilder(); |
|
65 | + $qb |
|
66 | + ->select('*') |
|
67 | + ->from($this->tableName) |
|
68 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
69 | + $result = $qb->execute(); |
|
70 | + $row = $result->fetch(); |
|
71 | + $result->closeCursor(); |
|
72 | + if($row === false) { |
|
73 | + throw new ClientNotFoundException(); |
|
74 | + } |
|
75 | + return Client::fromRow($row); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return Client[] |
|
80 | - */ |
|
81 | - public function getClients() { |
|
82 | - $qb = $this->db->getQueryBuilder(); |
|
83 | - $qb |
|
84 | - ->select('*') |
|
85 | - ->from($this->tableName); |
|
78 | + /** |
|
79 | + * @return Client[] |
|
80 | + */ |
|
81 | + public function getClients() { |
|
82 | + $qb = $this->db->getQueryBuilder(); |
|
83 | + $qb |
|
84 | + ->select('*') |
|
85 | + ->from($this->tableName); |
|
86 | 86 | |
87 | - return $this->findEntities($qb->getSQL()); |
|
88 | - } |
|
87 | + return $this->findEntities($qb->getSQL()); |
|
88 | + } |
|
89 | 89 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $result = $qb->execute(); |
50 | 50 | $row = $result->fetch(); |
51 | 51 | $result->closeCursor(); |
52 | - if($row === false) { |
|
52 | + if ($row === false) { |
|
53 | 53 | throw new ClientNotFoundException(); |
54 | 54 | } |
55 | 55 | return Client::fromRow($row); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $result = $qb->execute(); |
70 | 70 | $row = $result->fetch(); |
71 | 71 | $result->closeCursor(); |
72 | - if($row === false) { |
|
72 | + if ($row === false) { |
|
73 | 73 | throw new ClientNotFoundException(); |
74 | 74 | } |
75 | 75 | return Client::fromRow($row); |
@@ -28,43 +28,43 @@ |
||
28 | 28 | |
29 | 29 | class AccessTokenMapper extends Mapper { |
30 | 30 | |
31 | - /** |
|
32 | - * @param IDBConnection $db |
|
33 | - */ |
|
34 | - public function __construct(IDBConnection $db) { |
|
35 | - parent::__construct($db, 'oauth2_access_tokens'); |
|
36 | - } |
|
31 | + /** |
|
32 | + * @param IDBConnection $db |
|
33 | + */ |
|
34 | + public function __construct(IDBConnection $db) { |
|
35 | + parent::__construct($db, 'oauth2_access_tokens'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $code |
|
40 | - * @return AccessToken |
|
41 | - * @throws AccessTokenNotFoundException |
|
42 | - */ |
|
43 | - public function getByCode($code) { |
|
44 | - $qb = $this->db->getQueryBuilder(); |
|
45 | - $qb |
|
46 | - ->select('*') |
|
47 | - ->from($this->tableName) |
|
48 | - ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
49 | - $result = $qb->execute(); |
|
50 | - $row = $result->fetch(); |
|
51 | - $result->closeCursor(); |
|
52 | - if($row === false) { |
|
53 | - throw new AccessTokenNotFoundException(); |
|
54 | - } |
|
55 | - return AccessToken::fromRow($row); |
|
56 | - } |
|
38 | + /** |
|
39 | + * @param string $code |
|
40 | + * @return AccessToken |
|
41 | + * @throws AccessTokenNotFoundException |
|
42 | + */ |
|
43 | + public function getByCode($code) { |
|
44 | + $qb = $this->db->getQueryBuilder(); |
|
45 | + $qb |
|
46 | + ->select('*') |
|
47 | + ->from($this->tableName) |
|
48 | + ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
49 | + $result = $qb->execute(); |
|
50 | + $row = $result->fetch(); |
|
51 | + $result->closeCursor(); |
|
52 | + if($row === false) { |
|
53 | + throw new AccessTokenNotFoundException(); |
|
54 | + } |
|
55 | + return AccessToken::fromRow($row); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * delete all access token from a given client |
|
60 | - * |
|
61 | - * @param int $id |
|
62 | - */ |
|
63 | - public function deleteByClientId($id) { |
|
64 | - $qb = $this->db->getQueryBuilder(); |
|
65 | - $qb |
|
66 | - ->delete($this->tableName) |
|
67 | - ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
68 | - $qb->execute(); |
|
69 | - } |
|
58 | + /** |
|
59 | + * delete all access token from a given client |
|
60 | + * |
|
61 | + * @param int $id |
|
62 | + */ |
|
63 | + public function deleteByClientId($id) { |
|
64 | + $qb = $this->db->getQueryBuilder(); |
|
65 | + $qb |
|
66 | + ->delete($this->tableName) |
|
67 | + ->where($qb->expr()->eq('client_id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); |
|
68 | + $qb->execute(); |
|
69 | + } |
|
70 | 70 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $result = $qb->execute(); |
50 | 50 | $row = $result->fetch(); |
51 | 51 | $result->closeCursor(); |
52 | - if($row === false) { |
|
52 | + if ($row === false) { |
|
53 | 53 | throw new AccessTokenNotFoundException(); |
54 | 54 | } |
55 | 55 | return AccessToken::fromRow($row); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | private function setupUserFs($userId) { |
56 | 56 | \OC_Util::setupFS($userId); |
57 | 57 | $this->session->close(); |
58 | - return $this->principalPrefix . $userId; |
|
58 | + return $this->principalPrefix.$userId; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | public function validateBearerToken($bearerToken) { |
65 | 65 | \OC_Util::setupFS(); |
66 | 66 | |
67 | - if(!$this->userSession->isLoggedIn()) { |
|
67 | + if (!$this->userSession->isLoggedIn()) { |
|
68 | 68 | $this->userSession->tryTokenLogin($this->request); |
69 | 69 | } |
70 | - if($this->userSession->isLoggedIn()) { |
|
70 | + if ($this->userSession->isLoggedIn()) { |
|
71 | 71 | return $this->setupUserFs($this->userSession->getUser()->getUID()); |
72 | 72 | } |
73 | 73 |
@@ -29,66 +29,66 @@ |
||
29 | 29 | use Sabre\HTTP\ResponseInterface; |
30 | 30 | |
31 | 31 | class BearerAuth extends AbstractBearer { |
32 | - /** @var IUserSession */ |
|
33 | - private $userSession; |
|
34 | - /** @var ISession */ |
|
35 | - private $session; |
|
36 | - /** @var IRequest */ |
|
37 | - private $request; |
|
38 | - /** @var string */ |
|
39 | - private $principalPrefix; |
|
32 | + /** @var IUserSession */ |
|
33 | + private $userSession; |
|
34 | + /** @var ISession */ |
|
35 | + private $session; |
|
36 | + /** @var IRequest */ |
|
37 | + private $request; |
|
38 | + /** @var string */ |
|
39 | + private $principalPrefix; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IUserSession $userSession |
|
43 | - * @param ISession $session |
|
44 | - * @param string $principalPrefix |
|
45 | - * @param IRequest $request |
|
46 | - */ |
|
47 | - public function __construct(IUserSession $userSession, |
|
48 | - ISession $session, |
|
49 | - IRequest $request, |
|
50 | - $principalPrefix = 'principals/users/') { |
|
51 | - $this->userSession = $userSession; |
|
52 | - $this->session = $session; |
|
53 | - $this->request = $request; |
|
54 | - $this->principalPrefix = $principalPrefix; |
|
41 | + /** |
|
42 | + * @param IUserSession $userSession |
|
43 | + * @param ISession $session |
|
44 | + * @param string $principalPrefix |
|
45 | + * @param IRequest $request |
|
46 | + */ |
|
47 | + public function __construct(IUserSession $userSession, |
|
48 | + ISession $session, |
|
49 | + IRequest $request, |
|
50 | + $principalPrefix = 'principals/users/') { |
|
51 | + $this->userSession = $userSession; |
|
52 | + $this->session = $session; |
|
53 | + $this->request = $request; |
|
54 | + $this->principalPrefix = $principalPrefix; |
|
55 | 55 | |
56 | - // setup realm |
|
57 | - $defaults = new \OCP\Defaults(); |
|
58 | - $this->realm = $defaults->getName(); |
|
59 | - } |
|
56 | + // setup realm |
|
57 | + $defaults = new \OCP\Defaults(); |
|
58 | + $this->realm = $defaults->getName(); |
|
59 | + } |
|
60 | 60 | |
61 | - private function setupUserFs($userId) { |
|
62 | - \OC_Util::setupFS($userId); |
|
63 | - $this->session->close(); |
|
64 | - return $this->principalPrefix . $userId; |
|
65 | - } |
|
61 | + private function setupUserFs($userId) { |
|
62 | + \OC_Util::setupFS($userId); |
|
63 | + $this->session->close(); |
|
64 | + return $this->principalPrefix . $userId; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - public function validateBearerToken($bearerToken) { |
|
71 | - \OC_Util::setupFS(); |
|
67 | + /** |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + public function validateBearerToken($bearerToken) { |
|
71 | + \OC_Util::setupFS(); |
|
72 | 72 | |
73 | - if(!$this->userSession->isLoggedIn()) { |
|
74 | - $this->userSession->tryTokenLogin($this->request); |
|
75 | - } |
|
76 | - if($this->userSession->isLoggedIn()) { |
|
77 | - return $this->setupUserFs($this->userSession->getUser()->getUID()); |
|
78 | - } |
|
73 | + if(!$this->userSession->isLoggedIn()) { |
|
74 | + $this->userSession->tryTokenLogin($this->request); |
|
75 | + } |
|
76 | + if($this->userSession->isLoggedIn()) { |
|
77 | + return $this->setupUserFs($this->userSession->getUser()->getUID()); |
|
78 | + } |
|
79 | 79 | |
80 | - return false; |
|
81 | - } |
|
80 | + return false; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate |
|
85 | - * header which some DAV clients can't handle. Thus we override this function |
|
86 | - * and make it simply return a 401. |
|
87 | - * |
|
88 | - * @param RequestInterface $request |
|
89 | - * @param ResponseInterface $response |
|
90 | - */ |
|
91 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
92 | - $response->setStatus(401); |
|
93 | - } |
|
83 | + /** |
|
84 | + * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate |
|
85 | + * header which some DAV clients can't handle. Thus we override this function |
|
86 | + * and make it simply return a 401. |
|
87 | + * |
|
88 | + * @param RequestInterface $request |
|
89 | + * @param ResponseInterface $response |
|
90 | + */ |
|
91 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
92 | + $response->setStatus(401); |
|
93 | + } |
|
94 | 94 | } |
@@ -71,26 +71,26 @@ |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | $app = substr($script, 0, strpos($script, '/')); |
74 | - $script = substr($script, strpos($script, '/')+1); |
|
74 | + $script = substr($script, strpos($script, '/') + 1); |
|
75 | 75 | $app_path = \OC_App::getAppPath($app); |
76 | 76 | $app_url = \OC_App::getAppWebPath($app); |
77 | 77 | |
78 | 78 | // missing translations files fill be ignored |
79 | 79 | if (strpos($script, 'l10n/') === 0) { |
80 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
80 | + $this->appendIfExist($app_path, $script.'.js', $app_url); |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($app_path === false && $app_url === false) { |
85 | 85 | $this->logger->error('Could not find resource {resource} to load', [ |
86 | - 'resource' => $app . '/' . $script . '.js', |
|
86 | + 'resource' => $app.'/'.$script.'.js', |
|
87 | 87 | 'app' => 'jsresourceloader', |
88 | 88 | ]); |
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | 92 | if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
93 | - $this->append($app_path, $script . '.js', $app_url); |
|
93 | + $this->append($app_path, $script.'.js', $app_url); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 |
@@ -28,103 +28,103 @@ |
||
28 | 28 | |
29 | 29 | class JSResourceLocator extends ResourceLocator { |
30 | 30 | |
31 | - /** @var JSCombiner */ |
|
32 | - protected $jsCombiner; |
|
33 | - |
|
34 | - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
35 | - parent::__construct($logger, $theme, $core_map, $party_map); |
|
36 | - |
|
37 | - $this->jsCombiner = $JSCombiner; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * @param string $script |
|
42 | - */ |
|
43 | - public function doFind($script) { |
|
44 | - $theme_dir = 'themes/'.$this->theme.'/'; |
|
45 | - if (strpos($script, '3rdparty') === 0 |
|
46 | - && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
47 | - return; |
|
48 | - } |
|
49 | - |
|
50 | - if (strpos($script, '/l10n/') !== false) { |
|
51 | - // For language files we try to load them all, so themes can overwrite |
|
52 | - // single l10n strings without having to translate all of them. |
|
53 | - $found = 0; |
|
54 | - $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
55 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
56 | - $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
57 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
58 | - $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); |
|
59 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
60 | - |
|
61 | - if ($found) { |
|
62 | - return; |
|
63 | - } |
|
64 | - } else if ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
65 | - || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
66 | - || $this->appendIfExist($this->serverroot, $script.'.js') |
|
67 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
68 | - || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
69 | - || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
70 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
71 | - ) { |
|
72 | - return; |
|
73 | - } |
|
74 | - |
|
75 | - $app = substr($script, 0, strpos($script, '/')); |
|
76 | - $script = substr($script, strpos($script, '/')+1); |
|
77 | - $app_path = \OC_App::getAppPath($app); |
|
78 | - $app_url = \OC_App::getAppWebPath($app); |
|
79 | - |
|
80 | - if ($app_path !== false) { |
|
81 | - // Account for the possibility of having symlinks in app path. Only |
|
82 | - // do this if $app_path is set, because an empty argument to realpath |
|
83 | - // gets turned into cwd. |
|
84 | - $app_path = realpath($app_path); |
|
85 | - } |
|
86 | - |
|
87 | - // missing translations files fill be ignored |
|
88 | - if (strpos($script, 'l10n/') === 0) { |
|
89 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
90 | - return; |
|
91 | - } |
|
92 | - |
|
93 | - if ($app_path === false && $app_url === false) { |
|
94 | - $this->logger->error('Could not find resource {resource} to load', [ |
|
95 | - 'resource' => $app . '/' . $script . '.js', |
|
96 | - 'app' => 'jsresourceloader', |
|
97 | - ]); |
|
98 | - return; |
|
99 | - } |
|
100 | - |
|
101 | - if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
102 | - $this->append($app_path, $script . '.js', $app_url); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @param string $script |
|
108 | - */ |
|
109 | - public function doFindTheme($script) { |
|
110 | - } |
|
111 | - |
|
112 | - protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
113 | - if (is_file($root.'/'.$file)) { |
|
114 | - if ($this->jsCombiner->process($root, $file, $app)) { |
|
115 | - $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
116 | - } else { |
|
117 | - // Add all the files from the json |
|
118 | - $files = $this->jsCombiner->getContent($root, $file); |
|
119 | - $app_url = \OC_App::getAppWebPath($app); |
|
120 | - |
|
121 | - foreach ($files as $jsFile) { |
|
122 | - $this->append($root, $jsFile, $app_url); |
|
123 | - } |
|
124 | - } |
|
125 | - return true; |
|
126 | - } |
|
127 | - |
|
128 | - return false; |
|
129 | - } |
|
31 | + /** @var JSCombiner */ |
|
32 | + protected $jsCombiner; |
|
33 | + |
|
34 | + public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
35 | + parent::__construct($logger, $theme, $core_map, $party_map); |
|
36 | + |
|
37 | + $this->jsCombiner = $JSCombiner; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * @param string $script |
|
42 | + */ |
|
43 | + public function doFind($script) { |
|
44 | + $theme_dir = 'themes/'.$this->theme.'/'; |
|
45 | + if (strpos($script, '3rdparty') === 0 |
|
46 | + && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
47 | + return; |
|
48 | + } |
|
49 | + |
|
50 | + if (strpos($script, '/l10n/') !== false) { |
|
51 | + // For language files we try to load them all, so themes can overwrite |
|
52 | + // single l10n strings without having to translate all of them. |
|
53 | + $found = 0; |
|
54 | + $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
55 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
56 | + $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
57 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
58 | + $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); |
|
59 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
60 | + |
|
61 | + if ($found) { |
|
62 | + return; |
|
63 | + } |
|
64 | + } else if ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
65 | + || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
66 | + || $this->appendIfExist($this->serverroot, $script.'.js') |
|
67 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
68 | + || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
69 | + || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
70 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
71 | + ) { |
|
72 | + return; |
|
73 | + } |
|
74 | + |
|
75 | + $app = substr($script, 0, strpos($script, '/')); |
|
76 | + $script = substr($script, strpos($script, '/')+1); |
|
77 | + $app_path = \OC_App::getAppPath($app); |
|
78 | + $app_url = \OC_App::getAppWebPath($app); |
|
79 | + |
|
80 | + if ($app_path !== false) { |
|
81 | + // Account for the possibility of having symlinks in app path. Only |
|
82 | + // do this if $app_path is set, because an empty argument to realpath |
|
83 | + // gets turned into cwd. |
|
84 | + $app_path = realpath($app_path); |
|
85 | + } |
|
86 | + |
|
87 | + // missing translations files fill be ignored |
|
88 | + if (strpos($script, 'l10n/') === 0) { |
|
89 | + $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
90 | + return; |
|
91 | + } |
|
92 | + |
|
93 | + if ($app_path === false && $app_url === false) { |
|
94 | + $this->logger->error('Could not find resource {resource} to load', [ |
|
95 | + 'resource' => $app . '/' . $script . '.js', |
|
96 | + 'app' => 'jsresourceloader', |
|
97 | + ]); |
|
98 | + return; |
|
99 | + } |
|
100 | + |
|
101 | + if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
102 | + $this->append($app_path, $script . '.js', $app_url); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @param string $script |
|
108 | + */ |
|
109 | + public function doFindTheme($script) { |
|
110 | + } |
|
111 | + |
|
112 | + protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
113 | + if (is_file($root.'/'.$file)) { |
|
114 | + if ($this->jsCombiner->process($root, $file, $app)) { |
|
115 | + $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
116 | + } else { |
|
117 | + // Add all the files from the json |
|
118 | + $files = $this->jsCombiner->getContent($root, $file); |
|
119 | + $app_url = \OC_App::getAppWebPath($app); |
|
120 | + |
|
121 | + foreach ($files as $jsFile) { |
|
122 | + $this->append($root, $jsFile, $app_url); |
|
123 | + } |
|
124 | + } |
|
125 | + return true; |
|
126 | + } |
|
127 | + |
|
128 | + return false; |
|
129 | + } |
|
130 | 130 | } |
@@ -29,31 +29,31 @@ |
||
29 | 29 | |
30 | 30 | class Additional implements ISettings { |
31 | 31 | |
32 | - /** |
|
33 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
34 | - * @since 9.1 |
|
35 | - */ |
|
36 | - public function getForm() { |
|
37 | - return new TemplateResponse('settings', 'settings/empty'); |
|
38 | - } |
|
32 | + /** |
|
33 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
34 | + * @since 9.1 |
|
35 | + */ |
|
36 | + public function getForm() { |
|
37 | + return new TemplateResponse('settings', 'settings/empty'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string the section ID, e.g. 'sharing' |
|
42 | - * @since 9.1 |
|
43 | - */ |
|
44 | - public function getSection() { |
|
45 | - return 'additional'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string the section ID, e.g. 'sharing' |
|
42 | + * @since 9.1 |
|
43 | + */ |
|
44 | + public function getSection() { |
|
45 | + return 'additional'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return int whether the form should be rather on the top or bottom of |
|
50 | - * the admin section. The forms are arranged in ascending order of the |
|
51 | - * priority values. It is required to return a value between 0 and 100. |
|
52 | - * |
|
53 | - * E.g.: 70 |
|
54 | - * @since 9.1 |
|
55 | - */ |
|
56 | - public function getPriority() { |
|
57 | - return '5'; |
|
58 | - } |
|
48 | + /** |
|
49 | + * @return int whether the form should be rather on the top or bottom of |
|
50 | + * the admin section. The forms are arranged in ascending order of the |
|
51 | + * priority values. It is required to return a value between 0 and 100. |
|
52 | + * |
|
53 | + * E.g.: 70 |
|
54 | + * @since 9.1 |
|
55 | + */ |
|
56 | + public function getPriority() { |
|
57 | + return '5'; |
|
58 | + } |
|
59 | 59 | } |
@@ -27,45 +27,45 @@ |
||
27 | 27 | |
28 | 28 | class Config implements \OCP\GlobalScale\IConfig { |
29 | 29 | |
30 | - /** @var IConfig */ |
|
31 | - private $config; |
|
30 | + /** @var IConfig */ |
|
31 | + private $config; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Config constructor. |
|
35 | - * |
|
36 | - * @param IConfig $config |
|
37 | - */ |
|
38 | - public function __construct(IConfig $config) { |
|
39 | - $this->config = $config; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Config constructor. |
|
35 | + * |
|
36 | + * @param IConfig $config |
|
37 | + */ |
|
38 | + public function __construct(IConfig $config) { |
|
39 | + $this->config = $config; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * check if global scale is enabled |
|
44 | - * |
|
45 | - * @since 12.0.1 |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function isGlobalScaleEnabled() { |
|
49 | - $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | - return $enabled !== false; |
|
51 | - } |
|
42 | + /** |
|
43 | + * check if global scale is enabled |
|
44 | + * |
|
45 | + * @since 12.0.1 |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function isGlobalScaleEnabled() { |
|
49 | + $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | + return $enabled !== false; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * check if federation should only be used internally in a global scale setup |
|
55 | - * |
|
56 | - * @since 12.0.1 |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function onlyInternalFederation() { |
|
60 | - // if global scale is disabled federation works always globally |
|
61 | - $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | - if ($gsEnabled === false) { |
|
63 | - return false; |
|
64 | - } |
|
53 | + /** |
|
54 | + * check if federation should only be used internally in a global scale setup |
|
55 | + * |
|
56 | + * @since 12.0.1 |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function onlyInternalFederation() { |
|
60 | + // if global scale is disabled federation works always globally |
|
61 | + $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | + if ($gsEnabled === false) { |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | |
66 | - $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
66 | + $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
67 | 67 | |
68 | - return $enabled === 'internal'; |
|
69 | - } |
|
68 | + return $enabled === 'internal'; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -32,20 +32,20 @@ |
||
32 | 32 | */ |
33 | 33 | interface IConfig { |
34 | 34 | |
35 | - /** |
|
36 | - * check if global scale is enabled |
|
37 | - * |
|
38 | - * @since 12.0.1 |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - public function isGlobalScaleEnabled(); |
|
35 | + /** |
|
36 | + * check if global scale is enabled |
|
37 | + * |
|
38 | + * @since 12.0.1 |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + public function isGlobalScaleEnabled(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * check if federation should only be used internally in a global scale setup |
|
45 | - * |
|
46 | - * @since 12.0.1 |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public function onlyInternalFederation(); |
|
43 | + /** |
|
44 | + * check if federation should only be used internally in a global scale setup |
|
45 | + * |
|
46 | + * @since 12.0.1 |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public function onlyInternalFederation(); |
|
50 | 50 | |
51 | 51 | } |