DecryptedFolderMetadata.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Tobias Kaminsky
  5. * Copyright (C) 2017 Tobias Kaminsky
  6. * Copyright (C) 2017 Nextcloud GmbH.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. package com.owncloud.android.datamodel;
  22. import java.util.HashMap;
  23. /**
  24. * Decrypted class representation of metadata json of folder metadata
  25. */
  26. public class DecryptedFolderMetadata {
  27. private Metadata metadata;
  28. private HashMap<String, DecryptedFile> files;
  29. public DecryptedFolderMetadata() {
  30. this.metadata = new Metadata();
  31. this.files = new HashMap<>();
  32. }
  33. public DecryptedFolderMetadata(Metadata metadata, HashMap<String, DecryptedFile> files) {
  34. this.metadata = metadata;
  35. this.files = files;
  36. }
  37. public Metadata getMetadata() {
  38. return metadata;
  39. }
  40. public void setMetadata(Metadata metadata) {
  41. this.metadata = metadata;
  42. }
  43. public HashMap<String, DecryptedFile> getFiles() {
  44. return files;
  45. }
  46. public void setFiles(HashMap<String, DecryptedFile> files) {
  47. this.files = files;
  48. }
  49. public static class Metadata {
  50. private HashMap<Integer, String> metadataKeys; // each keys is encrypted on its own, decrypt on use
  51. private Sharing sharing;
  52. private int version;
  53. public HashMap<Integer, String> getMetadataKeys() {
  54. return metadataKeys;
  55. }
  56. public void setMetadataKeys(HashMap<Integer, String> metadataKeys) {
  57. this.metadataKeys = metadataKeys;
  58. }
  59. public Sharing getSharing() {
  60. return sharing;
  61. }
  62. public void setSharing(Sharing sharing) {
  63. this.sharing = sharing;
  64. }
  65. public int getVersion() {
  66. return version;
  67. }
  68. public void setVersion(int version) {
  69. this.version = version;
  70. }
  71. @Override
  72. public String toString() {
  73. return String.valueOf(version);
  74. }
  75. }
  76. public static class Encrypted {
  77. private HashMap<Integer, String> metadataKeys;
  78. public HashMap<Integer, String> getMetadataKeys() {
  79. return metadataKeys;
  80. }
  81. public void setMetadataKeys(HashMap<Integer, String> metadataKeys) {
  82. this.metadataKeys = metadataKeys;
  83. }
  84. }
  85. public static class Sharing {
  86. private HashMap<String, String> recipient;
  87. private String signature;
  88. public HashMap<String, String> getRecipient() {
  89. return recipient;
  90. }
  91. public void setRecipient(HashMap<String, String> recipient) {
  92. this.recipient = recipient;
  93. }
  94. public String getSignature() {
  95. return signature;
  96. }
  97. public void setSignature(String signature) {
  98. this.signature = signature;
  99. }
  100. }
  101. public static class DecryptedFile {
  102. private Data encrypted;
  103. private String initializationVector;
  104. private String authenticationTag;
  105. private int metadataKey;
  106. public Data getEncrypted() {
  107. return encrypted;
  108. }
  109. public void setEncrypted(Data encrypted) {
  110. this.encrypted = encrypted;
  111. }
  112. public String getInitializationVector() {
  113. return initializationVector;
  114. }
  115. public void setInitializationVector(String initializationVector) {
  116. this.initializationVector = initializationVector;
  117. }
  118. public String getAuthenticationTag() {
  119. return authenticationTag;
  120. }
  121. public void setAuthenticationTag(String authenticationTag) {
  122. this.authenticationTag = authenticationTag;
  123. }
  124. public int getMetadataKey() {
  125. return metadataKey;
  126. }
  127. public void setMetadataKey(int metadataKey) {
  128. this.metadataKey = metadataKey;
  129. }
  130. }
  131. public static class Data {
  132. private String key;
  133. private String filename;
  134. private String mimetype;
  135. private int version;
  136. public String getKey() {
  137. return key;
  138. }
  139. public void setKey(String key) {
  140. this.key = key;
  141. }
  142. public String getFilename() {
  143. return filename;
  144. }
  145. public void setFilename(String filename) {
  146. this.filename = filename;
  147. }
  148. public String getMimetype() {
  149. return mimetype;
  150. }
  151. public void setMimetype(String mimetype) {
  152. this.mimetype = mimetype;
  153. }
  154. public int getVersion() {
  155. return version;
  156. }
  157. public void setVersion(int version) {
  158. this.version = version;
  159. }
  160. }
  161. }