@@ -34,13 +34,13 @@ |
||
34 | 34 | */ |
35 | 35 | class BackupCode extends Entity { |
36 | 36 | |
37 | - /** @var string */ |
|
38 | - protected $userId; |
|
37 | + /** @var string */ |
|
38 | + protected $userId; |
|
39 | 39 | |
40 | - /** @var string */ |
|
41 | - protected $code; |
|
40 | + /** @var string */ |
|
41 | + protected $code; |
|
42 | 42 | |
43 | - /** @var int */ |
|
44 | - protected $used; |
|
43 | + /** @var int */ |
|
44 | + protected $used; |
|
45 | 45 | |
46 | 46 | } |
@@ -128,7 +128,7 @@ |
||
128 | 128 | $encryptedKey = $this->crypt->encryptPrivateKey($decryptedKey, $newPassword, $uid); |
129 | 129 | $header = $this->crypt->generateHeader(); |
130 | 130 | if ($encryptedKey) { |
131 | - $this->keyManager->setPrivateKey($uid, $header . $encryptedKey); |
|
131 | + $this->keyManager->setPrivateKey($uid, $header.$encryptedKey); |
|
132 | 132 | $this->session->setPrivateKey($decryptedKey); |
133 | 133 | $result = true; |
134 | 134 | } |
@@ -24,95 +24,95 @@ |
||
24 | 24 | |
25 | 25 | class SettingsController extends Controller { |
26 | 26 | |
27 | - /** |
|
28 | - * @param string $AppName |
|
29 | - * @param IRequest $request |
|
30 | - * @param IL10N $l |
|
31 | - * @param IUserManager $userManager |
|
32 | - * @param IUserSession $userSession |
|
33 | - * @param KeyManager $keyManager |
|
34 | - * @param Crypt $crypt |
|
35 | - * @param Session $session |
|
36 | - * @param ISession $ocSession |
|
37 | - * @param Util $util |
|
38 | - */ |
|
39 | - public function __construct( |
|
40 | - $AppName, |
|
41 | - IRequest $request, |
|
42 | - private IL10N $l, |
|
43 | - private IUserManager $userManager, |
|
44 | - private IUserSession $userSession, |
|
45 | - private KeyManager $keyManager, |
|
46 | - private Crypt $crypt, |
|
47 | - private Session $session, |
|
48 | - private ISession $ocSession, |
|
49 | - private Util $util, |
|
50 | - ) { |
|
51 | - parent::__construct($AppName, $request); |
|
52 | - } |
|
27 | + /** |
|
28 | + * @param string $AppName |
|
29 | + * @param IRequest $request |
|
30 | + * @param IL10N $l |
|
31 | + * @param IUserManager $userManager |
|
32 | + * @param IUserSession $userSession |
|
33 | + * @param KeyManager $keyManager |
|
34 | + * @param Crypt $crypt |
|
35 | + * @param Session $session |
|
36 | + * @param ISession $ocSession |
|
37 | + * @param Util $util |
|
38 | + */ |
|
39 | + public function __construct( |
|
40 | + $AppName, |
|
41 | + IRequest $request, |
|
42 | + private IL10N $l, |
|
43 | + private IUserManager $userManager, |
|
44 | + private IUserSession $userSession, |
|
45 | + private KeyManager $keyManager, |
|
46 | + private Crypt $crypt, |
|
47 | + private Session $session, |
|
48 | + private ISession $ocSession, |
|
49 | + private Util $util, |
|
50 | + ) { |
|
51 | + parent::__construct($AppName, $request); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @param string $oldPassword |
|
57 | - * @param string $newPassword |
|
58 | - * @return DataResponse |
|
59 | - */ |
|
60 | - #[NoAdminRequired] |
|
61 | - #[UseSession] |
|
62 | - public function updatePrivateKeyPassword($oldPassword, $newPassword) { |
|
63 | - $result = false; |
|
64 | - $uid = $this->userSession->getUser()->getUID(); |
|
65 | - $errorMessage = $this->l->t('Could not update the private key password.'); |
|
55 | + /** |
|
56 | + * @param string $oldPassword |
|
57 | + * @param string $newPassword |
|
58 | + * @return DataResponse |
|
59 | + */ |
|
60 | + #[NoAdminRequired] |
|
61 | + #[UseSession] |
|
62 | + public function updatePrivateKeyPassword($oldPassword, $newPassword) { |
|
63 | + $result = false; |
|
64 | + $uid = $this->userSession->getUser()->getUID(); |
|
65 | + $errorMessage = $this->l->t('Could not update the private key password.'); |
|
66 | 66 | |
67 | - //check if password is correct |
|
68 | - $passwordCorrect = $this->userManager->checkPassword($uid, $newPassword); |
|
69 | - if ($passwordCorrect === false) { |
|
70 | - // if check with uid fails we need to check the password with the login name |
|
71 | - // e.g. in the ldap case. For local user we need to check the password with |
|
72 | - // the uid because in this case the login name is case insensitive |
|
73 | - $loginName = $this->ocSession->get('loginname'); |
|
74 | - $passwordCorrect = $this->userManager->checkPassword($loginName, $newPassword); |
|
75 | - } |
|
67 | + //check if password is correct |
|
68 | + $passwordCorrect = $this->userManager->checkPassword($uid, $newPassword); |
|
69 | + if ($passwordCorrect === false) { |
|
70 | + // if check with uid fails we need to check the password with the login name |
|
71 | + // e.g. in the ldap case. For local user we need to check the password with |
|
72 | + // the uid because in this case the login name is case insensitive |
|
73 | + $loginName = $this->ocSession->get('loginname'); |
|
74 | + $passwordCorrect = $this->userManager->checkPassword($loginName, $newPassword); |
|
75 | + } |
|
76 | 76 | |
77 | - if ($passwordCorrect !== false) { |
|
78 | - $encryptedKey = $this->keyManager->getPrivateKey($uid); |
|
79 | - $decryptedKey = $this->crypt->decryptPrivateKey($encryptedKey, $oldPassword, $uid); |
|
77 | + if ($passwordCorrect !== false) { |
|
78 | + $encryptedKey = $this->keyManager->getPrivateKey($uid); |
|
79 | + $decryptedKey = $this->crypt->decryptPrivateKey($encryptedKey, $oldPassword, $uid); |
|
80 | 80 | |
81 | - if ($decryptedKey) { |
|
82 | - $encryptedKey = $this->crypt->encryptPrivateKey($decryptedKey, $newPassword, $uid); |
|
83 | - $header = $this->crypt->generateHeader(); |
|
84 | - if ($encryptedKey) { |
|
85 | - $this->keyManager->setPrivateKey($uid, $header . $encryptedKey); |
|
86 | - $this->session->setPrivateKey($decryptedKey); |
|
87 | - $result = true; |
|
88 | - } |
|
89 | - } else { |
|
90 | - $errorMessage = $this->l->t('The old password was not correct, please try again.'); |
|
91 | - } |
|
92 | - } else { |
|
93 | - $errorMessage = $this->l->t('The current log-in password was not correct, please try again.'); |
|
94 | - } |
|
81 | + if ($decryptedKey) { |
|
82 | + $encryptedKey = $this->crypt->encryptPrivateKey($decryptedKey, $newPassword, $uid); |
|
83 | + $header = $this->crypt->generateHeader(); |
|
84 | + if ($encryptedKey) { |
|
85 | + $this->keyManager->setPrivateKey($uid, $header . $encryptedKey); |
|
86 | + $this->session->setPrivateKey($decryptedKey); |
|
87 | + $result = true; |
|
88 | + } |
|
89 | + } else { |
|
90 | + $errorMessage = $this->l->t('The old password was not correct, please try again.'); |
|
91 | + } |
|
92 | + } else { |
|
93 | + $errorMessage = $this->l->t('The current log-in password was not correct, please try again.'); |
|
94 | + } |
|
95 | 95 | |
96 | - if ($result === true) { |
|
97 | - $this->session->setStatus(Session::INIT_SUCCESSFUL); |
|
98 | - return new DataResponse( |
|
99 | - ['message' => $this->l->t('Private key password successfully updated.')] |
|
100 | - ); |
|
101 | - } else { |
|
102 | - return new DataResponse( |
|
103 | - ['message' => $errorMessage], |
|
104 | - Http::STATUS_BAD_REQUEST |
|
105 | - ); |
|
106 | - } |
|
107 | - } |
|
96 | + if ($result === true) { |
|
97 | + $this->session->setStatus(Session::INIT_SUCCESSFUL); |
|
98 | + return new DataResponse( |
|
99 | + ['message' => $this->l->t('Private key password successfully updated.')] |
|
100 | + ); |
|
101 | + } else { |
|
102 | + return new DataResponse( |
|
103 | + ['message' => $errorMessage], |
|
104 | + Http::STATUS_BAD_REQUEST |
|
105 | + ); |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @param bool $encryptHomeStorage |
|
111 | - * @return DataResponse |
|
112 | - */ |
|
113 | - #[UseSession] |
|
114 | - public function setEncryptHomeStorage($encryptHomeStorage) { |
|
115 | - $this->util->setEncryptHomeStorage($encryptHomeStorage); |
|
116 | - return new DataResponse(); |
|
117 | - } |
|
109 | + /** |
|
110 | + * @param bool $encryptHomeStorage |
|
111 | + * @return DataResponse |
|
112 | + */ |
|
113 | + #[UseSession] |
|
114 | + public function setEncryptHomeStorage($encryptHomeStorage) { |
|
115 | + $this->util->setEncryptHomeStorage($encryptHomeStorage); |
|
116 | + return new DataResponse(); |
|
117 | + } |
|
118 | 118 | } |
@@ -60,9 +60,9 @@ |
||
60 | 60 | |
61 | 61 | public function propFind(PropFind $propFind, INode $node) { |
62 | 62 | /* Overload current-user-principal */ |
63 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
63 | + $propFind->handle('{DAV:}current-user-principal', function() { |
|
64 | 64 | if ($url = parent::getCurrentUserPrincipal()) { |
65 | - return new Principal(Principal::HREF, $url . '/'); |
|
65 | + return new Principal(Principal::HREF, $url.'/'); |
|
66 | 66 | } else { |
67 | 67 | return new Principal(Principal::UNAUTHENTICATED); |
68 | 68 | } |
@@ -14,44 +14,44 @@ |
||
14 | 14 | |
15 | 15 | class LegacyDAVACL extends DavAclPlugin { |
16 | 16 | |
17 | - /** |
|
18 | - * @inheritdoc |
|
19 | - */ |
|
20 | - public function getCurrentUserPrincipals() { |
|
21 | - $principalV2 = $this->getCurrentUserPrincipal(); |
|
22 | - |
|
23 | - if (is_null($principalV2)) { |
|
24 | - return []; |
|
25 | - } |
|
26 | - |
|
27 | - $principalV1 = $this->convertPrincipal($principalV2, false); |
|
28 | - return array_merge( |
|
29 | - [ |
|
30 | - $principalV2, |
|
31 | - $principalV1 |
|
32 | - ], |
|
33 | - $this->getPrincipalMembership($principalV1) |
|
34 | - ); |
|
35 | - } |
|
36 | - |
|
37 | - private function convertPrincipal($principal, $toV2) { |
|
38 | - [, $name] = \Sabre\Uri\split($principal); |
|
39 | - if ($toV2) { |
|
40 | - return "principals/users/$name"; |
|
41 | - } |
|
42 | - return "principals/$name"; |
|
43 | - } |
|
44 | - |
|
45 | - public function propFind(PropFind $propFind, INode $node) { |
|
46 | - /* Overload current-user-principal */ |
|
47 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
48 | - if ($url = parent::getCurrentUserPrincipal()) { |
|
49 | - return new Principal(Principal::HREF, $url . '/'); |
|
50 | - } else { |
|
51 | - return new Principal(Principal::UNAUTHENTICATED); |
|
52 | - } |
|
53 | - }); |
|
54 | - |
|
55 | - return parent::propFind($propFind, $node); |
|
56 | - } |
|
17 | + /** |
|
18 | + * @inheritdoc |
|
19 | + */ |
|
20 | + public function getCurrentUserPrincipals() { |
|
21 | + $principalV2 = $this->getCurrentUserPrincipal(); |
|
22 | + |
|
23 | + if (is_null($principalV2)) { |
|
24 | + return []; |
|
25 | + } |
|
26 | + |
|
27 | + $principalV1 = $this->convertPrincipal($principalV2, false); |
|
28 | + return array_merge( |
|
29 | + [ |
|
30 | + $principalV2, |
|
31 | + $principalV1 |
|
32 | + ], |
|
33 | + $this->getPrincipalMembership($principalV1) |
|
34 | + ); |
|
35 | + } |
|
36 | + |
|
37 | + private function convertPrincipal($principal, $toV2) { |
|
38 | + [, $name] = \Sabre\Uri\split($principal); |
|
39 | + if ($toV2) { |
|
40 | + return "principals/users/$name"; |
|
41 | + } |
|
42 | + return "principals/$name"; |
|
43 | + } |
|
44 | + |
|
45 | + public function propFind(PropFind $propFind, INode $node) { |
|
46 | + /* Overload current-user-principal */ |
|
47 | + $propFind->handle('{DAV:}current-user-principal', function () { |
|
48 | + if ($url = parent::getCurrentUserPrincipal()) { |
|
49 | + return new Principal(Principal::HREF, $url . '/'); |
|
50 | + } else { |
|
51 | + return new Principal(Principal::UNAUTHENTICATED); |
|
52 | + } |
|
53 | + }); |
|
54 | + |
|
55 | + return parent::propFind($propFind, $node); |
|
56 | + } |
|
57 | 57 | } |
@@ -38,12 +38,12 @@ |
||
38 | 38 | * @since 6.0.0 |
39 | 39 | */ |
40 | 40 | interface IConsumer { |
41 | - /** |
|
42 | - * @param IEvent $event |
|
43 | - * @return null |
|
44 | - * @since 6.0.0 |
|
45 | - * @since 8.2.0 Replaced the parameters with an IEvent object |
|
46 | - */ |
|
47 | - public function receive(IEvent $event); |
|
41 | + /** |
|
42 | + * @param IEvent $event |
|
43 | + * @return null |
|
44 | + * @since 6.0.0 |
|
45 | + * @since 8.2.0 Replaced the parameters with an IEvent object |
|
46 | + */ |
|
47 | + public function receive(IEvent $event); |
|
48 | 48 | } |
49 | 49 |
@@ -30,10 +30,10 @@ |
||
30 | 30 | * @since 8.0.0 |
31 | 31 | */ |
32 | 32 | interface IDateTimeZone { |
33 | - /** |
|
34 | - * @param bool|int $timestamp |
|
35 | - * @return \DateTimeZone |
|
36 | - * @since 8.0.0 - parameter $timestamp was added in 8.1.0 |
|
37 | - */ |
|
38 | - public function getTimeZone($timestamp = false); |
|
33 | + /** |
|
34 | + * @param bool|int $timestamp |
|
35 | + * @return \DateTimeZone |
|
36 | + * @since 8.0.0 - parameter $timestamp was added in 8.1.0 |
|
37 | + */ |
|
38 | + public function getTimeZone($timestamp = false); |
|
39 | 39 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | */ |
62 | 62 | public function addEntityCollection($name, \Closure $entityExistsFunction) { |
63 | 63 | if (isset($this->collections[$name])) { |
64 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
64 | + throw new \OutOfBoundsException('Duplicate entity name "'.$name.'"'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $this->collections[$name] = $entityExistsFunction; |
@@ -16,47 +16,47 @@ |
||
16 | 16 | * @since 28.0.0 Dispatched as a typed event |
17 | 17 | */ |
18 | 18 | class CommentsEntityEvent extends Event { |
19 | - /** |
|
20 | - * @since 9.1.0 |
|
21 | - * @deprecated 22.0.0 - Listen to the typed event instead. |
|
22 | - */ |
|
23 | - public const EVENT_ENTITY = 'OCP\Comments\ICommentsManager::registerEntity'; |
|
24 | - |
|
25 | - /** @var \Closure[] */ |
|
26 | - protected $collections; |
|
27 | - |
|
28 | - /** |
|
29 | - * DispatcherEvent constructor. |
|
30 | - * |
|
31 | - * @since 9.1.0 |
|
32 | - */ |
|
33 | - public function __construct() { |
|
34 | - parent::__construct(); |
|
35 | - $this->collections = []; |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $name |
|
40 | - * @param \Closure $entityExistsFunction The closure should take one |
|
41 | - * argument, which is the id of the entity, that comments |
|
42 | - * should be handled for. The return should then be bool, |
|
43 | - * depending on whether comments are allowed (true) or not. |
|
44 | - * @throws \OutOfBoundsException when the entity name is already taken |
|
45 | - * @since 9.1.0 |
|
46 | - */ |
|
47 | - public function addEntityCollection($name, \Closure $entityExistsFunction) { |
|
48 | - if (isset($this->collections[$name])) { |
|
49 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
50 | - } |
|
51 | - |
|
52 | - $this->collections[$name] = $entityExistsFunction; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * @return \Closure[] |
|
57 | - * @since 9.1.0 |
|
58 | - */ |
|
59 | - public function getEntityCollections() { |
|
60 | - return $this->collections; |
|
61 | - } |
|
19 | + /** |
|
20 | + * @since 9.1.0 |
|
21 | + * @deprecated 22.0.0 - Listen to the typed event instead. |
|
22 | + */ |
|
23 | + public const EVENT_ENTITY = 'OCP\Comments\ICommentsManager::registerEntity'; |
|
24 | + |
|
25 | + /** @var \Closure[] */ |
|
26 | + protected $collections; |
|
27 | + |
|
28 | + /** |
|
29 | + * DispatcherEvent constructor. |
|
30 | + * |
|
31 | + * @since 9.1.0 |
|
32 | + */ |
|
33 | + public function __construct() { |
|
34 | + parent::__construct(); |
|
35 | + $this->collections = []; |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $name |
|
40 | + * @param \Closure $entityExistsFunction The closure should take one |
|
41 | + * argument, which is the id of the entity, that comments |
|
42 | + * should be handled for. The return should then be bool, |
|
43 | + * depending on whether comments are allowed (true) or not. |
|
44 | + * @throws \OutOfBoundsException when the entity name is already taken |
|
45 | + * @since 9.1.0 |
|
46 | + */ |
|
47 | + public function addEntityCollection($name, \Closure $entityExistsFunction) { |
|
48 | + if (isset($this->collections[$name])) { |
|
49 | + throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
50 | + } |
|
51 | + |
|
52 | + $this->collections[$name] = $entityExistsFunction; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * @return \Closure[] |
|
57 | + * @since 9.1.0 |
|
58 | + */ |
|
59 | + public function getEntityCollections() { |
|
60 | + return $this->collections; |
|
61 | + } |
|
62 | 62 | } |
@@ -30,33 +30,33 @@ |
||
30 | 30 | * @since 8.0.0 |
31 | 31 | */ |
32 | 32 | interface IEvent { |
33 | - /** |
|
34 | - * @return string |
|
35 | - * @since 8.0.0 |
|
36 | - */ |
|
37 | - public function getId(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + * @since 8.0.0 |
|
36 | + */ |
|
37 | + public function getId(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - * @since 8.0.0 |
|
42 | - */ |
|
43 | - public function getDescription(); |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + * @since 8.0.0 |
|
42 | + */ |
|
43 | + public function getDescription(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return float |
|
47 | - * @since 8.0.0 |
|
48 | - */ |
|
49 | - public function getStart(); |
|
45 | + /** |
|
46 | + * @return float |
|
47 | + * @since 8.0.0 |
|
48 | + */ |
|
49 | + public function getStart(); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return float |
|
53 | - * @since 8.0.0 |
|
54 | - */ |
|
55 | - public function getEnd(); |
|
51 | + /** |
|
52 | + * @return float |
|
53 | + * @since 8.0.0 |
|
54 | + */ |
|
55 | + public function getEnd(); |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return float |
|
59 | - * @since 8.0.0 |
|
60 | - */ |
|
61 | - public function getDuration(); |
|
57 | + /** |
|
58 | + * @return float |
|
59 | + * @since 8.0.0 |
|
60 | + */ |
|
61 | + public function getDuration(); |
|
62 | 62 | } |
@@ -30,9 +30,9 @@ |
||
30 | 30 | * @since 8.1.0 |
31 | 31 | */ |
32 | 32 | interface ICommand { |
33 | - /** |
|
34 | - * Run the command |
|
35 | - * @since 8.1.0 |
|
36 | - */ |
|
37 | - public function handle(); |
|
33 | + /** |
|
34 | + * Run the command |
|
35 | + * @since 8.1.0 |
|
36 | + */ |
|
37 | + public function handle(); |
|
38 | 38 | } |
@@ -30,19 +30,19 @@ |
||
30 | 30 | * @since 8.1.0 |
31 | 31 | */ |
32 | 32 | interface IBus { |
33 | - /** |
|
34 | - * Schedule a command to be fired |
|
35 | - * |
|
36 | - * @param \OCP\Command\ICommand | callable $command |
|
37 | - * @since 8.1.0 |
|
38 | - */ |
|
39 | - public function push($command); |
|
33 | + /** |
|
34 | + * Schedule a command to be fired |
|
35 | + * |
|
36 | + * @param \OCP\Command\ICommand | callable $command |
|
37 | + * @since 8.1.0 |
|
38 | + */ |
|
39 | + public function push($command); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Require all commands using a trait to be run synchronous |
|
43 | - * |
|
44 | - * @param string $trait |
|
45 | - * @since 8.1.0 |
|
46 | - */ |
|
47 | - public function requireSync($trait); |
|
41 | + /** |
|
42 | + * Require all commands using a trait to be run synchronous |
|
43 | + * |
|
44 | + * @param string $trait |
|
45 | + * @since 8.1.0 |
|
46 | + */ |
|
47 | + public function requireSync($trait); |
|
48 | 48 | } |