2016-09-11 18:33:09 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Nextcloud - passman
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later. See the COPYING file.
|
|
|
|
*
|
|
|
|
* @author Sander Brand <brantje@gmail.com>
|
|
|
|
* @copyright Sander Brand 2016
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Passman\Service;
|
|
|
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\AppFramework\Db\DoesNotExistException;
|
|
|
|
|
|
|
|
use OCA\Passman\Db\VaultMapper;
|
|
|
|
|
|
|
|
|
|
|
|
class VaultService {
|
|
|
|
|
|
|
|
private $vaultMapper;
|
|
|
|
|
|
|
|
public function __construct(VaultMapper $vaultMapper) {
|
|
|
|
$this->vaultMapper = $vaultMapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getByUser($userId) {
|
|
|
|
return $this->vaultMapper->findVaultsFromUser($userId);
|
|
|
|
}
|
|
|
|
|
2016-09-29 02:29:50 +08:00
|
|
|
public function getById($vault_id, $user_id) {
|
|
|
|
$vault = $this->vaultMapper->find($vault_id, $user_id);
|
2016-09-29 04:05:09 +08:00
|
|
|
return $vault;
|
2016-09-29 02:29:50 +08:00
|
|
|
}
|
|
|
|
|
2016-10-07 18:58:41 +08:00
|
|
|
public function getByGuid($vault_guid, $user_id) {
|
|
|
|
$vault = $this->vaultMapper->findByGuid($vault_guid, $user_id);
|
|
|
|
return $vault;
|
|
|
|
}
|
|
|
|
|
2016-09-11 18:33:09 +08:00
|
|
|
public function createVault($vault_name, $userId) {
|
|
|
|
return $this->vaultMapper->create($vault_name, $userId);
|
|
|
|
}
|
2016-09-13 00:25:16 +08:00
|
|
|
|
2016-09-29 04:05:09 +08:00
|
|
|
public function updateVault($vault) {
|
|
|
|
return $this->vaultMapper->updateVault($vault);
|
|
|
|
}
|
|
|
|
|
2016-09-29 02:29:50 +08:00
|
|
|
public function setLastAccess($vault_id, $user_id){
|
|
|
|
return $this->vaultMapper->setLastAccess($vault_id, $user_id);
|
2016-09-13 00:25:16 +08:00
|
|
|
}
|
2016-09-26 00:34:33 +08:00
|
|
|
|
|
|
|
public function updateSharingKeys($vault_id, $privateKey, $publicKey){
|
|
|
|
return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey);
|
|
|
|
}
|
2016-09-11 18:33:09 +08:00
|
|
|
}
|