-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up KeyStorage into KeyStorage and MetaDataStorage
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
- Loading branch information
1 parent
fa84404
commit 58a69e4
Showing
10 changed files
with
1,718 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2020 Georg Ehrke <georg-nextcloud@ehrke.email> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\EndToEndEncryption; | ||
|
||
use OCA\EndToEndEncryption\Exceptions\KeyExistsException; | ||
use OCP\Files\ForbiddenException; | ||
use OCP\Files\NotFoundException; | ||
use OCP\Files\NotPermittedException; | ||
use OCP\IUser; | ||
|
||
/** | ||
* Interface IKeyStorage | ||
* | ||
* @package OCA\EndToEndEncryption | ||
*/ | ||
interface IKeyStorage { | ||
|
||
/** | ||
* Get users public key | ||
* | ||
* @param string $uid | ||
* @return string | ||
* | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
*/ | ||
public function getPublicKey(string $uid): string; | ||
|
||
/** | ||
* Check if a public key exists | ||
* | ||
* @param string $uid | ||
* @return bool | ||
* | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
*/ | ||
public function publicKeyExists(string $uid): bool; | ||
|
||
/** | ||
* store public key | ||
* | ||
* @param string $publicKey | ||
* @param string $uid | ||
* | ||
* @throws KeyExistsException | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
*/ | ||
public function setPublicKey(string $publicKey, string $uid): void; | ||
|
||
/** | ||
* delete the users public key | ||
* | ||
* @param string $uid | ||
* | ||
* @throws NotPermittedException | ||
* @throws NotFoundException | ||
*/ | ||
public function deletePublicKey(string $uid): void; | ||
|
||
/** | ||
* get users private key | ||
* | ||
* @param string $uid | ||
* @return string | ||
* | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
* @throws ForbiddenException | ||
*/ | ||
public function getPrivateKey(string $uid): string; | ||
|
||
/** | ||
* check if a private key exists | ||
* | ||
* @param string $uid | ||
* @return bool | ||
* | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
* @throws ForbiddenException | ||
*/ | ||
public function privateKeyExists(string $uid): bool; | ||
|
||
/** | ||
* store private key | ||
* | ||
* @param string $privateKey | ||
* @param string $uid | ||
* | ||
* @throws KeyExistsException | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
* @throws ForbiddenException | ||
*/ | ||
public function setPrivateKey(string $privateKey, string $uid): void; | ||
|
||
/** | ||
* get users private key | ||
* | ||
* @param string $uid | ||
* | ||
* @throws NotPermittedException | ||
* @throws NotFoundException | ||
*/ | ||
public function deletePrivateKey(string $uid): void; | ||
|
||
/** | ||
* delete all user private and public key permanently | ||
* | ||
* @param IUser $user | ||
* | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
*/ | ||
public function deleteUserKeys(IUser $user): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2020 Georg Ehrke <georg-nextcloud@ehrke.email> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\EndToEndEncryption; | ||
|
||
use OCA\EndToEndEncryption\Exceptions\MetaDataExistsException; | ||
use OCA\EndToEndEncryption\Exceptions\MissingMetaDataException; | ||
use OCP\Files\NotFoundException; | ||
use OCP\Files\NotPermittedException; | ||
|
||
/** | ||
* Interface IMetaDataStorage | ||
* | ||
* @package OCA\EndToEndEncryption | ||
*/ | ||
interface IMetaDataStorage { | ||
|
||
/** | ||
* get meta data file | ||
* | ||
* @param int $id | ||
* @return string | ||
* | ||
* @throws NotPermittedException | ||
* @throws NotFoundException | ||
*/ | ||
public function getMetaData(int $id): string; | ||
|
||
/** | ||
* set meta data file | ||
* | ||
* @param int $id file id | ||
* @param string $metaData | ||
* | ||
* @throws NotPermittedException | ||
* @throws NotFoundException | ||
* @throws MetaDataExistsException | ||
*/ | ||
public function setMetaData(int $id, string $metaData): void; | ||
|
||
/** | ||
* update meta data file | ||
* | ||
* @param int $id file id | ||
* @param string $fileKey | ||
* | ||
* @throws NotPermittedException | ||
* @throws NotFoundException | ||
* @throws MissingMetaDataException | ||
*/ | ||
public function updateMetaData(int $id, string $fileKey): void; | ||
|
||
/** | ||
* delete meta data file | ||
* | ||
* @param int $id | ||
* | ||
* @throws NotPermittedException | ||
* @throws NotFoundException | ||
*/ | ||
public function deleteMetaData(int $id): void; | ||
} |
Oops, something went wrong.