nextcloud/apps/encryption/lib/users/setup.php

64 lines
1.3 KiB
PHP
Raw Normal View History

2015-02-24 21:05:19 +03:00
<?php
/**
* @author Clark Tomlinson <fallen013@gmail.com>
* @since 3/6/15, 11:36 AM
* @link http:/www.clarkt.com
* @copyright Clark Tomlinson © 2015
*
*/
namespace OCA\Encryption\Users;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCP\ILogger;
use OCP\IUserSession;
class Setup extends \OCA\Encryption\Setup {
/**
* @var Crypt
*/
private $crypt;
/**
* @var KeyManager
*/
private $keyManager;
/**
* @param ILogger $logger
* @param IUserSession $userSession
* @param Crypt $crypt
* @param KeyManager $keyManager
*/
public function __construct(ILogger $logger, IUserSession $userSession, Crypt $crypt, KeyManager $keyManager) {
parent::__construct($logger, $userSession);
$this->crypt = $crypt;
$this->keyManager = $keyManager;
}
2015-02-24 21:05:19 +03:00
/**
* @param $uid userid
* @param $password user password
2015-02-24 21:05:19 +03:00
* @return bool
*/
public function setupUser($uid, $password) {
return $this->setupServerSide($uid, $password);
2015-02-24 21:05:19 +03:00
}
/**
* @param $uid userid
* @param $password user password
2015-02-24 21:05:19 +03:00
* @return bool
*/
public function setupServerSide($uid, $password) {
2015-02-24 21:05:19 +03:00
// Check if user already has keys
if (!$this->keyManager->userHasKeys($uid)) {
return $this->keyManager->storeKeyPair($uid, $password,
$this->crypt->createKeyPair());
2015-02-24 21:05:19 +03:00
}
return true;
}
}