@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | // Save private key |
| 267 | 267 | if ($encryptedPrivateKey) { |
| 268 | 268 | $this->keyManager->setPrivateKey($user->getUID(), |
| 269 | - $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
| 269 | + $this->crypt->generateHeader().$encryptedPrivateKey); |
|
| 270 | 270 | } else { |
| 271 | 271 | $this->logger->error('Encryption could not update users encryption password'); |
| 272 | 272 | } |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); |
| 316 | 316 | |
| 317 | 317 | if ($encryptedKey) { |
| 318 | - $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); |
|
| 318 | + $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader().$encryptedKey); |
|
| 319 | 319 | |
| 320 | 320 | if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
| 321 | 321 | $this->recovery->recoverUsersFiles($recoveryPassword, $userId); |
@@ -44,304 +44,304 @@ |
||
| 44 | 44 | |
| 45 | 45 | class UserHooks implements IHook { |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * list of user for which we perform a password reset |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 51 | - protected static $passwordResetUsers = []; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var KeyManager |
|
| 55 | - */ |
|
| 56 | - private $keyManager; |
|
| 57 | - /** |
|
| 58 | - * @var IUserManager |
|
| 59 | - */ |
|
| 60 | - private $userManager; |
|
| 61 | - /** |
|
| 62 | - * @var ILogger |
|
| 63 | - */ |
|
| 64 | - private $logger; |
|
| 65 | - /** |
|
| 66 | - * @var Setup |
|
| 67 | - */ |
|
| 68 | - private $userSetup; |
|
| 69 | - /** |
|
| 70 | - * @var IUserSession |
|
| 71 | - */ |
|
| 72 | - private $userSession; |
|
| 73 | - /** |
|
| 74 | - * @var Util |
|
| 75 | - */ |
|
| 76 | - private $util; |
|
| 77 | - /** |
|
| 78 | - * @var Session |
|
| 79 | - */ |
|
| 80 | - private $session; |
|
| 81 | - /** |
|
| 82 | - * @var Recovery |
|
| 83 | - */ |
|
| 84 | - private $recovery; |
|
| 85 | - /** |
|
| 86 | - * @var Crypt |
|
| 87 | - */ |
|
| 88 | - private $crypt; |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * UserHooks constructor. |
|
| 92 | - * |
|
| 93 | - * @param KeyManager $keyManager |
|
| 94 | - * @param IUserManager $userManager |
|
| 95 | - * @param ILogger $logger |
|
| 96 | - * @param Setup $userSetup |
|
| 97 | - * @param IUserSession $userSession |
|
| 98 | - * @param Util $util |
|
| 99 | - * @param Session $session |
|
| 100 | - * @param Crypt $crypt |
|
| 101 | - * @param Recovery $recovery |
|
| 102 | - */ |
|
| 103 | - public function __construct(KeyManager $keyManager, |
|
| 104 | - IUserManager $userManager, |
|
| 105 | - ILogger $logger, |
|
| 106 | - Setup $userSetup, |
|
| 107 | - IUserSession $userSession, |
|
| 108 | - Util $util, |
|
| 109 | - Session $session, |
|
| 110 | - Crypt $crypt, |
|
| 111 | - Recovery $recovery) { |
|
| 112 | - $this->keyManager = $keyManager; |
|
| 113 | - $this->userManager = $userManager; |
|
| 114 | - $this->logger = $logger; |
|
| 115 | - $this->userSetup = $userSetup; |
|
| 116 | - $this->userSession = $userSession; |
|
| 117 | - $this->util = $util; |
|
| 118 | - $this->session = $session; |
|
| 119 | - $this->recovery = $recovery; |
|
| 120 | - $this->crypt = $crypt; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Connects Hooks |
|
| 125 | - * |
|
| 126 | - * @return null |
|
| 127 | - */ |
|
| 128 | - public function addHooks() { |
|
| 129 | - OCUtil::connectHook('OC_User', 'post_login', $this, 'login'); |
|
| 130 | - OCUtil::connectHook('OC_User', 'logout', $this, 'logout'); |
|
| 131 | - |
|
| 132 | - // this hooks only make sense if no master key is used |
|
| 133 | - if ($this->util->isMasterKeyEnabled() === false) { |
|
| 134 | - OCUtil::connectHook('OC_User', |
|
| 135 | - 'post_setPassword', |
|
| 136 | - $this, |
|
| 137 | - 'setPassphrase'); |
|
| 138 | - |
|
| 139 | - OCUtil::connectHook('OC_User', |
|
| 140 | - 'pre_setPassword', |
|
| 141 | - $this, |
|
| 142 | - 'preSetPassphrase'); |
|
| 143 | - |
|
| 144 | - OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
| 145 | - 'post_passwordReset', |
|
| 146 | - $this, |
|
| 147 | - 'postPasswordReset'); |
|
| 148 | - |
|
| 149 | - OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
| 150 | - 'pre_passwordReset', |
|
| 151 | - $this, |
|
| 152 | - 'prePasswordReset'); |
|
| 153 | - |
|
| 154 | - OCUtil::connectHook('OC_User', |
|
| 155 | - 'post_createUser', |
|
| 156 | - $this, |
|
| 157 | - 'postCreateUser'); |
|
| 158 | - |
|
| 159 | - OCUtil::connectHook('OC_User', |
|
| 160 | - 'post_deleteUser', |
|
| 161 | - $this, |
|
| 162 | - 'postDeleteUser'); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Startup encryption backend upon user login |
|
| 169 | - * |
|
| 170 | - * @note This method should never be called for users using client side encryption |
|
| 171 | - * @param array $params |
|
| 172 | - * @return boolean|null |
|
| 173 | - */ |
|
| 174 | - public function login($params) { |
|
| 175 | - // ensure filesystem is loaded |
|
| 176 | - if (!\OC\Files\Filesystem::$loaded) { |
|
| 177 | - $this->setupFS($params['uid']); |
|
| 178 | - } |
|
| 179 | - if ($this->util->isMasterKeyEnabled() === false) { |
|
| 180 | - $this->userSetup->setupUser($params['uid'], $params['password']); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $this->keyManager->init($params['uid'], $params['password']); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * remove keys from session during logout |
|
| 188 | - */ |
|
| 189 | - public function logout() { |
|
| 190 | - $this->session->clear(); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * setup encryption backend upon user created |
|
| 195 | - * |
|
| 196 | - * @note This method should never be called for users using client side encryption |
|
| 197 | - * @param array $params |
|
| 198 | - */ |
|
| 199 | - public function postCreateUser($params) { |
|
| 200 | - $this->userSetup->setupUser($params['uid'], $params['password']); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * cleanup encryption backend upon user deleted |
|
| 205 | - * |
|
| 206 | - * @param array $params : uid, password |
|
| 207 | - * @note This method should never be called for users using client side encryption |
|
| 208 | - */ |
|
| 209 | - public function postDeleteUser($params) { |
|
| 210 | - $this->keyManager->deletePublicKey($params['uid']); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - public function prePasswordReset($params) { |
|
| 214 | - $user = $params['uid']; |
|
| 215 | - self::$passwordResetUsers[$user] = true; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - public function postPasswordReset($params) { |
|
| 219 | - $uid = $params['uid']; |
|
| 220 | - $password = $params['password']; |
|
| 221 | - $this->keyManager->backupUserKeys('passwordReset', $uid); |
|
| 222 | - $this->keyManager->deleteUserKeys($uid); |
|
| 223 | - $this->userSetup->setupUser($uid, $password); |
|
| 224 | - unset(self::$passwordResetUsers[$uid]); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * If the password can't be changed within Nextcloud, than update the key password in advance. |
|
| 229 | - * |
|
| 230 | - * @param array $params : uid, password |
|
| 231 | - * @return boolean|null |
|
| 232 | - */ |
|
| 233 | - public function preSetPassphrase($params) { |
|
| 234 | - $user = $this->userManager->get($params['uid']); |
|
| 235 | - |
|
| 236 | - if ($user && !$user->canChangePassword()) { |
|
| 237 | - $this->setPassphrase($params); |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Change a user's encryption passphrase |
|
| 243 | - * |
|
| 244 | - * @param array $params keys: uid, password |
|
| 245 | - * @return boolean|null |
|
| 246 | - */ |
|
| 247 | - public function setPassphrase($params) { |
|
| 248 | - |
|
| 249 | - // if we are in the process to resetting a user password, we have nothing |
|
| 250 | - // to do here |
|
| 251 | - if (isset(self::$passwordResetUsers[$params['uid']])) { |
|
| 252 | - return true; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // Get existing decrypted private key |
|
| 256 | - $user = $this->userSession->getUser(); |
|
| 257 | - |
|
| 258 | - // current logged in user changes his own password |
|
| 259 | - if ($user && $params['uid'] === $user->getUID()) { |
|
| 260 | - $privateKey = $this->session->getPrivateKey(); |
|
| 261 | - |
|
| 262 | - // Encrypt private key with new user pwd as passphrase |
|
| 263 | - $encryptedPrivateKey = $this->crypt->encryptPrivateKey($privateKey, $params['password'], $params['uid']); |
|
| 264 | - |
|
| 265 | - // Save private key |
|
| 266 | - if ($encryptedPrivateKey) { |
|
| 267 | - $this->keyManager->setPrivateKey($user->getUID(), |
|
| 268 | - $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
| 269 | - } else { |
|
| 270 | - $this->logger->error('Encryption could not update users encryption password'); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - // NOTE: Session does not need to be updated as the |
|
| 274 | - // private key has not changed, only the passphrase |
|
| 275 | - // used to decrypt it has changed |
|
| 276 | - } else { // admin changed the password for a different user, create new keys and re-encrypt file keys |
|
| 277 | - $userId = $params['uid']; |
|
| 278 | - $this->initMountPoints($userId); |
|
| 279 | - $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null; |
|
| 280 | - |
|
| 281 | - $recoveryKeyId = $this->keyManager->getRecoveryKeyId(); |
|
| 282 | - $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId); |
|
| 283 | - try { |
|
| 284 | - $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $recoveryPassword); |
|
| 285 | - } catch (\Exception $e) { |
|
| 286 | - $decryptedRecoveryKey = false; |
|
| 287 | - } |
|
| 288 | - if ($decryptedRecoveryKey === false) { |
|
| 289 | - $message = 'Can not decrypt the recovery key. Maybe you provided the wrong password. Try again.'; |
|
| 290 | - throw new GenericEncryptionException($message, $message); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - // we generate new keys if... |
|
| 294 | - // ...we have a recovery password and the user enabled the recovery key |
|
| 295 | - // ...encryption was activated for the first time (no keys exists) |
|
| 296 | - // ...the user doesn't have any files |
|
| 297 | - if ( |
|
| 298 | - ($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword) |
|
| 299 | - || !$this->keyManager->userHasKeys($userId) |
|
| 300 | - || !$this->util->userHasFiles($userId) |
|
| 301 | - ) { |
|
| 302 | - |
|
| 303 | - // backup old keys |
|
| 304 | - //$this->backupAllKeys('recovery'); |
|
| 305 | - |
|
| 306 | - $newUserPassword = $params['password']; |
|
| 307 | - |
|
| 308 | - $keyPair = $this->crypt->createKeyPair(); |
|
| 309 | - |
|
| 310 | - // Save public key |
|
| 311 | - $this->keyManager->setPublicKey($userId, $keyPair['publicKey']); |
|
| 312 | - |
|
| 313 | - // Encrypt private key with new password |
|
| 314 | - $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); |
|
| 315 | - |
|
| 316 | - if ($encryptedKey) { |
|
| 317 | - $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); |
|
| 318 | - |
|
| 319 | - if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
|
| 320 | - $this->recovery->recoverUsersFiles($recoveryPassword, $userId); |
|
| 321 | - } |
|
| 322 | - } else { |
|
| 323 | - $this->logger->error('Encryption Could not update users encryption password'); |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * init mount points for given user |
|
| 331 | - * |
|
| 332 | - * @param string $user |
|
| 333 | - * @throws \OC\User\NoUserException |
|
| 334 | - */ |
|
| 335 | - protected function initMountPoints($user) { |
|
| 336 | - Filesystem::initMountPoints($user); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * setup file system for user |
|
| 341 | - * |
|
| 342 | - * @param string $uid user id |
|
| 343 | - */ |
|
| 344 | - protected function setupFS($uid) { |
|
| 345 | - \OC_Util::setupFS($uid); |
|
| 346 | - } |
|
| 47 | + /** |
|
| 48 | + * list of user for which we perform a password reset |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | + protected static $passwordResetUsers = []; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var KeyManager |
|
| 55 | + */ |
|
| 56 | + private $keyManager; |
|
| 57 | + /** |
|
| 58 | + * @var IUserManager |
|
| 59 | + */ |
|
| 60 | + private $userManager; |
|
| 61 | + /** |
|
| 62 | + * @var ILogger |
|
| 63 | + */ |
|
| 64 | + private $logger; |
|
| 65 | + /** |
|
| 66 | + * @var Setup |
|
| 67 | + */ |
|
| 68 | + private $userSetup; |
|
| 69 | + /** |
|
| 70 | + * @var IUserSession |
|
| 71 | + */ |
|
| 72 | + private $userSession; |
|
| 73 | + /** |
|
| 74 | + * @var Util |
|
| 75 | + */ |
|
| 76 | + private $util; |
|
| 77 | + /** |
|
| 78 | + * @var Session |
|
| 79 | + */ |
|
| 80 | + private $session; |
|
| 81 | + /** |
|
| 82 | + * @var Recovery |
|
| 83 | + */ |
|
| 84 | + private $recovery; |
|
| 85 | + /** |
|
| 86 | + * @var Crypt |
|
| 87 | + */ |
|
| 88 | + private $crypt; |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * UserHooks constructor. |
|
| 92 | + * |
|
| 93 | + * @param KeyManager $keyManager |
|
| 94 | + * @param IUserManager $userManager |
|
| 95 | + * @param ILogger $logger |
|
| 96 | + * @param Setup $userSetup |
|
| 97 | + * @param IUserSession $userSession |
|
| 98 | + * @param Util $util |
|
| 99 | + * @param Session $session |
|
| 100 | + * @param Crypt $crypt |
|
| 101 | + * @param Recovery $recovery |
|
| 102 | + */ |
|
| 103 | + public function __construct(KeyManager $keyManager, |
|
| 104 | + IUserManager $userManager, |
|
| 105 | + ILogger $logger, |
|
| 106 | + Setup $userSetup, |
|
| 107 | + IUserSession $userSession, |
|
| 108 | + Util $util, |
|
| 109 | + Session $session, |
|
| 110 | + Crypt $crypt, |
|
| 111 | + Recovery $recovery) { |
|
| 112 | + $this->keyManager = $keyManager; |
|
| 113 | + $this->userManager = $userManager; |
|
| 114 | + $this->logger = $logger; |
|
| 115 | + $this->userSetup = $userSetup; |
|
| 116 | + $this->userSession = $userSession; |
|
| 117 | + $this->util = $util; |
|
| 118 | + $this->session = $session; |
|
| 119 | + $this->recovery = $recovery; |
|
| 120 | + $this->crypt = $crypt; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Connects Hooks |
|
| 125 | + * |
|
| 126 | + * @return null |
|
| 127 | + */ |
|
| 128 | + public function addHooks() { |
|
| 129 | + OCUtil::connectHook('OC_User', 'post_login', $this, 'login'); |
|
| 130 | + OCUtil::connectHook('OC_User', 'logout', $this, 'logout'); |
|
| 131 | + |
|
| 132 | + // this hooks only make sense if no master key is used |
|
| 133 | + if ($this->util->isMasterKeyEnabled() === false) { |
|
| 134 | + OCUtil::connectHook('OC_User', |
|
| 135 | + 'post_setPassword', |
|
| 136 | + $this, |
|
| 137 | + 'setPassphrase'); |
|
| 138 | + |
|
| 139 | + OCUtil::connectHook('OC_User', |
|
| 140 | + 'pre_setPassword', |
|
| 141 | + $this, |
|
| 142 | + 'preSetPassphrase'); |
|
| 143 | + |
|
| 144 | + OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
| 145 | + 'post_passwordReset', |
|
| 146 | + $this, |
|
| 147 | + 'postPasswordReset'); |
|
| 148 | + |
|
| 149 | + OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
| 150 | + 'pre_passwordReset', |
|
| 151 | + $this, |
|
| 152 | + 'prePasswordReset'); |
|
| 153 | + |
|
| 154 | + OCUtil::connectHook('OC_User', |
|
| 155 | + 'post_createUser', |
|
| 156 | + $this, |
|
| 157 | + 'postCreateUser'); |
|
| 158 | + |
|
| 159 | + OCUtil::connectHook('OC_User', |
|
| 160 | + 'post_deleteUser', |
|
| 161 | + $this, |
|
| 162 | + 'postDeleteUser'); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Startup encryption backend upon user login |
|
| 169 | + * |
|
| 170 | + * @note This method should never be called for users using client side encryption |
|
| 171 | + * @param array $params |
|
| 172 | + * @return boolean|null |
|
| 173 | + */ |
|
| 174 | + public function login($params) { |
|
| 175 | + // ensure filesystem is loaded |
|
| 176 | + if (!\OC\Files\Filesystem::$loaded) { |
|
| 177 | + $this->setupFS($params['uid']); |
|
| 178 | + } |
|
| 179 | + if ($this->util->isMasterKeyEnabled() === false) { |
|
| 180 | + $this->userSetup->setupUser($params['uid'], $params['password']); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $this->keyManager->init($params['uid'], $params['password']); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * remove keys from session during logout |
|
| 188 | + */ |
|
| 189 | + public function logout() { |
|
| 190 | + $this->session->clear(); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * setup encryption backend upon user created |
|
| 195 | + * |
|
| 196 | + * @note This method should never be called for users using client side encryption |
|
| 197 | + * @param array $params |
|
| 198 | + */ |
|
| 199 | + public function postCreateUser($params) { |
|
| 200 | + $this->userSetup->setupUser($params['uid'], $params['password']); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * cleanup encryption backend upon user deleted |
|
| 205 | + * |
|
| 206 | + * @param array $params : uid, password |
|
| 207 | + * @note This method should never be called for users using client side encryption |
|
| 208 | + */ |
|
| 209 | + public function postDeleteUser($params) { |
|
| 210 | + $this->keyManager->deletePublicKey($params['uid']); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + public function prePasswordReset($params) { |
|
| 214 | + $user = $params['uid']; |
|
| 215 | + self::$passwordResetUsers[$user] = true; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + public function postPasswordReset($params) { |
|
| 219 | + $uid = $params['uid']; |
|
| 220 | + $password = $params['password']; |
|
| 221 | + $this->keyManager->backupUserKeys('passwordReset', $uid); |
|
| 222 | + $this->keyManager->deleteUserKeys($uid); |
|
| 223 | + $this->userSetup->setupUser($uid, $password); |
|
| 224 | + unset(self::$passwordResetUsers[$uid]); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * If the password can't be changed within Nextcloud, than update the key password in advance. |
|
| 229 | + * |
|
| 230 | + * @param array $params : uid, password |
|
| 231 | + * @return boolean|null |
|
| 232 | + */ |
|
| 233 | + public function preSetPassphrase($params) { |
|
| 234 | + $user = $this->userManager->get($params['uid']); |
|
| 235 | + |
|
| 236 | + if ($user && !$user->canChangePassword()) { |
|
| 237 | + $this->setPassphrase($params); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Change a user's encryption passphrase |
|
| 243 | + * |
|
| 244 | + * @param array $params keys: uid, password |
|
| 245 | + * @return boolean|null |
|
| 246 | + */ |
|
| 247 | + public function setPassphrase($params) { |
|
| 248 | + |
|
| 249 | + // if we are in the process to resetting a user password, we have nothing |
|
| 250 | + // to do here |
|
| 251 | + if (isset(self::$passwordResetUsers[$params['uid']])) { |
|
| 252 | + return true; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // Get existing decrypted private key |
|
| 256 | + $user = $this->userSession->getUser(); |
|
| 257 | + |
|
| 258 | + // current logged in user changes his own password |
|
| 259 | + if ($user && $params['uid'] === $user->getUID()) { |
|
| 260 | + $privateKey = $this->session->getPrivateKey(); |
|
| 261 | + |
|
| 262 | + // Encrypt private key with new user pwd as passphrase |
|
| 263 | + $encryptedPrivateKey = $this->crypt->encryptPrivateKey($privateKey, $params['password'], $params['uid']); |
|
| 264 | + |
|
| 265 | + // Save private key |
|
| 266 | + if ($encryptedPrivateKey) { |
|
| 267 | + $this->keyManager->setPrivateKey($user->getUID(), |
|
| 268 | + $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
| 269 | + } else { |
|
| 270 | + $this->logger->error('Encryption could not update users encryption password'); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + // NOTE: Session does not need to be updated as the |
|
| 274 | + // private key has not changed, only the passphrase |
|
| 275 | + // used to decrypt it has changed |
|
| 276 | + } else { // admin changed the password for a different user, create new keys and re-encrypt file keys |
|
| 277 | + $userId = $params['uid']; |
|
| 278 | + $this->initMountPoints($userId); |
|
| 279 | + $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null; |
|
| 280 | + |
|
| 281 | + $recoveryKeyId = $this->keyManager->getRecoveryKeyId(); |
|
| 282 | + $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId); |
|
| 283 | + try { |
|
| 284 | + $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $recoveryPassword); |
|
| 285 | + } catch (\Exception $e) { |
|
| 286 | + $decryptedRecoveryKey = false; |
|
| 287 | + } |
|
| 288 | + if ($decryptedRecoveryKey === false) { |
|
| 289 | + $message = 'Can not decrypt the recovery key. Maybe you provided the wrong password. Try again.'; |
|
| 290 | + throw new GenericEncryptionException($message, $message); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + // we generate new keys if... |
|
| 294 | + // ...we have a recovery password and the user enabled the recovery key |
|
| 295 | + // ...encryption was activated for the first time (no keys exists) |
|
| 296 | + // ...the user doesn't have any files |
|
| 297 | + if ( |
|
| 298 | + ($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword) |
|
| 299 | + || !$this->keyManager->userHasKeys($userId) |
|
| 300 | + || !$this->util->userHasFiles($userId) |
|
| 301 | + ) { |
|
| 302 | + |
|
| 303 | + // backup old keys |
|
| 304 | + //$this->backupAllKeys('recovery'); |
|
| 305 | + |
|
| 306 | + $newUserPassword = $params['password']; |
|
| 307 | + |
|
| 308 | + $keyPair = $this->crypt->createKeyPair(); |
|
| 309 | + |
|
| 310 | + // Save public key |
|
| 311 | + $this->keyManager->setPublicKey($userId, $keyPair['publicKey']); |
|
| 312 | + |
|
| 313 | + // Encrypt private key with new password |
|
| 314 | + $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); |
|
| 315 | + |
|
| 316 | + if ($encryptedKey) { |
|
| 317 | + $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); |
|
| 318 | + |
|
| 319 | + if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
|
| 320 | + $this->recovery->recoverUsersFiles($recoveryPassword, $userId); |
|
| 321 | + } |
|
| 322 | + } else { |
|
| 323 | + $this->logger->error('Encryption Could not update users encryption password'); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * init mount points for given user |
|
| 331 | + * |
|
| 332 | + * @param string $user |
|
| 333 | + * @throws \OC\User\NoUserException |
|
| 334 | + */ |
|
| 335 | + protected function initMountPoints($user) { |
|
| 336 | + Filesystem::initMountPoints($user); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * setup file system for user |
|
| 341 | + * |
|
| 342 | + * @param string $uid user id |
|
| 343 | + */ |
|
| 344 | + protected function setupFS($uid) { |
|
| 345 | + \OC_Util::setupFS($uid); |
|
| 346 | + } |
|
| 347 | 347 | } |
@@ -32,25 +32,25 @@ |
||
| 32 | 32 | |
| 33 | 33 | class LegacyLoadAdditionalScriptsAdapter implements IEventListener { |
| 34 | 34 | |
| 35 | - /** @var SymfonyAdapter */ |
|
| 36 | - private $dispatcher; |
|
| 37 | - |
|
| 38 | - public function __construct(SymfonyAdapter $dispatcher) { |
|
| 39 | - $this->dispatcher = $dispatcher; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function handle(Event $event): void { |
|
| 43 | - if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - $legacyEvent = new GenericEvent(null, ['hiddenFields' => []]); |
|
| 48 | - $this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent); |
|
| 49 | - |
|
| 50 | - $hiddenFields = $legacyEvent->getArgument('hiddenFields'); |
|
| 51 | - foreach ($hiddenFields as $name => $value) { |
|
| 52 | - $event->addHiddenField($name, $value); |
|
| 53 | - } |
|
| 54 | - } |
|
| 35 | + /** @var SymfonyAdapter */ |
|
| 36 | + private $dispatcher; |
|
| 37 | + |
|
| 38 | + public function __construct(SymfonyAdapter $dispatcher) { |
|
| 39 | + $this->dispatcher = $dispatcher; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function handle(Event $event): void { |
|
| 43 | + if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + $legacyEvent = new GenericEvent(null, ['hiddenFields' => []]); |
|
| 48 | + $this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent); |
|
| 49 | + |
|
| 50 | + $hiddenFields = $legacyEvent->getArgument('hiddenFields'); |
|
| 51 | + foreach ($hiddenFields as $name => $value) { |
|
| 52 | + $event->addHiddenField($name, $value); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | } |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | return []; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return array_map(function (IToken $token) use ($sessionToken) { |
|
| 94 | + return array_map(function(IToken $token) use ($sessionToken) { |
|
| 95 | 95 | $data = $token->jsonSerialize(); |
| 96 | 96 | $data['canDelete'] = true; |
| 97 | 97 | $data['canRename'] = $token instanceof INamedToken; |
@@ -40,79 +40,79 @@ |
||
| 40 | 40 | |
| 41 | 41 | class Authtokens implements ISettings { |
| 42 | 42 | |
| 43 | - /** @var IAuthTokenProvider */ |
|
| 44 | - private $tokenProvider; |
|
| 45 | - |
|
| 46 | - /** @var ISession */ |
|
| 47 | - private $session; |
|
| 48 | - |
|
| 49 | - /** @var IInitialState */ |
|
| 50 | - private $initialState; |
|
| 51 | - |
|
| 52 | - /** @var string|null */ |
|
| 53 | - private $uid; |
|
| 54 | - |
|
| 55 | - /** @var IUserSession */ |
|
| 56 | - private $userSession; |
|
| 57 | - |
|
| 58 | - public function __construct(IAuthTokenProvider $tokenProvider, |
|
| 59 | - ISession $session, |
|
| 60 | - IUserSession $userSession, |
|
| 61 | - IInitialState $initialState, |
|
| 62 | - ?string $UserId) { |
|
| 63 | - $this->tokenProvider = $tokenProvider; |
|
| 64 | - $this->session = $session; |
|
| 65 | - $this->initialState = $initialState; |
|
| 66 | - $this->uid = $UserId; |
|
| 67 | - $this->userSession = $userSession; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function getForm(): TemplateResponse { |
|
| 71 | - $this->initialState->provideInitialState( |
|
| 72 | - 'app_tokens', |
|
| 73 | - $this->getAppTokens() |
|
| 74 | - ); |
|
| 75 | - |
|
| 76 | - $this->initialState->provideInitialState( |
|
| 77 | - 'can_create_app_token', |
|
| 78 | - $this->userSession->getImpersonatingUserID() === null |
|
| 79 | - ); |
|
| 80 | - |
|
| 81 | - return new TemplateResponse('settings', 'settings/personal/security/authtokens'); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function getSection(): string { |
|
| 85 | - return 'security'; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - public function getPriority(): int { |
|
| 89 | - return 100; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - private function getAppTokens(): array { |
|
| 93 | - $tokens = $this->tokenProvider->getTokenByUser($this->uid); |
|
| 94 | - |
|
| 95 | - try { |
|
| 96 | - $sessionId = $this->session->getId(); |
|
| 97 | - } catch (SessionNotAvailableException $ex) { |
|
| 98 | - return []; |
|
| 99 | - } |
|
| 100 | - try { |
|
| 101 | - $sessionToken = $this->tokenProvider->getToken($sessionId); |
|
| 102 | - } catch (InvalidTokenException $ex) { |
|
| 103 | - return []; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return array_map(function (IToken $token) use ($sessionToken) { |
|
| 107 | - $data = $token->jsonSerialize(); |
|
| 108 | - $data['canDelete'] = true; |
|
| 109 | - $data['canRename'] = $token instanceof INamedToken; |
|
| 110 | - if ($sessionToken->getId() === $token->getId()) { |
|
| 111 | - $data['canDelete'] = false; |
|
| 112 | - $data['canRename'] = false; |
|
| 113 | - $data['current'] = true; |
|
| 114 | - } |
|
| 115 | - return $data; |
|
| 116 | - }, $tokens); |
|
| 117 | - } |
|
| 43 | + /** @var IAuthTokenProvider */ |
|
| 44 | + private $tokenProvider; |
|
| 45 | + |
|
| 46 | + /** @var ISession */ |
|
| 47 | + private $session; |
|
| 48 | + |
|
| 49 | + /** @var IInitialState */ |
|
| 50 | + private $initialState; |
|
| 51 | + |
|
| 52 | + /** @var string|null */ |
|
| 53 | + private $uid; |
|
| 54 | + |
|
| 55 | + /** @var IUserSession */ |
|
| 56 | + private $userSession; |
|
| 57 | + |
|
| 58 | + public function __construct(IAuthTokenProvider $tokenProvider, |
|
| 59 | + ISession $session, |
|
| 60 | + IUserSession $userSession, |
|
| 61 | + IInitialState $initialState, |
|
| 62 | + ?string $UserId) { |
|
| 63 | + $this->tokenProvider = $tokenProvider; |
|
| 64 | + $this->session = $session; |
|
| 65 | + $this->initialState = $initialState; |
|
| 66 | + $this->uid = $UserId; |
|
| 67 | + $this->userSession = $userSession; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function getForm(): TemplateResponse { |
|
| 71 | + $this->initialState->provideInitialState( |
|
| 72 | + 'app_tokens', |
|
| 73 | + $this->getAppTokens() |
|
| 74 | + ); |
|
| 75 | + |
|
| 76 | + $this->initialState->provideInitialState( |
|
| 77 | + 'can_create_app_token', |
|
| 78 | + $this->userSession->getImpersonatingUserID() === null |
|
| 79 | + ); |
|
| 80 | + |
|
| 81 | + return new TemplateResponse('settings', 'settings/personal/security/authtokens'); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function getSection(): string { |
|
| 85 | + return 'security'; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + public function getPriority(): int { |
|
| 89 | + return 100; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + private function getAppTokens(): array { |
|
| 93 | + $tokens = $this->tokenProvider->getTokenByUser($this->uid); |
|
| 94 | + |
|
| 95 | + try { |
|
| 96 | + $sessionId = $this->session->getId(); |
|
| 97 | + } catch (SessionNotAvailableException $ex) { |
|
| 98 | + return []; |
|
| 99 | + } |
|
| 100 | + try { |
|
| 101 | + $sessionToken = $this->tokenProvider->getToken($sessionId); |
|
| 102 | + } catch (InvalidTokenException $ex) { |
|
| 103 | + return []; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return array_map(function (IToken $token) use ($sessionToken) { |
|
| 107 | + $data = $token->jsonSerialize(); |
|
| 108 | + $data['canDelete'] = true; |
|
| 109 | + $data['canRename'] = $token instanceof INamedToken; |
|
| 110 | + if ($sessionToken->getId() === $token->getId()) { |
|
| 111 | + $data['canDelete'] = false; |
|
| 112 | + $data['canRename'] = false; |
|
| 113 | + $data['current'] = true; |
|
| 114 | + } |
|
| 115 | + return $data; |
|
| 116 | + }, $tokens); |
|
| 117 | + } |
|
| 118 | 118 | } |
@@ -34,27 +34,27 @@ |
||
| 34 | 34 | |
| 35 | 35 | class TwoFactorSettingsController extends Controller { |
| 36 | 36 | |
| 37 | - /** @var MandatoryTwoFactor */ |
|
| 38 | - private $mandatoryTwoFactor; |
|
| 37 | + /** @var MandatoryTwoFactor */ |
|
| 38 | + private $mandatoryTwoFactor; |
|
| 39 | 39 | |
| 40 | - public function __construct(string $appName, |
|
| 41 | - IRequest $request, |
|
| 42 | - MandatoryTwoFactor $mandatoryTwoFactor) { |
|
| 43 | - parent::__construct($appName, $request); |
|
| 40 | + public function __construct(string $appName, |
|
| 41 | + IRequest $request, |
|
| 42 | + MandatoryTwoFactor $mandatoryTwoFactor) { |
|
| 43 | + parent::__construct($appName, $request); |
|
| 44 | 44 | |
| 45 | - $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
| 46 | - } |
|
| 45 | + $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function index(): JSONResponse { |
|
| 49 | - return new JSONResponse($this->mandatoryTwoFactor->getState()); |
|
| 50 | - } |
|
| 48 | + public function index(): JSONResponse { |
|
| 49 | + return new JSONResponse($this->mandatoryTwoFactor->getState()); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function update(bool $enforced, array $enforcedGroups = [], array $excludedGroups = []): JSONResponse { |
|
| 53 | - $this->mandatoryTwoFactor->setState( |
|
| 54 | - new EnforcementState($enforced, $enforcedGroups, $excludedGroups) |
|
| 55 | - ); |
|
| 52 | + public function update(bool $enforced, array $enforcedGroups = [], array $excludedGroups = []): JSONResponse { |
|
| 53 | + $this->mandatoryTwoFactor->setState( |
|
| 54 | + new EnforcementState($enforced, $enforcedGroups, $excludedGroups) |
|
| 55 | + ); |
|
| 56 | 56 | |
| 57 | - return new JSONResponse($this->mandatoryTwoFactor->getState()); |
|
| 58 | - } |
|
| 57 | + return new JSONResponse($this->mandatoryTwoFactor->getState()); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | } |
@@ -26,71 +26,71 @@ |
||
| 26 | 26 | |
| 27 | 27 | class Setting implements ISetting { |
| 28 | 28 | |
| 29 | - /** @var IL10N */ |
|
| 30 | - protected $l; |
|
| 29 | + /** @var IL10N */ |
|
| 30 | + protected $l; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param IL10N $l10n |
|
| 34 | - */ |
|
| 35 | - public function __construct(IL10N $l10n) { |
|
| 36 | - $this->l = $l10n; |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * @param IL10N $l10n |
|
| 34 | + */ |
|
| 35 | + public function __construct(IL10N $l10n) { |
|
| 36 | + $this->l = $l10n; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return string Lowercase a-z and underscore only identifier |
|
| 41 | - * @since 11.0.0 |
|
| 42 | - */ |
|
| 43 | - public function getIdentifier() { |
|
| 44 | - return 'personal_settings'; |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * @return string Lowercase a-z and underscore only identifier |
|
| 41 | + * @since 11.0.0 |
|
| 42 | + */ |
|
| 43 | + public function getIdentifier() { |
|
| 44 | + return 'personal_settings'; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @return string A translated string |
|
| 49 | - * @since 11.0.0 |
|
| 50 | - */ |
|
| 51 | - public function getName() { |
|
| 52 | - return $this->l->t('Your <strong>password</strong> or <strong>email</strong> was modified'); |
|
| 53 | - } |
|
| 47 | + /** |
|
| 48 | + * @return string A translated string |
|
| 49 | + * @since 11.0.0 |
|
| 50 | + */ |
|
| 51 | + public function getName() { |
|
| 52 | + return $this->l->t('Your <strong>password</strong> or <strong>email</strong> was modified'); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @return int whether the filter should be rather on the top or bottom of |
|
| 57 | - * the admin section. The filters are arranged in ascending order of the |
|
| 58 | - * priority values. It is required to return a value between 0 and 100. |
|
| 59 | - * @since 11.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getPriority() { |
|
| 62 | - return 0; |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * @return int whether the filter should be rather on the top or bottom of |
|
| 57 | + * the admin section. The filters are arranged in ascending order of the |
|
| 58 | + * priority values. It is required to return a value between 0 and 100. |
|
| 59 | + * @since 11.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getPriority() { |
|
| 62 | + return 0; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @return bool True when the option can be changed for the stream |
|
| 67 | - * @since 11.0.0 |
|
| 68 | - */ |
|
| 69 | - public function canChangeStream() { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 65 | + /** |
|
| 66 | + * @return bool True when the option can be changed for the stream |
|
| 67 | + * @since 11.0.0 |
|
| 68 | + */ |
|
| 69 | + public function canChangeStream() { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @return bool True when the option can be changed for the stream |
|
| 75 | - * @since 11.0.0 |
|
| 76 | - */ |
|
| 77 | - public function isDefaultEnabledStream() { |
|
| 78 | - return true; |
|
| 79 | - } |
|
| 73 | + /** |
|
| 74 | + * @return bool True when the option can be changed for the stream |
|
| 75 | + * @since 11.0.0 |
|
| 76 | + */ |
|
| 77 | + public function isDefaultEnabledStream() { |
|
| 78 | + return true; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return bool True when the option can be changed for the mail |
|
| 83 | - * @since 11.0.0 |
|
| 84 | - */ |
|
| 85 | - public function canChangeMail() { |
|
| 86 | - return false; |
|
| 87 | - } |
|
| 81 | + /** |
|
| 82 | + * @return bool True when the option can be changed for the mail |
|
| 83 | + * @since 11.0.0 |
|
| 84 | + */ |
|
| 85 | + public function canChangeMail() { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @return bool True when the option can be changed for the stream |
|
| 91 | - * @since 11.0.0 |
|
| 92 | - */ |
|
| 93 | - public function isDefaultEnabledMail() { |
|
| 94 | - return false; |
|
| 95 | - } |
|
| 89 | + /** |
|
| 90 | + * @return bool True when the option can be changed for the stream |
|
| 91 | + * @since 11.0.0 |
|
| 92 | + */ |
|
| 93 | + public function isDefaultEnabledMail() { |
|
| 94 | + return false; |
|
| 95 | + } |
|
| 96 | 96 | } |
@@ -28,39 +28,39 @@ |
||
| 28 | 28 | |
| 29 | 29 | class SecurityFilter implements IFilter { |
| 30 | 30 | |
| 31 | - /** @var IURLGenerator */ |
|
| 32 | - private $urlGenerator; |
|
| 31 | + /** @var IURLGenerator */ |
|
| 32 | + private $urlGenerator; |
|
| 33 | 33 | |
| 34 | - /** @var IL10N */ |
|
| 35 | - private $l10n; |
|
| 34 | + /** @var IL10N */ |
|
| 35 | + private $l10n; |
|
| 36 | 36 | |
| 37 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { |
|
| 38 | - $this->urlGenerator = $urlGenerator; |
|
| 39 | - $this->l10n = $l10n; |
|
| 40 | - } |
|
| 37 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) { |
|
| 38 | + $this->urlGenerator = $urlGenerator; |
|
| 39 | + $this->l10n = $l10n; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function allowedApps() { |
|
| 43 | - return []; |
|
| 44 | - } |
|
| 42 | + public function allowedApps() { |
|
| 43 | + return []; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function filterTypes(array $types) { |
|
| 47 | - return array_intersect(['security'], $types); |
|
| 48 | - } |
|
| 46 | + public function filterTypes(array $types) { |
|
| 47 | + return array_intersect(['security'], $types); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function getIcon() { |
|
| 51 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')); |
|
| 52 | - } |
|
| 50 | + public function getIcon() { |
|
| 51 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getIdentifier() { |
|
| 55 | - return 'security'; |
|
| 56 | - } |
|
| 54 | + public function getIdentifier() { |
|
| 55 | + return 'security'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function getName() { |
|
| 59 | - return $this->l10n->t('Security'); |
|
| 60 | - } |
|
| 58 | + public function getName() { |
|
| 59 | + return $this->l10n->t('Security'); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function getPriority() { |
|
| 63 | - return 30; |
|
| 64 | - } |
|
| 62 | + public function getPriority() { |
|
| 63 | + return 30; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
@@ -27,39 +27,39 @@ |
||
| 27 | 27 | |
| 28 | 28 | class SecuritySetting implements ISetting { |
| 29 | 29 | |
| 30 | - /** @var IL10N */ |
|
| 31 | - private $l10n; |
|
| 30 | + /** @var IL10N */ |
|
| 31 | + private $l10n; |
|
| 32 | 32 | |
| 33 | - public function __construct(IL10N $l10n) { |
|
| 34 | - $this->l10n = $l10n; |
|
| 35 | - } |
|
| 33 | + public function __construct(IL10N $l10n) { |
|
| 34 | + $this->l10n = $l10n; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function canChangeMail() { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 37 | + public function canChangeMail() { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function canChangeStream() { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 41 | + public function canChangeStream() { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function getIdentifier() { |
|
| 46 | - return 'security'; |
|
| 47 | - } |
|
| 45 | + public function getIdentifier() { |
|
| 46 | + return 'security'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function getName() { |
|
| 50 | - return $this->l10n->t('Security'); |
|
| 51 | - } |
|
| 49 | + public function getName() { |
|
| 50 | + return $this->l10n->t('Security'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function getPriority() { |
|
| 54 | - return 30; |
|
| 55 | - } |
|
| 53 | + public function getPriority() { |
|
| 54 | + return 30; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function isDefaultEnabledMail() { |
|
| 58 | - return true; |
|
| 59 | - } |
|
| 57 | + public function isDefaultEnabledMail() { |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function isDefaultEnabledStream() { |
|
| 62 | - return true; |
|
| 63 | - } |
|
| 61 | + public function isDefaultEnabledStream() { |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\Settings\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\Settings\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |