diff --git a/app/src/main/java/lightcontainer/domains/Task.java b/app/src/main/java/lightcontainer/domains/Task.java index 42ce548..c32133d 100644 --- a/app/src/main/java/lightcontainer/domains/Task.java +++ b/app/src/main/java/lightcontainer/domains/Task.java @@ -3,6 +3,7 @@ package lightcontainer.domains; import lightcontainer.domains.client.Context; import lightcontainer.enumerations.TaskStatus; import lightcontainer.protocol.ProtocolWriter; +import lightcontainer.utils.Log; /** * Une tâche exécutable @@ -43,7 +44,6 @@ public class Task { * @return TRUE si le client doit recevoir cette réponse. */ public boolean isResponseOfClient(String storeDomain) { - System.out.println(status + " - " + context.getDomain() + " | " + storeDomain); return (status == TaskStatus.PROCESSING && context.getDomain().equals(storeDomain)); } diff --git a/app/src/main/java/lightcontainer/domains/client/ClientHandler.java b/app/src/main/java/lightcontainer/domains/client/ClientHandler.java index 16f7dff..19e0cac 100644 --- a/app/src/main/java/lightcontainer/domains/client/ClientHandler.java +++ b/app/src/main/java/lightcontainer/domains/client/ClientHandler.java @@ -9,6 +9,7 @@ import lightcontainer.protocol.rules.reader.SigninRule; import lightcontainer.protocol.rules.reader.SignoutRule; import lightcontainer.protocol.rules.reader.SignupRule; import lightcontainer.protocol.rules.writer.SignErrorRule; +import lightcontainer.utils.Log; import java.io.IOException; import java.net.Socket; @@ -58,7 +59,7 @@ public class ClientHandler extends UnicastThread implements AutoCloseable { try { String command = this.readLine(); if (command != null) { - System.out.println("Client: " + command); + Log.getInstance().infoln("Client: " + command); } else { this.repository.disconnect(this); break; @@ -73,7 +74,6 @@ public class ClientHandler extends UnicastThread implements AutoCloseable { if (checkAccess(ruleResult)) { // Lecture du fichier client ruleResult.read(this.getInputStream()); - System.out.println(getContext().getLogin() + " - " + 1); ProtocolWriter.ProtocolResult writerCommand = ruleResult.getResultCommand(); // TODO : Vérifier que le StorBackEnd demandé (Pas toujours demandé) est disponible if (ruleResult.getReceiver() == ProtocolReader.ResultCmdReceiver.STOREBACKEND && !fileFrontEnd.canExecuteCommand(ruleResult.getRequestDomain())) { @@ -181,9 +181,9 @@ public class ClientHandler extends UnicastThread implements AutoCloseable { try { super.close(); this.repository.disconnect(this); - System.out.printf("[CLIENT] %s s'est déconnecté\n", getContext().getLogin()); + Log.getInstance().infof("[CLIENT] %s s'est déconnecté\n", getContext().getLogin()); } catch (IOException e) { - System.out.println("[CH] Error while closing client."); + Log.getInstance().infoln("[CH] Error while closing client."); } } } diff --git a/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java b/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java index 2efbfe2..e570af9 100644 --- a/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java +++ b/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java @@ -4,6 +4,7 @@ import lightcontainer.interfaces.ProtocolRepository; import lightcontainer.interfaces.StoreProcessorFFE; import lightcontainer.protocol.ProtocolReader; import lightcontainer.protocol.ProtocolWriter; +import lightcontainer.utils.Log; import java.io.IOException; import java.net.Socket; @@ -56,7 +57,7 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable { if (protocolResult == null) { // Si on n'a pas encore la commande à envoyer waitAction(); } - System.out.println("[SBE] Envoie commande : " + protocolResult.getCommand()); + Log.getInstance().infoln("[SBE] Envoie commande : " + protocolResult.getCommand()); // Request this.write(protocolResult.getCommand()); @@ -74,23 +75,23 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable { responseCommand += "\r\n"; ProtocolReader.ProtocolResult responseResult = protocolRep.executeReader(getContext(), responseCommand); if (responseResult != null) { - System.out.println("StoreBackEnd (" + domain + ") response to client: " + responseResult.getResultCommand()); + Log.getInstance().infoln("StoreBackEnd (" + domain + ") response to client: " + responseResult.getResultCommand()); responseResult.read( this.getInputStream() ); alertAvailable(responseResult.getResultCommand()); } else { - System.out.println("StoreBackEnd result: Commande null"); + Log.getInstance().infoln("StoreBackEnd result: Commande null"); alertAvailable(null); } } else { - System.out.println("StoreBackEnd: Commande null"); + Log.getInstance().infoln("StoreBackEnd: Commande null"); alertAvailable(null); } } catch (IOException exception) { - System.out.println("[ERROR] Problem with SBE (" + domain + ") : " + exception.getMessage()); + Log.getInstance().infoln("[ERROR] Problem with SBE (" + domain + ") : " + exception.getMessage()); this.close(); } } @@ -100,7 +101,7 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable { this.close(); this.fileFrontEnd.onStoreDisconnect(this.domain); } catch (Exception e) { - System.out.println("[ERROR] Error while closing SBE (" + domain + ") : " + e.getMessage()); + Log.getInstance().infoln("[ERROR] Error while closing SBE (" + domain + ") : " + e.getMessage()); } } @@ -153,7 +154,7 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable { public void close() { if (this.isRunning()) { this.setRunning(false); - System.out.println("[SBE] Fermeture de " + domain); + Log.getInstance().infoln("[SBE] Fermeture de " + domain); } } diff --git a/app/src/main/java/lightcontainer/domains/server/MulticastServerListener.java b/app/src/main/java/lightcontainer/domains/server/MulticastServerListener.java index 32e9c42..c6fc769 100644 --- a/app/src/main/java/lightcontainer/domains/server/MulticastServerListener.java +++ b/app/src/main/java/lightcontainer/domains/server/MulticastServerListener.java @@ -6,6 +6,7 @@ import lightcontainer.interfaces.ProtocolRepository; import lightcontainer.protocol.ProtocolReader; import lightcontainer.protocol.rules.reader.HelloRule; import lightcontainer.repository.FileFrontEnd; +import lightcontainer.utils.Log; import lightcontainer.utils.NetChooser; import java.io.IOException; @@ -74,16 +75,17 @@ public class MulticastServerListener implements Runnable { onNewSbe(packet); } } catch (IOException ioException) { - System.out.println("[ERREUR] Multicast server can't start : " + ioException.getMessage()); + Log.getInstance().infoln("[ERREUR] Multicast server can't start : " + ioException.getMessage()); } } private void onNewSbe(DatagramPacket packet) { try { String data = new String(packet.getData(), 0, packet.getLength()); + HelloRule.Result readerResult = protocolRep.executeReader(null, data); - System.out.printf("Nouveau SBE : Domain=%s | Port=%d\n", readerResult.getDomain(), readerResult.getPort()); + Log.getInstance().infof("Nouveau SBE : Domain=%s | Port=%d\n", readerResult.getDomain(), readerResult.getPort()); if (!this.repository.hasDomain(readerResult.getDomain())){ Socket socket = new Socket(packet.getAddress(), readerResult.getPort()); @@ -97,7 +99,7 @@ public class MulticastServerListener implements Runnable { // Contient déjà le SBE donc maj de la dernière activité this.repository.updateLastAnnounce(readerResult.getDomain()); } catch (IOException | ClassCastException exception) { - System.out.println("[ERREUR] Une SBE essaye de se connecter avec une mauvaise configuration : " + exception.getMessage()); + Log.getInstance().infoln("[ERREUR] Une SBE essaye de se connecter avec une mauvaise configuration : " + exception.getMessage()); } } diff --git a/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java b/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java index 2f15e98..85046e3 100644 --- a/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java +++ b/app/src/main/java/lightcontainer/protocol/ProtocolWriter.java @@ -1,6 +1,7 @@ package lightcontainer.protocol; import lightcontainer.domains.client.Context; +import lightcontainer.utils.Log; import java.io.IOException; import java.io.OutputStream; @@ -83,7 +84,7 @@ public abstract class ProtocolWriter { String command = builder + "\r\n"; Matcher ruleMatcher = this.rulePattern.matcher(command); // Vérifie que tout match (cf. Matcher). Si match alors on retourne la commande build, sinon on retourne NULL - System.out.println("Crée la commande : " + command); + if (ruleMatcher.matches()) { ProtocolResult result = onExecuted(context, data); result.setCommand(command); diff --git a/app/src/main/java/lightcontainer/protocol/rules/reader/RetrieveOkRule.java b/app/src/main/java/lightcontainer/protocol/rules/reader/RetrieveOkRule.java index 7e9c278..67aeac4 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/reader/RetrieveOkRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/reader/RetrieveOkRule.java @@ -6,6 +6,7 @@ import lightcontainer.protocol.ProtocolReader; import lightcontainer.protocol.rules.writer.GetFileErrorRule; import lightcontainer.protocol.rules.writer.GetFileOkRule; import lightcontainer.utils.FileReceiver; +import lightcontainer.utils.Log; import lightcontainer.utils.SHA; import java.io.InputStream; @@ -60,7 +61,7 @@ public class RetrieveOkRule extends ProtocolReader { @Override public void read(InputStream reader) { super.read(reader); - System.out.println("Récupération du fichier du SBE"); + try { FileReceiver fileReceiver = new FileReceiver(storagePath); if (!fileReceiver.receiveFile(reader, this.filename, this.filesize)) { diff --git a/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java b/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java index 0e859bb..237cca6 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java @@ -47,13 +47,11 @@ public class SavefileRule extends ProtocolReader { super(context); this.filename = filename; this.size = size; - System.out.println(size); } @Override public void read(InputStream reader) { super.read(reader); - System.out.printf("Sauvegarde du fichier : %s %d\n", filename, size); if (getContext().canAddFile()) { try { @@ -75,8 +73,6 @@ public class SavefileRule extends ProtocolReader { long encryptedFileSize = fileReceiver.receiveFile(reader, this.filename, this.size, key, iv); if (encryptedFileSize < 0) throw new IOException(); - System.out.println(encryptedFileSize); - String fileHash = SHA.hashFile(storagePath, this.filename); // On met les données de la requête actuelle diff --git a/app/src/main/java/lightcontainer/protocol/rules/writer/EraseFileRule.java b/app/src/main/java/lightcontainer/protocol/rules/writer/EraseFileRule.java index 19f57a7..3c1c3c3 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/writer/EraseFileRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/writer/EraseFileRule.java @@ -2,6 +2,7 @@ package lightcontainer.protocol.rules.writer; import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.StandardizedDefinitions; +import lightcontainer.utils.Log; import static lightcontainer.protocol.StandardizedDefinitions.FFE_ERASE_FILE; @@ -15,6 +16,5 @@ public class EraseFileRule extends ProtocolWriter { public EraseFileRule() { super(NAME, PATTERN); - System.out.println(PATTERN); } } diff --git a/app/src/main/java/lightcontainer/protocol/rules/writer/GetFileOkRule.java b/app/src/main/java/lightcontainer/protocol/rules/writer/GetFileOkRule.java index 516658c..ec2ab61 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/writer/GetFileOkRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/writer/GetFileOkRule.java @@ -4,6 +4,7 @@ import lightcontainer.domains.client.Context; import lightcontainer.protocol.ProtocolWriter; import lightcontainer.utils.DeepFileEraser; import lightcontainer.utils.FileSender; +import lightcontainer.utils.Log; import java.io.IOException; import java.io.OutputStream; @@ -47,9 +48,6 @@ public class GetFileOkRule extends ProtocolWriter { */ @Override public void write(OutputStream writer) throws IOException { - System.out.printf("Sauvegarde du fichier : %s %d\n", this.filename, this.filesize); - - System.out.println("Encrypted size for parsing: " + getContext().getDataLong("encryptedFileSize") + " normal: " + getContext().getDataLong("fileSize")); FileSender fileSender = new FileSender(storagePath); fileSender.sendFile( getContext().getDataString("hashedFileName"), diff --git a/app/src/main/java/lightcontainer/protocol/rules/writer/SaveFileOkRule.java b/app/src/main/java/lightcontainer/protocol/rules/writer/SaveFileOkRule.java index 2dc847e..80f1085 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/writer/SaveFileOkRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/writer/SaveFileOkRule.java @@ -3,6 +3,7 @@ package lightcontainer.protocol.rules.writer; import lightcontainer.domains.client.Context; import lightcontainer.protocol.ProtocolWriter; import lightcontainer.utils.DeepFileEraser; +import lightcontainer.utils.Log; import static lightcontainer.protocol.StandardizedDefinitions.FFE_SAVE_FILE_OK; @@ -26,7 +27,6 @@ public class SaveFileOkRule extends ProtocolWriter { protected ProtocolWriter.ProtocolResult onExecuted(Context context, String... data) { ProtocolWriter.ProtocolResult result = new ProtocolWriter.ProtocolResult(context); - System.out.println("===> Save en json " + context.getDomain() + " - " + context.getLogin()); // Sauvegarder dans JSON context.addFile(context.getDataString("fileName"), context.getDataString("fileNameSalt"), context.getDataLong("size"), context.getDataString("iv"), context.getDomain()); diff --git a/app/src/main/java/lightcontainer/protocol/rules/writer/SendfileRule.java b/app/src/main/java/lightcontainer/protocol/rules/writer/SendfileRule.java index 4dd9b18..e46d8b8 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/writer/SendfileRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/writer/SendfileRule.java @@ -4,6 +4,7 @@ import lightcontainer.domains.client.Context; import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.StandardizedDefinitions; import lightcontainer.utils.FileSender; +import lightcontainer.utils.Log; import java.io.IOException; import java.io.OutputStream; @@ -46,7 +47,6 @@ public class SendfileRule extends ProtocolWriter { @Override public void write(OutputStream writer) throws IOException { super.write(writer); - System.out.println("Envoie du fichier au SBE"); FileSender fileSender = new FileSender(storagePath); fileSender.sendFile(hashedFileName, writer); diff --git a/app/src/main/java/lightcontainer/storage/AppData.java b/app/src/main/java/lightcontainer/storage/AppData.java index 326839b..296c655 100644 --- a/app/src/main/java/lightcontainer/storage/AppData.java +++ b/app/src/main/java/lightcontainer/storage/AppData.java @@ -1,5 +1,7 @@ package lightcontainer.storage; +import lightcontainer.utils.Log; + import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -194,7 +196,6 @@ public class AppData { */ public boolean verifyUser(String login, String password) { User user = getUser(login); - System.out.println("OKOKOK " + password + " ok " + user); return user != null && user.verifyPassword(password); } diff --git a/app/src/main/java/lightcontainer/storage/JsonAdapter.java b/app/src/main/java/lightcontainer/storage/JsonAdapter.java index d3c07c9..aed572c 100644 --- a/app/src/main/java/lightcontainer/storage/JsonAdapter.java +++ b/app/src/main/java/lightcontainer/storage/JsonAdapter.java @@ -1,6 +1,7 @@ package lightcontainer.storage; import com.google.gson.*; +import lightcontainer.utils.Log; import java.util.*; @@ -97,7 +98,7 @@ public class JsonAdapter implements Adapter { } return appData; } catch (JsonParseException parseException) { - System.out.println("[FFE] : Error while loading configuration file"); //TODO - changer en log + Log.getInstance().infoln("[FFE] : Error while loading configuration file"); //TODO - changer en log return null; } } diff --git a/app/src/main/java/lightcontainer/storage/Repository.java b/app/src/main/java/lightcontainer/storage/Repository.java index ea65159..7c2201a 100644 --- a/app/src/main/java/lightcontainer/storage/Repository.java +++ b/app/src/main/java/lightcontainer/storage/Repository.java @@ -1,5 +1,7 @@ package lightcontainer.storage; +import lightcontainer.utils.Log; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -35,7 +37,7 @@ public class Repository { bufferedWriter.write(jsonAppData); bufferedWriter.flush(); } catch (IOException e) { - System.out.println("Error while saving configuration file !"); + Log.getInstance().infoln("Error while saving configuration file !"); } } } @@ -93,7 +95,7 @@ public class Repository { builder.append(reader.readLine()); } } catch (IOException e) { - System.out.println("Error while reading configuration file"); + Log.getInstance().infoln("Error while reading configuration file"); builder.setLength(0); } return builder.toString(); diff --git a/app/src/main/java/lightcontainer/storage/User.java b/app/src/main/java/lightcontainer/storage/User.java index 896f76e..6f8eaf9 100644 --- a/app/src/main/java/lightcontainer/storage/User.java +++ b/app/src/main/java/lightcontainer/storage/User.java @@ -1,6 +1,7 @@ package lightcontainer.storage; import lightcontainer.utils.BCryptHasher; +import lightcontainer.utils.Log; import java.util.ArrayList; import java.util.Iterator; @@ -27,7 +28,6 @@ public class User { this.password = password; this.aesKey = aesKey; this.files = files; - System.out.println(files.size() + " fichiers trouvéssss pour " + name); } public String getName() { diff --git a/app/src/main/java/lightcontainer/utils/AES_GCM.java b/app/src/main/java/lightcontainer/utils/AES_GCM.java index 8addb45..b37474f 100644 --- a/app/src/main/java/lightcontainer/utils/AES_GCM.java +++ b/app/src/main/java/lightcontainer/utils/AES_GCM.java @@ -21,58 +21,6 @@ public class AES_GCM { public static final int GCM_IV_LENGTH = 16; public static final int GCM_TAG_LENGTH = 16; - // Main method for testing - public static void main(String[] args) throws Exception { - /* - * FILE ENCRYPTION DEMO - */ - // Init files - File inFile = new File("D:\\HELMo.png"); - File outFile = new File("D:\\HELMoCrypted.png"); - File clearFile = new File("D:\\HELMoClear.png"); - outFile.createNewFile(); - clearFile.createNewFile(); - // Make options - String IVFile = generateIV(); - String keyFile = generateSecretKey(); - // Show options - System.out.println("IV : " + IVFile); - System.out.println("Key : " + keyFile); - // Encrypt - encryptStream( - new FileInputStream(inFile), - new FileOutputStream(outFile), - inFile.length(), - IVFile, - keyFile - ); - // Decrypt - decryptStream( - new FileInputStream(outFile), - new FileOutputStream(clearFile), - outFile.length(), - IVFile, - keyFile - ); - - /* - * TEXT ENCRYPTION DEMO - */ - // Make option - String plainText = "Salut sombre fils de pute, comment vas tu ?";//TODO enlever le text chelou de Jérémi (ce fou là) - String IV = generateIV(); - String key = generateSecretKey(); - // Show options - System.out.println("IV : " + IV); - System.out.println("Key : " + key); - System.out.println("Original text : " + plainText); - // Crypt - String cryptText = encrypt(plainText, key, IV); - System.out.println("Encrypted text : " + cryptText); - // Decrypt - String decryptedText = decrypt(cryptText, key, IV); - System.out.println("Decrypted text : " + decryptedText); - } /** * Decoder to decode base64 vector to byte vector. diff --git a/app/src/main/java/lightcontainer/utils/DeepFileEraser.java b/app/src/main/java/lightcontainer/utils/DeepFileEraser.java index 3a6d6a9..7966b37 100644 --- a/app/src/main/java/lightcontainer/utils/DeepFileEraser.java +++ b/app/src/main/java/lightcontainer/utils/DeepFileEraser.java @@ -20,15 +20,6 @@ public class DeepFileEraser { public static final int DFE_STEP_MIN_FILL_VALUE = 0; // Minimum filling value of a writing phase public static final int DFE_STEP_MAX_FILL_VALUE = 15; // Maximum filling value of a writing phase - public static void main(String[] args) throws Exception - { - System.out.println(random(1, 3)); - try { - eraseFile("D:\\lol"); - } catch (Exception e) { - e.printStackTrace(); - } - } /** * Generate a number randomly. diff --git a/app/src/main/java/lightcontainer/utils/FileSender.java b/app/src/main/java/lightcontainer/utils/FileSender.java index 5781961..b80496d 100644 --- a/app/src/main/java/lightcontainer/utils/FileSender.java +++ b/app/src/main/java/lightcontainer/utils/FileSender.java @@ -12,7 +12,6 @@ public class FileSender { public boolean sendFile(String filename, OutputStream out, long fileSize, String aesKey, String iv) throws IOException { BufferedInputStream bisFile; - System.out.printf("Envoie fichier : %s - %s - %s \n", filename, aesKey, iv); try { File f = new File(String.format("%s/%s", path, filename)); if (f.exists()) { diff --git a/app/src/main/java/lightcontainer/utils/Log.java b/app/src/main/java/lightcontainer/utils/Log.java index 0aa9e26..2a07a05 100644 --- a/app/src/main/java/lightcontainer/utils/Log.java +++ b/app/src/main/java/lightcontainer/utils/Log.java @@ -1,10 +1,35 @@ package lightcontainer.utils; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.Logger; - public class Log { + public void infoln(String msg) { + System.out.println(msg); + } + + public void infoln(int msg) { + System.out.println(msg); + } + + public void infoln(long msg) { + System.out.println(msg); + } + + public void infoln(Object msg) { + System.out.println(msg); + } + + + public void infof(String msg, Object... data) { + System.out.printf(msg, data); + } + + private static Log instance; + + public static Log getInstance() { + if (instance == null) { + instance = new Log(); + } + return instance; + } } diff --git a/app/src/main/java/lightcontainer/utils/NetChooser.java b/app/src/main/java/lightcontainer/utils/NetChooser.java index d46de32..0836ccf 100644 --- a/app/src/main/java/lightcontainer/utils/NetChooser.java +++ b/app/src/main/java/lightcontainer/utils/NetChooser.java @@ -19,11 +19,11 @@ public class NetChooser { Scanner console = new Scanner(System.in); String[] allInterfaceNames = getInterfaces(); for (int index = 0; index < allInterfaceNames.length; ++index) { - System.out.printf("%d. %s\n", index, allInterfaceNames[index]); + Log.getInstance().infof("%d. %s\n", index, allInterfaceNames[index]); } - System.out.printf("Select your interface :"); + Log.getInstance().infof("Select your interface :"); NetworkInterface selected = getInterfacesByIndex(console.nextInt()); - System.out.printf("Selected interface: %s\n", selected.getDisplayName()); + Log.getInstance().infof("Selected interface: %s\n", selected.getDisplayName()); return selected; } @@ -66,7 +66,4 @@ public class NetChooser { return null; } - public static void main(String[] args) { - new NetChooser(); - } } \ No newline at end of file diff --git a/app/src/main/java/lightcontainer/utils/SHA.java b/app/src/main/java/lightcontainer/utils/SHA.java index 76dee77..66656e5 100644 --- a/app/src/main/java/lightcontainer/utils/SHA.java +++ b/app/src/main/java/lightcontainer/utils/SHA.java @@ -21,22 +21,6 @@ public class SHA { // Constants public static final String SHA_VERSION = "SHA-256"; - // Main method for testing - public static void main(String[] args) throws Exception { - /* - * BORROWING ENCRYPTION DEMO - */ - File inFile = new File("D:\\HELMoCrypted.png"); - System.out.println(hashStream( - new FileInputStream(inFile), - inFile.length() - )); - - System.out.println(hashFile( // caca5439dc02f2ced5094e95f1a3403d42127cda29feecd2eb1c68ff38a6fee3 - "D:\\ffe", - "46ba86ddecd2fe80c3bdb9fb2f9480b4c92057447e9d1b43863dd1a6d540f3a316571684f9e3a7459f533a9792d4925e" - )); - } /** * Make a borrowing of the stream. diff --git a/app/src/main/resources/appdata.json b/app/src/main/resources/appdata.json index d9a25a1..c23e22a 100644 --- a/app/src/main/resources/appdata.json +++ b/app/src/main/resources/appdata.json @@ -1 +1 @@ -{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"wlp1s0","tls":true,"storagePath":"/home/benjamin/ffe","users":[{"name":"benjamin","password":"$2a$10$I4vHt83CTYuQCP7xvZ04Ne7Vb0cswBiVZhV0n23k9FCxoH0ny9fZG","aes_key":"mAP6izUBUhBxIkakH2yB/TplhRz1OQV5Fp6HQmhywns=","files":[{"name":"README.md","fileNameSalt":"5rB5fhj09F6ukJPRoJgTGQ==","size":17,"iv":"hY2yWRgIxB0dRettv/vPJw==","storage":["lightcontainerSB01"]}]},{"name":"aaaaa","password":"$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W","aes_key":"kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=","files":[]}]} \ No newline at end of file +{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"tun0","tls":false,"storagePath":"/home/benjamin/ffe","users":[{"name":"90004142","password":"$2a$10$4/YHWJNlS40X5duOYpRaPOk7XcE5eWXqpTBfnWivDx9BeIjpPxs.u","aes_key":"i7+O+euhXRqgjW2IGmW+5KfPuS+olP11S+J44q4rdnY=","files":[]},{"name":"900024935","password":"$2a$10$nsLkeXZrkpFtvp/Db63cseLvP7DEMtfwMxHbFzF/T15xuYZW1EhC2","aes_key":"hT4t7hB2n3iq/2EdZP32HAbO8o/gY20y9uF0QO/BgaU=","files":[]},{"name":"900039267","password":"$2a$10$kYrVuD.ILwuXdB7FBxOtwupBpGGdSauMOGuA4OUpYobbWE8Fh2VRu","aes_key":"d8ESyVJuCZrDmUY94uKdpCd7IG5ZjOwaAeMEcL6TWvU=","files":[]},{"name":"aaaaa","password":"$2a$10$mhJW5GO3xGKeZBURpdBvi.IuhZBCCosvej/XI3RlPqYsoAb2id8V2","aes_key":"GBKZZ+kmXqb0QEXac9AJZuaAjCykb2m4W+aPNHp4V0Q=","files":[]},{"name":"900038231","password":"$2a$10$8l1ZBBG.fzHVn6XryuXrfemqgBJ/cZXnbNuiGX/iGLOIVXr7dQ1OW","aes_key":"I3jt+93WG5f5nsbyMeBNBS39RRTq03AVeTs2x7wRzew=","files":[]},{"name":"900018980","password":"$2a$10$Z0KO/nc6NliGbFSKNyiGVeEaFTlwIERr6gZEJ3AehC8F3GbKaU2M2","aes_key":"Bxoonmos9zTStu8xoZJ3alsySjXztU1e5km07J8XHbE=","files":[]},{"name":"900031619","password":"$2a$10$/lLbtuR8354764g6MWJgP.yxMQyapwm/wj.n21bUgG.ABlkSoiaKK","aes_key":"m0FlcdCIsTbz/3OSWwr535jozKLYizddIBBgkjG7Bf0=","files":[]},{"name":"123456789","password":"$2a$10$zYzJHeUZXcLPCbeHcvVeGuXxFLAyu6QuPl243M6Jdm1LJzq5RzmuW","aes_key":"D22bldMnDxgR1YWEdzcSNqG0Jqwi5AWlcFKZhuH9/jk=","files":[]},{"name":"900033729","password":"$2a$10$/xovzQW0k.i/91z9AtyKuOaz./XEYJantFER3uPxeFvNvuE6rQzv.","aes_key":"j/CCk8TH0TZ96SyA+R76bAJP9l5sx4hXFrGKQ1+Eixo=","files":[]},{"name":"900015602","password":"$2a$10$48WmUiwoOafmyq74jTcj1uC3Q3Pccl7B1LEBxZMwz.Chj9P0hvIgu","aes_key":"eKGrhHdsHodSubNDWXG1IxrkdZO7MjHD317qLxnmQB8=","files":[]},{"name":"900030864","password":"$2a$10$VHHHic9iaMGQAQvwlEHhfOed0kIt1Im2SiD7wrtOuzl5ZbeTzqNJK","aes_key":"i5yTL2okyVTKkxaHYSB6JeG3o+v4HkIBohFyCYeraBI=","files":[]},{"name":"900013901","password":"$2a$10$aFYP84tfEmRrbOHZf6wTou8NFlVynOSmeYTNKo0kZqPFUMc.IN1uq","aes_key":"0Bk+UvERHWZX8t5pRnN0adX89rR9QQBrFkW+g50NzgY=","files":[]},{"name":"900021093","password":"$2a$10$1Vf4XUaH8qZrVV7U3ynUD.8AJyqvXaGFYA/XPNrNShznAxfrM9UB2","aes_key":"18Hlf3PsCzAO4MawJdZONENW3n1QLeUp0DtlFP6tzz8=","files":[]},{"name":"900042724","password":"$2a$10$QmWBlwkP.K08mY4XDf8WmOxepXvpBWOGpqrNrPQuRbK8fklUw9V5q","aes_key":"d+Ts4ri4hFbZdO3HXfza4ycAHDq0YdxBQ503DsC24CE=","files":[]},{"name":"900028534","password":"$2a$10$HUFfWTMSWay1EL5t1uidSe58GPREvavjN1SsDo/4CM58WWo1obiX2","aes_key":"ZikM2g8iTS5vLsENkcespYlEQhgQFpBW5k1CFifXZpo=","files":[]},{"name":"90006184","password":"$2a$10$GslCWOSL1znNJYR80xbvIuoDmaWN2FoNmk1fzqfhXdHJgOsRIU2F.","aes_key":"iCgLxd7w3XFHVeoldSuyrlRierCkiD1F33QaQqQ+RV8=","files":[]},{"name":"900043975","password":"$2a$10$C7aaCyVoga63NhQRFvNT0uZmw/i5nQZkl.kYzQE7m99OtEMMoz03e","aes_key":"t5J/WIryBVIaxuxhsnlGJtNdd13TD/+JiJ703TxJQbI=","files":[]},{"name":"900026119","password":"$2a$10$Uu8hTLKJ6laJk4Hnxqw6rOcbws.MK4mSHvGhGSsfNgVoIAeACz302","aes_key":"Yt9OFnVdL4Q6OrGPL3JJbsMydZ3mpLR8FLip5Y5asBw=","files":[]},{"name":"900049525","password":"$2a$10$91Yhg.if8Cb/6iVeh7Hq2.WJq7PGDaZBWlJZ5nQihrokBqfVcaHQ6","aes_key":"CjA40gwN/NgmlTbgAVJwGbIK4lQTpHKLfqFoY4eYabI=","files":[]},{"name":"900049924","password":"$2a$10$ahfO42ImHO8n9CM6HzvUBuv7GoVx2U29aPo2w/6YBlfkd97oD0B0G","aes_key":"iioHKN0vMqrI2q/42ho3Wz99CKOYhVUwg+KvL0hp16Y=","files":[]},{"name":"900049517","password":"$2a$10$8IQr27MBkYZI0Fvh9UBwvekTM6PYsbRK4BJS/TweSYC3XdPyDEk0e","aes_key":"WgcV03geOWoVsE29g3zJeM44r9sK6HqoRK4qLwQ9jyQ=","files":[]}]} \ No newline at end of file diff --git a/app/src/test/java/lightcontainer/storage/RepositoryTests.java b/app/src/test/java/lightcontainer/storage/RepositoryTests.java index 7b07bbc..4880790 100644 --- a/app/src/test/java/lightcontainer/storage/RepositoryTests.java +++ b/app/src/test/java/lightcontainer/storage/RepositoryTests.java @@ -20,7 +20,7 @@ public class RepositoryTests { try { Files.deleteIfExists(Paths.get("src", "test", "resources", "test.json").toAbsolutePath()); } catch (IOException e) { - System.out.println("Error while destroying file"); + Log.getInstance().infoln("Error while destroying file"); } }