-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileMetadata.java
More file actions
281 lines (212 loc) · 11 KB
/
Copy pathFileMetadata.java
File metadata and controls
281 lines (212 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
package com.securefileshare.models;
import java.sql.Timestamp;
public class FileMetadata {
private int fileId;
private int userId;
private String originalFilename;
private String storedFilename;
private String fileHash;
private long fileSize;
private String fileType;
private String description;
// CloudMe specific fields
private String cloudFileId;
private String cloudmeFileId;
private String cloudmeAccount;
private String cloudmePath;
private String cloudmeFolder;
private Timestamp cloudmeModifiedDate;
private String cloudmeSyncStatus;
private String webdavPath;
private String cloudStorage;
// Encryption fields
private String encryptionKey;
private String encryptionKeyHash;
private String iv;
private String ivBase64;
private String saltBase64;
private int keyIterations;
private String encryptionAlgorithm;
private boolean encrypted;
// File properties
private boolean sensitive;
private Timestamp accessExpiry;
private Timestamp uploadDate;
private Timestamp lastDownloadDate;
private int accessCount;
private int downloadCount;
private int maxDownloads;
// Upload metadata
private int retentionDays;
private String tags;
private String uploadMethod;
private int chunkCount;
private int chunkSize;
private String uploadStatus;
// File integrity
private String sha256Hash;
private String sha256EncryptedHash;
// Compression
private double compressionRatio;
// Sharing
private boolean shared;
private String shareToken;
private Timestamp shareExpiry;
private String sharePasswordHash;
private int shareMaxDownloads;
// For backward compatibility - alias methods
public String getCloudPath() {
return cloudmePath != null ? cloudmePath : webdavPath;
}
public void setCloudPath(String cloudPath) {
this.cloudmePath = cloudPath;
this.webdavPath = cloudPath;
}
public String getProcessedHash() {
return sha256EncryptedHash;
}
public void setProcessedHash(String processedHash) {
this.sha256EncryptedHash = processedHash;
}
public String getStoragePath() {
return webdavPath;
}
public void setStoragePath(String storagePath) {
this.webdavPath = storagePath;
this.cloudmePath = storagePath;
}
public String getSalt() {
return saltBase64;
}
public void setSalt(String salt) {
this.saltBase64 = salt;
}
public long getProcessedSize() {
return fileSize;
}
public void setProcessedSize(long processedSize) {
// Not storing separately
}
public String getHashAlgorithm() {
return "SHA-256";
}
public void setHashAlgorithm(String hashAlgorithm) {
// Default SHA-256
}
// Getters and Setters
public int getFileId() { return fileId; }
public void setFileId(int fileId) { this.fileId = fileId; }
public int getUserId() { return userId; }
public void setUserId(int userId) { this.userId = userId; }
public String getOriginalFilename() { return originalFilename; }
public void setOriginalFilename(String originalFilename) { this.originalFilename = originalFilename; }
public String getStoredFilename() { return storedFilename; }
public void setStoredFilename(String storedFilename) { this.storedFilename = storedFilename; }
public String getFileHash() { return fileHash; }
public void setFileHash(String fileHash) { this.fileHash = fileHash; }
public long getFileSize() { return fileSize; }
public void setFileSize(long fileSize) { this.fileSize = fileSize; }
public String getFileType() { return fileType; }
public void setFileType(String fileType) { this.fileType = fileType; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public String getCloudFileId() { return cloudFileId; }
public void setCloudFileId(String cloudFileId) { this.cloudFileId = cloudFileId; }
public String getCloudmeFileId() { return cloudmeFileId; }
public void setCloudmeFileId(String cloudmeFileId) { this.cloudmeFileId = cloudmeFileId; }
public String getCloudmeAccount() { return cloudmeAccount; }
public void setCloudmeAccount(String cloudmeAccount) { this.cloudmeAccount = cloudmeAccount; }
public String getCloudmePath() { return cloudmePath; }
public void setCloudmePath(String cloudmePath) { this.cloudmePath = cloudmePath; }
public String getCloudmeFolder() { return cloudmeFolder; }
public void setCloudmeFolder(String cloudmeFolder) { this.cloudmeFolder = cloudmeFolder; }
public Timestamp getCloudmeModifiedDate() { return cloudmeModifiedDate; }
public void setCloudmeModifiedDate(Timestamp cloudmeModifiedDate) { this.cloudmeModifiedDate = cloudmeModifiedDate; }
public String getCloudmeSyncStatus() { return cloudmeSyncStatus; }
public void setCloudmeSyncStatus(String cloudmeSyncStatus) { this.cloudmeSyncStatus = cloudmeSyncStatus; }
public String getWebdavPath() { return webdavPath; }
public void setWebdavPath(String webdavPath) { this.webdavPath = webdavPath; }
public String getCloudStorage() { return cloudStorage; }
public void setCloudStorage(String cloudStorage) { this.cloudStorage = cloudStorage; }
public String getEncryptionKey() { return encryptionKey; }
public void setEncryptionKey(String encryptionKey) { this.encryptionKey = encryptionKey; }
public String getEncryptionKeyHash() { return encryptionKeyHash; }
public void setEncryptionKeyHash(String encryptionKeyHash) { this.encryptionKeyHash = encryptionKeyHash; }
public String getIv() { return iv; }
public void setIv(String iv) { this.iv = iv; }
public String getIvBase64() { return ivBase64; }
public void setIvBase64(String ivBase64) { this.ivBase64 = ivBase64; }
public String getSaltBase64() { return saltBase64; }
public void setSaltBase64(String saltBase64) { this.saltBase64 = saltBase64; }
public int getKeyIterations() { return keyIterations; }
public void setKeyIterations(int keyIterations) { this.keyIterations = keyIterations; }
public String getEncryptionAlgorithm() { return encryptionAlgorithm; }
public void setEncryptionAlgorithm(String encryptionAlgorithm) { this.encryptionAlgorithm = encryptionAlgorithm; }
public boolean isEncrypted() { return encrypted; }
public void setEncrypted(boolean encrypted) { this.encrypted = encrypted; }
public boolean isSensitive() { return sensitive; }
public void setSensitive(boolean sensitive) { this.sensitive = sensitive; }
public Timestamp getAccessExpiry() { return accessExpiry; }
public void setAccessExpiry(Timestamp accessExpiry) { this.accessExpiry = accessExpiry; }
public Timestamp getUploadDate() { return uploadDate; }
public void setUploadDate(Timestamp uploadDate) { this.uploadDate = uploadDate; }
public Timestamp getLastDownloadDate() { return lastDownloadDate; }
public void setLastDownloadDate(Timestamp lastDownloadDate) { this.lastDownloadDate = lastDownloadDate; }
public int getAccessCount() { return accessCount; }
public void setAccessCount(int accessCount) { this.accessCount = accessCount; }
public int getDownloadCount() { return downloadCount; }
public void setDownloadCount(int downloadCount) { this.downloadCount = downloadCount; }
public int getMaxDownloads() { return maxDownloads; }
public void setMaxDownloads(int maxDownloads) { this.maxDownloads = maxDownloads; }
public int getRetentionDays() { return retentionDays; }
public void setRetentionDays(int retentionDays) { this.retentionDays = retentionDays; }
public String getTags() { return tags; }
public void setTags(String tags) { this.tags = tags; }
public String getUploadMethod() { return uploadMethod; }
public void setUploadMethod(String uploadMethod) { this.uploadMethod = uploadMethod; }
public int getChunkCount() { return chunkCount; }
public void setChunkCount(int chunkCount) { this.chunkCount = chunkCount; }
public int getChunkSize() { return chunkSize; }
public void setChunkSize(int chunkSize) { this.chunkSize = chunkSize; }
public String getUploadStatus() { return uploadStatus; }
public void setUploadStatus(String uploadStatus) { this.uploadStatus = uploadStatus; }
public String getSha256Hash() { return sha256Hash; }
public void setSha256Hash(String sha256Hash) { this.sha256Hash = sha256Hash; }
public String getSha256EncryptedHash() { return sha256EncryptedHash; }
public void setSha256EncryptedHash(String sha256EncryptedHash) { this.sha256EncryptedHash = sha256EncryptedHash; }
public double getCompressionRatio() { return compressionRatio; }
public void setCompressionRatio(double compressionRatio) { this.compressionRatio = compressionRatio; }
public boolean isShared() { return shared; }
public void setShared(boolean shared) { this.shared = shared; }
public String getShareToken() { return shareToken; }
public void setShareToken(String shareToken) { this.shareToken = shareToken; }
public Timestamp getShareExpiry() { return shareExpiry; }
public void setShareExpiry(Timestamp shareExpiry) { this.shareExpiry = shareExpiry; }
public String getSharePasswordHash() { return sharePasswordHash; }
public void setSharePasswordHash(String sharePasswordHash) { this.sharePasswordHash = sharePasswordHash; }
public int getShareMaxDownloads() { return shareMaxDownloads; }
public void setShareMaxDownloads(int shareMaxDownloads) { this.shareMaxDownloads = shareMaxDownloads; }
// Constructor
public FileMetadata() {
this.encrypted = true;
this.sensitive = false;
this.accessCount = 0;
this.downloadCount = 0;
this.retentionDays = 30;
this.uploadMethod = "standard";
this.chunkSize = 5242880; // 5MB
this.uploadStatus = "completed";
this.cloudStorage = "CLOUDME";
this.cloudmeSyncStatus = "synced";
this.encryptionAlgorithm = "AES-256-GCM";
this.keyIterations = 65536;
}
public String toDebugString() {
return String.format(
"FileMetadata{fileId=%d, userId=%d, original='%s', stored='%s', " +
"size=%d, cloudFileId='%s', webdavPath='%s', encrypted=%s}",
fileId, userId, originalFilename, storedFilename,
fileSize, cloudFileId, webdavPath, encrypted
);
}
}