Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/private/Security/Hasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
*
* Usage:
* // Hashing a message
* $hash = \OC::$server->getHasher()->hash('MessageToHash');
* $hash = \OC::$server->get(\OCP\Security\IHasher::class)->hash('MessageToHash');
* // Verifying a message - $newHash will contain the newly calculated hash
* $newHash = null;
* var_dump(\OC::$server->getHasher()->verify('a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', $newHash));
* var_dump(\OC::$server->get(\OCP\Security\IHasher::class)->verify('a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', $newHash));
* var_dump($newHash);
*
* @package OC\Security
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Share20/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\Security\IHasher;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
Expand Down Expand Up @@ -199,7 +200,7 @@ protected function getShareByMailProvider() {
$this->serverContainer->getActivityManager(),
$settingsManager,
$this->serverContainer->query(Defaults::class),
$this->serverContainer->getHasher(),
$this->serverContainer->get(IHasher::class),
$this->serverContainer->get(IEventDispatcher::class),
$this->serverContainer->get(IManager::class)
);
Expand Down
7 changes: 4 additions & 3 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\Security\Events\ValidatePasswordPolicyEvent;
use OCP\Security\IHasher;
use OCP\User\Backend\ABackend;
use OCP\User\Backend\ICheckPasswordBackend;
use OCP\User\Backend\ICountUsersBackend;
Expand Down Expand Up @@ -130,7 +131,7 @@ public function createUser(string $uid, string $password): bool {
$qb->insert($this->table)
->values([
'uid' => $qb->createNamedParameter($uid),
'password' => $qb->createNamedParameter(\OC::$server->getHasher()->hash($password)),
'password' => $qb->createNamedParameter(\OC::$server->get(IHasher::class)->hash($password)),
'uid_lower' => $qb->createNamedParameter(mb_strtolower($uid)),
]);

Expand Down Expand Up @@ -197,7 +198,7 @@ public function setPassword(string $uid, string $password): bool {
if ($this->userExists($uid)) {
$this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));

$hasher = \OC::$server->getHasher();
$hasher = \OC::$server->get(IHasher::class);
$hashedPassword = $hasher->hash($password);

$return = $this->updatePassword($uid, $hashedPassword);
Expand Down Expand Up @@ -353,7 +354,7 @@ public function checkPassword(string $loginName, string $password) {
if ($found && is_array($this->cache[$loginName])) {
$storedHash = $this->cache[$loginName]['password'];
$newHash = '';
if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
if (\OC::$server->get(IHasher::class)->verify($password, $storedHash, $newHash)) {
if (!empty($newHash)) {
$this->updatePassword($loginName, $newHash);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Security/IHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
*
* Usage:
* // Hashing a message
* $hash = \OC::$server->getHasher()->hash('MessageToHash');
* $hash = \OC::$server->get(\OCP\Security\IHasher::class)->hash('MessageToHash');
* // Verifying a message - $newHash will contain the newly calculated hash
* $newHash = null;
* var_dump(\OC::$server->getHasher()->verify('a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', $newHash));
* var_dump(\OC::$server->get(\OCP\Security\IHasher::class)->verify('a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', $newHash));
* var_dump($newHash);
*
* @since 8.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function setUp(): void {
parent::setUp();

$this->mapper = $this->createMock(PublicKeyTokenMapper::class);
$this->hasher = \OC::$server->getHasher();
$this->hasher = \OC::$server->get(IHasher::class);
$this->crypto = \OC::$server->getCrypto();
$this->config = $this->createMock(IConfig::class);
$this->config->method('getSystemValueInt')
Expand Down