From afd26cdd12fef4bd2aafa2ac8d708e18d277a2fe Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 12 Jan 2021 12:51:23 +0800 Subject: Implement object collection(not tested) and sha256(tested) --- .../util/backup/inc/ObjectCollectionManager.java | 11 -------- .../backup/inc/identifier/ObjectIdentifier.java | 9 ------ .../inc/identifier/SingleHashIdentifier.java | 32 ---------------------- 3 files changed, 52 deletions(-) delete mode 100644 src/main/java/com/keuin/kbackupfabric/util/backup/inc/ObjectCollectionManager.java delete mode 100644 src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/ObjectIdentifier.java delete mode 100644 src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/SingleHashIdentifier.java (limited to 'src/main/java/com/keuin/kbackupfabric/util/backup/inc') diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/inc/ObjectCollectionManager.java b/src/main/java/com/keuin/kbackupfabric/util/backup/inc/ObjectCollectionManager.java deleted file mode 100644 index 9560261..0000000 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/inc/ObjectCollectionManager.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.keuin.kbackupfabric.util.backup.inc; - -/** - * Incremental backup is implemented as git-like file collection. - * Files are called `objects`, the collection contains all files distinguished by their - * identifiers. Usually, identifier is the combination of hash and other short information (such as size and another hash). - * The identifier should use hashes that are strong enough, to prevent possible collisions. - */ -public class ObjectCollectionManager { - -} diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/ObjectIdentifier.java b/src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/ObjectIdentifier.java deleted file mode 100644 index 079f49d..0000000 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/ObjectIdentifier.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.keuin.kbackupfabric.util.backup.inc.identifier; - -/** - * The identifier distinguishing files in the object collection. - * It should be based on cryptographic hash function in order to prevent possible attacks to the backup system. - * All identifiers should be immutable and implement their own equals method. - */ -public interface ObjectIdentifier { -} diff --git a/src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/SingleHashIdentifier.java b/src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/SingleHashIdentifier.java deleted file mode 100644 index 50b23bb..0000000 --- a/src/main/java/com/keuin/kbackupfabric/util/backup/inc/identifier/SingleHashIdentifier.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.keuin.kbackupfabric.util.backup.inc.identifier; - -import java.io.File; -import java.util.Arrays; - -/** - * A simple identifier based on a single hash function. - */ -public abstract class SingleHashIdentifier implements ObjectIdentifier { - - private final byte[] hash; - - protected SingleHashIdentifier(byte[] hash) { - this.hash = Arrays.copyOf(hash, hash.length); - } - - /** - * The hash function. - * - * @param file the file to be hashed. - * @return the hash bytes. - */ - protected abstract byte[] hash(File file); - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof SingleHashIdentifier)) { - return false; - } - return Arrays.equals(hash, ((SingleHashIdentifier) obj).hash); - } -} -- cgit v1.2.3