1
0

IStorage.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. * @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. }