123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- /*
- * Nextcloud - Android Client
- *
- * SPDX-FileCopyrightText: 2017 Tobias Kaminsky <tobias@kaminsky.me>
- * SPDX-FileCopyrightText: 2017 Nextcloud GmbH
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
- package com.owncloud.android.datamodel;
- import java.util.HashMap;
- import java.util.Map;
- import androidx.annotation.VisibleForTesting;
- /**
- * Decrypted class representation of metadata json of folder metadata.
- */
- public class DecryptedFolderMetadataOld {
- private Metadata metadata;
- private Map<String, DecryptedFile> files;
- private Map<String, DecryptedFile> filedrop;
- public DecryptedFolderMetadataOld() {
- this.metadata = new Metadata();
- this.files = new HashMap<>();
- }
- public DecryptedFolderMetadataOld(Metadata metadata, Map<String, DecryptedFile> files) {
- this.metadata = metadata;
- this.files = files;
- }
- public Metadata getMetadata() {
- return this.metadata;
- }
- public Map<String, DecryptedFile> getFiles() {
- return this.files;
- }
- public void setMetadata(Metadata metadata) {
- this.metadata = metadata;
- }
- public void setFiles(Map<String, DecryptedFile> files) {
- this.files = files;
- }
- @VisibleForTesting
- public void setFiledrop(Map<String, DecryptedFile> filedrop) {
- this.filedrop = filedrop;
- }
- public Map<String, DecryptedFile> getFiledrop() {
- return filedrop;
- }
- public static class Metadata {
- transient
- private Map<Integer, String> metadataKeys; // outdated with v1.1
- private String metadataKey;
- private String checksum;
- private double version = 1.2;
- @Override
- public String toString() {
- return String.valueOf(version);
- }
- public Map<Integer, String> getMetadataKeys() {
- return this.metadataKeys;
- }
- public double getVersion() {
- return this.version;
- }
- public void setMetadataKeys(Map<Integer, String> metadataKeys) {
- this.metadataKeys = metadataKeys;
- }
- public void setVersion(double version) {
- this.version = version;
- }
- public String getMetadataKey() {
- if (metadataKey == null) {
- // fallback to old keys array
- return metadataKeys.get(0);
- }
- return metadataKey;
- }
- public void setMetadataKey(String metadataKey) {
- this.metadataKey = metadataKey;
- }
- public String getChecksum() {
- return checksum;
- }
- public void setChecksum(String checksum) {
- this.checksum = checksum;
- }
- }
- public static class Encrypted {
- private Map<Integer, String> metadataKeys;
- public Map<Integer, String> getMetadataKeys() {
- return this.metadataKeys;
- }
- public void setMetadataKeys(Map<Integer, String> metadataKeys) {
- this.metadataKeys = metadataKeys;
- }
- }
- public static class DecryptedFile {
- private Data encrypted;
- private String initializationVector;
- private String authenticationTag;
- transient private int metadataKey;
- public Data getEncrypted() {
- return this.encrypted;
- }
- public String getInitializationVector() {
- return this.initializationVector;
- }
- public String getAuthenticationTag() {
- return this.authenticationTag;
- }
- public int getMetadataKey() {
- return this.metadataKey;
- }
- public void setEncrypted(Data encrypted) {
- this.encrypted = encrypted;
- }
- public void setInitializationVector(String initializationVector) {
- this.initializationVector = initializationVector;
- }
- public void setAuthenticationTag(String authenticationTag) {
- this.authenticationTag = authenticationTag;
- }
- public void setMetadataKey(int metadataKey) {
- this.metadataKey = metadataKey;
- }
- }
- public static class Data {
- private String key;
- private String filename;
- private String mimetype;
- transient private double version;
- public String getKey() {
- return this.key;
- }
- public String getFilename() {
- return this.filename;
- }
- public String getMimetype() {
- return this.mimetype;
- }
- public double getVersion() {
- return this.version;
- }
- public void setKey(String key) {
- this.key = key;
- }
- public void setFilename(String filename) {
- this.filename = filename;
- }
- public void setMimetype(String mimetype) {
- this.mimetype = mimetype;
- }
- public void setVersion(int version) {
- this.version = version;
- }
- }
- }
|