DecryptedFolderMetadataOld.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Nextcloud - Android Client
  3. *
  4. * SPDX-FileCopyrightText: 2017 Tobias Kaminsky <tobias@kaminsky.me>
  5. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH
  6. * SPDX-License-Identifier: AGPL-3.0-or-later
  7. */
  8. package com.owncloud.android.datamodel;
  9. import java.util.HashMap;
  10. import java.util.Map;
  11. import androidx.annotation.VisibleForTesting;
  12. /**
  13. * Decrypted class representation of metadata json of folder metadata.
  14. */
  15. public class DecryptedFolderMetadataOld {
  16. private Metadata metadata;
  17. private Map<String, DecryptedFile> files;
  18. private Map<String, DecryptedFile> filedrop;
  19. public DecryptedFolderMetadataOld() {
  20. this.metadata = new Metadata();
  21. this.files = new HashMap<>();
  22. }
  23. public DecryptedFolderMetadataOld(Metadata metadata, Map<String, DecryptedFile> files) {
  24. this.metadata = metadata;
  25. this.files = files;
  26. }
  27. public Metadata getMetadata() {
  28. return this.metadata;
  29. }
  30. public Map<String, DecryptedFile> getFiles() {
  31. return this.files;
  32. }
  33. public void setMetadata(Metadata metadata) {
  34. this.metadata = metadata;
  35. }
  36. public void setFiles(Map<String, DecryptedFile> files) {
  37. this.files = files;
  38. }
  39. @VisibleForTesting
  40. public void setFiledrop(Map<String, DecryptedFile> filedrop) {
  41. this.filedrop = filedrop;
  42. }
  43. public Map<String, DecryptedFile> getFiledrop() {
  44. return filedrop;
  45. }
  46. public static class Metadata {
  47. transient
  48. private Map<Integer, String> metadataKeys; // outdated with v1.1
  49. private String metadataKey;
  50. private String checksum;
  51. private double version = 1.2;
  52. @Override
  53. public String toString() {
  54. return String.valueOf(version);
  55. }
  56. public Map<Integer, String> getMetadataKeys() {
  57. return this.metadataKeys;
  58. }
  59. public double getVersion() {
  60. return this.version;
  61. }
  62. public void setMetadataKeys(Map<Integer, String> metadataKeys) {
  63. this.metadataKeys = metadataKeys;
  64. }
  65. public void setVersion(double version) {
  66. this.version = version;
  67. }
  68. public String getMetadataKey() {
  69. if (metadataKey == null) {
  70. // fallback to old keys array
  71. return metadataKeys.get(0);
  72. }
  73. return metadataKey;
  74. }
  75. public void setMetadataKey(String metadataKey) {
  76. this.metadataKey = metadataKey;
  77. }
  78. public String getChecksum() {
  79. return checksum;
  80. }
  81. public void setChecksum(String checksum) {
  82. this.checksum = checksum;
  83. }
  84. }
  85. public static class Encrypted {
  86. private Map<Integer, String> metadataKeys;
  87. public Map<Integer, String> getMetadataKeys() {
  88. return this.metadataKeys;
  89. }
  90. public void setMetadataKeys(Map<Integer, String> metadataKeys) {
  91. this.metadataKeys = metadataKeys;
  92. }
  93. }
  94. public static class DecryptedFile {
  95. private Data encrypted;
  96. private String initializationVector;
  97. private String authenticationTag;
  98. transient private int metadataKey;
  99. public Data getEncrypted() {
  100. return this.encrypted;
  101. }
  102. public String getInitializationVector() {
  103. return this.initializationVector;
  104. }
  105. public String getAuthenticationTag() {
  106. return this.authenticationTag;
  107. }
  108. public int getMetadataKey() {
  109. return this.metadataKey;
  110. }
  111. public void setEncrypted(Data encrypted) {
  112. this.encrypted = encrypted;
  113. }
  114. public void setInitializationVector(String initializationVector) {
  115. this.initializationVector = initializationVector;
  116. }
  117. public void setAuthenticationTag(String authenticationTag) {
  118. this.authenticationTag = authenticationTag;
  119. }
  120. public void setMetadataKey(int metadataKey) {
  121. this.metadataKey = metadataKey;
  122. }
  123. }
  124. public static class Data {
  125. private String key;
  126. private String filename;
  127. private String mimetype;
  128. transient private double version;
  129. public String getKey() {
  130. return this.key;
  131. }
  132. public String getFilename() {
  133. return this.filename;
  134. }
  135. public String getMimetype() {
  136. return this.mimetype;
  137. }
  138. public double getVersion() {
  139. return this.version;
  140. }
  141. public void setKey(String key) {
  142. this.key = key;
  143. }
  144. public void setFilename(String filename) {
  145. this.filename = filename;
  146. }
  147. public void setMimetype(String mimetype) {
  148. this.mimetype = mimetype;
  149. }
  150. public void setVersion(int version) {
  151. this.version = version;
  152. }
  153. }
  154. }