1
0

IStorage.php 4.6 KB

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