You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.6 KiB

9 years ago
9 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCP\Encryption\Keys;
  26. /**
  27. * Interface IStorage
  28. *
  29. * @package OCP\Encryption\Keys
  30. * @since 8.1.0
  31. */
  32. interface IStorage {
  33. /**
  34. * get user specific key
  35. *
  36. * @param string $uid ID if the user for whom we want the key
  37. * @param string $keyId id of the key
  38. * @param string $encryptionModuleId
  39. *
  40. * @return mixed key
  41. * @since 8.1.0
  42. */
  43. public function getUserKey($uid, $keyId, $encryptionModuleId);
  44. /**
  45. * get file specific key
  46. *
  47. * @param string $path path to file
  48. * @param string $keyId id of the key
  49. * @param string $encryptionModuleId
  50. *
  51. * @return mixed key
  52. * @since 8.1.0
  53. */
  54. public function getFileKey($path, $keyId, $encryptionModuleId);
  55. /**
  56. * get system-wide encryption keys not related to a specific user,
  57. * e.g something like a key for public link shares
  58. *
  59. * @param string $keyId id of the key
  60. * @param string $encryptionModuleId
  61. *
  62. * @return mixed key
  63. * @since 8.1.0
  64. */
  65. public function getSystemUserKey($keyId, $encryptionModuleId);
  66. /**
  67. * set user specific key
  68. *
  69. * @param string $uid ID if the user for whom we want the key
  70. * @param string $keyId id of the key
  71. * @param mixed $key
  72. * @param string $encryptionModuleId
  73. * @since 8.1.0
  74. */
  75. public function setUserKey($uid, $keyId, $key, $encryptionModuleId);
  76. /**
  77. * set file specific key
  78. *
  79. * @param string $path path to file
  80. * @param string $keyId id of the key
  81. * @param mixed $key
  82. * @param string $encryptionModuleId
  83. * @since 8.1.0
  84. */
  85. public function setFileKey($path, $keyId, $key, $encryptionModuleId);
  86. /**
  87. * set system-wide encryption keys not related to a specific user,
  88. * e.g something like a key for public link shares
  89. *
  90. * @param string $keyId id of the key
  91. * @param mixed $key
  92. * @param string $encryptionModuleId
  93. *
  94. * @return mixed key
  95. * @since 8.1.0
  96. */
  97. public function setSystemUserKey($keyId, $key, $encryptionModuleId);
  98. /**
  99. * delete user specific key
  100. *
  101. * @param string $uid ID if the user for whom we want to delete the key
  102. * @param string $keyId id of the key
  103. * @param string $encryptionModuleId
  104. *
  105. * @return boolean False when the key could not be deleted
  106. * @since 8.1.0
  107. */
  108. public function deleteUserKey($uid, $keyId, $encryptionModuleId);
  109. /**
  110. * delete file specific key
  111. *
  112. * @param string $path path to file
  113. * @param string $keyId id of the key
  114. * @param string $encryptionModuleId
  115. *
  116. * @return boolean False when the key could not be deleted
  117. * @since 8.1.0
  118. */
  119. public function deleteFileKey($path, $keyId, $encryptionModuleId);
  120. /**
  121. * delete all file keys for a given file
  122. *
  123. * @param string $path to the file
  124. *
  125. * @return boolean False when the keys could not be deleted
  126. * @since 8.1.0
  127. */
  128. public function deleteAllFileKeys($path);
  129. /**
  130. * delete system-wide encryption keys not related to a specific user,
  131. * e.g something like a key for public link shares
  132. *
  133. * @param string $keyId id of the key
  134. * @param string $encryptionModuleId
  135. *
  136. * @return boolean False when the key could not be deleted
  137. * @since 8.1.0
  138. */
  139. public function deleteSystemUserKey($keyId, $encryptionModuleId);
  140. /**
  141. * copy keys if a file was renamed
  142. *
  143. * @param string $source
  144. * @param string $target
  145. * @return boolean
  146. * @since 8.1.0
  147. */
  148. public function renameKeys($source, $target);
  149. /**
  150. * move keys if a file was renamed
  151. *
  152. * @param string $source
  153. * @param string $target
  154. * @return boolean
  155. * @since 8.1.0
  156. */
  157. public function copyKeys($source, $target);
  158. /**
  159. * backup keys of a given encryption module
  160. *
  161. * @param string $encryptionModuleId
  162. * @param string $purpose
  163. * @param string $uid
  164. * @return bool
  165. * @since 12.0.0
  166. */
  167. public function backupUserKeys($encryptionModuleId, $purpose, $uid);
  168. }