- Suppression des Sysout

- Ajout class de Log
- Suppression des main non-utilisés
This commit is contained in:
Benjamin 2022-03-20 14:16:44 +01:00
parent 3fe127b497
commit 82818f3c94
23 changed files with 69 additions and 122 deletions

View File

@ -3,6 +3,7 @@ package lightcontainer.domains;
import lightcontainer.domains.client.Context; import lightcontainer.domains.client.Context;
import lightcontainer.enumerations.TaskStatus; import lightcontainer.enumerations.TaskStatus;
import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.ProtocolWriter;
import lightcontainer.utils.Log;
/** /**
* Une tâche exécutable * Une tâche exécutable
@ -43,7 +44,6 @@ public class Task {
* @return TRUE si le client doit recevoir cette réponse. * @return TRUE si le client doit recevoir cette réponse.
*/ */
public boolean isResponseOfClient(String storeDomain) { public boolean isResponseOfClient(String storeDomain) {
System.out.println(status + " - " + context.getDomain() + " | " + storeDomain);
return (status == TaskStatus.PROCESSING && context.getDomain().equals(storeDomain)); return (status == TaskStatus.PROCESSING && context.getDomain().equals(storeDomain));
} }

View File

@ -9,6 +9,7 @@ import lightcontainer.protocol.rules.reader.SigninRule;
import lightcontainer.protocol.rules.reader.SignoutRule; import lightcontainer.protocol.rules.reader.SignoutRule;
import lightcontainer.protocol.rules.reader.SignupRule; import lightcontainer.protocol.rules.reader.SignupRule;
import lightcontainer.protocol.rules.writer.SignErrorRule; import lightcontainer.protocol.rules.writer.SignErrorRule;
import lightcontainer.utils.Log;
import java.io.IOException; import java.io.IOException;
import java.net.Socket; import java.net.Socket;
@ -58,7 +59,7 @@ public class ClientHandler extends UnicastThread implements AutoCloseable {
try { try {
String command = this.readLine(); String command = this.readLine();
if (command != null) { if (command != null) {
System.out.println("Client: " + command); Log.getInstance().infoln("Client: " + command);
} else { } else {
this.repository.disconnect(this); this.repository.disconnect(this);
break; break;
@ -73,7 +74,6 @@ public class ClientHandler extends UnicastThread implements AutoCloseable {
if (checkAccess(ruleResult)) { if (checkAccess(ruleResult)) {
// Lecture du fichier client // Lecture du fichier client
ruleResult.read(this.getInputStream()); ruleResult.read(this.getInputStream());
System.out.println(getContext().getLogin() + " - " + 1);
ProtocolWriter.ProtocolResult writerCommand = ruleResult.getResultCommand(); ProtocolWriter.ProtocolResult writerCommand = ruleResult.getResultCommand();
// TODO : Vérifier que le StorBackEnd demandé (Pas toujours demandé) est disponible // TODO : Vérifier que le StorBackEnd demandé (Pas toujours demandé) est disponible
if (ruleResult.getReceiver() == ProtocolReader.ResultCmdReceiver.STOREBACKEND && !fileFrontEnd.canExecuteCommand(ruleResult.getRequestDomain())) { if (ruleResult.getReceiver() == ProtocolReader.ResultCmdReceiver.STOREBACKEND && !fileFrontEnd.canExecuteCommand(ruleResult.getRequestDomain())) {
@ -181,9 +181,9 @@ public class ClientHandler extends UnicastThread implements AutoCloseable {
try { try {
super.close(); super.close();
this.repository.disconnect(this); 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) { } catch (IOException e) {
System.out.println("[CH] Error while closing client."); Log.getInstance().infoln("[CH] Error while closing client.");
} }
} }
} }

View File

@ -4,6 +4,7 @@ import lightcontainer.interfaces.ProtocolRepository;
import lightcontainer.interfaces.StoreProcessorFFE; import lightcontainer.interfaces.StoreProcessorFFE;
import lightcontainer.protocol.ProtocolReader; import lightcontainer.protocol.ProtocolReader;
import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.ProtocolWriter;
import lightcontainer.utils.Log;
import java.io.IOException; import java.io.IOException;
import java.net.Socket; 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 if (protocolResult == null) { // Si on n'a pas encore la commande à envoyer
waitAction(); waitAction();
} }
System.out.println("[SBE] Envoie commande : " + protocolResult.getCommand()); Log.getInstance().infoln("[SBE] Envoie commande : " + protocolResult.getCommand());
// Request // Request
this.write(protocolResult.getCommand()); this.write(protocolResult.getCommand());
@ -74,23 +75,23 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable {
responseCommand += "\r\n"; responseCommand += "\r\n";
ProtocolReader.ProtocolResult responseResult = protocolRep.executeReader(getContext(), responseCommand); ProtocolReader.ProtocolResult responseResult = protocolRep.executeReader(getContext(), responseCommand);
if (responseResult != null) { 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( responseResult.read(
this.getInputStream() this.getInputStream()
); );
alertAvailable(responseResult.getResultCommand()); alertAvailable(responseResult.getResultCommand());
} else { } else {
System.out.println("StoreBackEnd result: Commande null"); Log.getInstance().infoln("StoreBackEnd result: Commande null");
alertAvailable(null); alertAvailable(null);
} }
} else { } else {
System.out.println("StoreBackEnd: Commande null"); Log.getInstance().infoln("StoreBackEnd: Commande null");
alertAvailable(null); alertAvailable(null);
} }
} catch (IOException exception) { } 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(); this.close();
} }
} }
@ -100,7 +101,7 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable {
this.close(); this.close();
this.fileFrontEnd.onStoreDisconnect(this.domain); this.fileFrontEnd.onStoreDisconnect(this.domain);
} catch (Exception e) { } 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() { public void close() {
if (this.isRunning()) { if (this.isRunning()) {
this.setRunning(false); this.setRunning(false);
System.out.println("[SBE] Fermeture de " + domain); Log.getInstance().infoln("[SBE] Fermeture de " + domain);
} }
} }

View File

@ -6,6 +6,7 @@ import lightcontainer.interfaces.ProtocolRepository;
import lightcontainer.protocol.ProtocolReader; import lightcontainer.protocol.ProtocolReader;
import lightcontainer.protocol.rules.reader.HelloRule; import lightcontainer.protocol.rules.reader.HelloRule;
import lightcontainer.repository.FileFrontEnd; import lightcontainer.repository.FileFrontEnd;
import lightcontainer.utils.Log;
import lightcontainer.utils.NetChooser; import lightcontainer.utils.NetChooser;
import java.io.IOException; import java.io.IOException;
@ -74,16 +75,17 @@ public class MulticastServerListener implements Runnable {
onNewSbe(packet); onNewSbe(packet);
} }
} catch (IOException ioException) { } 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) { private void onNewSbe(DatagramPacket packet) {
try { try {
String data = new String(packet.getData(), 0, packet.getLength()); String data = new String(packet.getData(), 0, packet.getLength());
HelloRule.Result readerResult = protocolRep.executeReader(null, data); 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())){ if (!this.repository.hasDomain(readerResult.getDomain())){
Socket socket = new Socket(packet.getAddress(), readerResult.getPort()); 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é // Contient déjà le SBE donc maj de la dernière activité
this.repository.updateLastAnnounce(readerResult.getDomain()); this.repository.updateLastAnnounce(readerResult.getDomain());
} catch (IOException | ClassCastException exception) { } 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());
} }
} }

View File

@ -1,6 +1,7 @@
package lightcontainer.protocol; package lightcontainer.protocol;
import lightcontainer.domains.client.Context; import lightcontainer.domains.client.Context;
import lightcontainer.utils.Log;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -83,7 +84,7 @@ public abstract class ProtocolWriter {
String command = builder + "\r\n"; 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 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()) { if (ruleMatcher.matches()) {
ProtocolResult result = onExecuted(context, data); ProtocolResult result = onExecuted(context, data);
result.setCommand(command); result.setCommand(command);

View File

@ -6,6 +6,7 @@ import lightcontainer.protocol.ProtocolReader;
import lightcontainer.protocol.rules.writer.GetFileErrorRule; import lightcontainer.protocol.rules.writer.GetFileErrorRule;
import lightcontainer.protocol.rules.writer.GetFileOkRule; import lightcontainer.protocol.rules.writer.GetFileOkRule;
import lightcontainer.utils.FileReceiver; import lightcontainer.utils.FileReceiver;
import lightcontainer.utils.Log;
import lightcontainer.utils.SHA; import lightcontainer.utils.SHA;
import java.io.InputStream; import java.io.InputStream;
@ -60,7 +61,7 @@ public class RetrieveOkRule extends ProtocolReader {
@Override @Override
public void read(InputStream reader) { public void read(InputStream reader) {
super.read(reader); super.read(reader);
System.out.println("Récupération du fichier du SBE");
try { try {
FileReceiver fileReceiver = new FileReceiver(storagePath); FileReceiver fileReceiver = new FileReceiver(storagePath);
if (!fileReceiver.receiveFile(reader, this.filename, this.filesize)) { if (!fileReceiver.receiveFile(reader, this.filename, this.filesize)) {

View File

@ -47,13 +47,11 @@ public class SavefileRule extends ProtocolReader {
super(context); super(context);
this.filename = filename; this.filename = filename;
this.size = size; this.size = size;
System.out.println(size);
} }
@Override @Override
public void read(InputStream reader) { public void read(InputStream reader) {
super.read(reader); super.read(reader);
System.out.printf("Sauvegarde du fichier : %s %d\n", filename, size);
if (getContext().canAddFile()) { if (getContext().canAddFile()) {
try { try {
@ -75,8 +73,6 @@ public class SavefileRule extends ProtocolReader {
long encryptedFileSize = fileReceiver.receiveFile(reader, this.filename, this.size, key, iv); long encryptedFileSize = fileReceiver.receiveFile(reader, this.filename, this.size, key, iv);
if (encryptedFileSize < 0) throw new IOException(); if (encryptedFileSize < 0) throw new IOException();
System.out.println(encryptedFileSize);
String fileHash = SHA.hashFile(storagePath, this.filename); String fileHash = SHA.hashFile(storagePath, this.filename);
// On met les données de la requête actuelle // On met les données de la requête actuelle

View File

@ -2,6 +2,7 @@ package lightcontainer.protocol.rules.writer;
import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.ProtocolWriter;
import lightcontainer.protocol.StandardizedDefinitions; import lightcontainer.protocol.StandardizedDefinitions;
import lightcontainer.utils.Log;
import static lightcontainer.protocol.StandardizedDefinitions.FFE_ERASE_FILE; import static lightcontainer.protocol.StandardizedDefinitions.FFE_ERASE_FILE;
@ -15,6 +16,5 @@ public class EraseFileRule extends ProtocolWriter {
public EraseFileRule() { public EraseFileRule() {
super(NAME, PATTERN); super(NAME, PATTERN);
System.out.println(PATTERN);
} }
} }

View File

@ -4,6 +4,7 @@ import lightcontainer.domains.client.Context;
import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.ProtocolWriter;
import lightcontainer.utils.DeepFileEraser; import lightcontainer.utils.DeepFileEraser;
import lightcontainer.utils.FileSender; import lightcontainer.utils.FileSender;
import lightcontainer.utils.Log;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -47,9 +48,6 @@ public class GetFileOkRule extends ProtocolWriter {
*/ */
@Override @Override
public void write(OutputStream writer) throws IOException { 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 fileSender = new FileSender(storagePath);
fileSender.sendFile( fileSender.sendFile(
getContext().getDataString("hashedFileName"), getContext().getDataString("hashedFileName"),

View File

@ -3,6 +3,7 @@ package lightcontainer.protocol.rules.writer;
import lightcontainer.domains.client.Context; import lightcontainer.domains.client.Context;
import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.ProtocolWriter;
import lightcontainer.utils.DeepFileEraser; import lightcontainer.utils.DeepFileEraser;
import lightcontainer.utils.Log;
import static lightcontainer.protocol.StandardizedDefinitions.FFE_SAVE_FILE_OK; 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) { protected ProtocolWriter.ProtocolResult onExecuted(Context context, String... data) {
ProtocolWriter.ProtocolResult result = new ProtocolWriter.ProtocolResult(context); ProtocolWriter.ProtocolResult result = new ProtocolWriter.ProtocolResult(context);
System.out.println("===> Save en json " + context.getDomain() + " - " + context.getLogin());
// Sauvegarder dans JSON // Sauvegarder dans JSON
context.addFile(context.getDataString("fileName"), context.getDataString("fileNameSalt"), context.getDataLong("size"), context.getDataString("iv"), context.getDomain()); context.addFile(context.getDataString("fileName"), context.getDataString("fileNameSalt"), context.getDataLong("size"), context.getDataString("iv"), context.getDomain());

View File

@ -4,6 +4,7 @@ import lightcontainer.domains.client.Context;
import lightcontainer.protocol.ProtocolWriter; import lightcontainer.protocol.ProtocolWriter;
import lightcontainer.protocol.StandardizedDefinitions; import lightcontainer.protocol.StandardizedDefinitions;
import lightcontainer.utils.FileSender; import lightcontainer.utils.FileSender;
import lightcontainer.utils.Log;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -46,7 +47,6 @@ public class SendfileRule extends ProtocolWriter {
@Override @Override
public void write(OutputStream writer) throws IOException { public void write(OutputStream writer) throws IOException {
super.write(writer); super.write(writer);
System.out.println("Envoie du fichier au SBE");
FileSender fileSender = new FileSender(storagePath); FileSender fileSender = new FileSender(storagePath);
fileSender.sendFile(hashedFileName, writer); fileSender.sendFile(hashedFileName, writer);

View File

@ -1,5 +1,7 @@
package lightcontainer.storage; package lightcontainer.storage;
import lightcontainer.utils.Log;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -194,7 +196,6 @@ public class AppData {
*/ */
public boolean verifyUser(String login, String password) { public boolean verifyUser(String login, String password) {
User user = getUser(login); User user = getUser(login);
System.out.println("OKOKOK " + password + " ok " + user);
return user != null && user.verifyPassword(password); return user != null && user.verifyPassword(password);
} }

View File

@ -1,6 +1,7 @@
package lightcontainer.storage; package lightcontainer.storage;
import com.google.gson.*; import com.google.gson.*;
import lightcontainer.utils.Log;
import java.util.*; import java.util.*;
@ -97,7 +98,7 @@ public class JsonAdapter implements Adapter {
} }
return appData; return appData;
} catch (JsonParseException parseException) { } 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; return null;
} }
} }

View File

@ -1,5 +1,7 @@
package lightcontainer.storage; package lightcontainer.storage;
import lightcontainer.utils.Log;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.IOException; import java.io.IOException;
@ -35,7 +37,7 @@ public class Repository {
bufferedWriter.write(jsonAppData); bufferedWriter.write(jsonAppData);
bufferedWriter.flush(); bufferedWriter.flush();
} catch (IOException e) { } 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()); builder.append(reader.readLine());
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println("Error while reading configuration file"); Log.getInstance().infoln("Error while reading configuration file");
builder.setLength(0); builder.setLength(0);
} }
return builder.toString(); return builder.toString();

View File

@ -1,6 +1,7 @@
package lightcontainer.storage; package lightcontainer.storage;
import lightcontainer.utils.BCryptHasher; import lightcontainer.utils.BCryptHasher;
import lightcontainer.utils.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -27,7 +28,6 @@ public class User {
this.password = password; this.password = password;
this.aesKey = aesKey; this.aesKey = aesKey;
this.files = files; this.files = files;
System.out.println(files.size() + " fichiers trouvéssss pour " + name);
} }
public String getName() { public String getName() {

View File

@ -21,58 +21,6 @@ public class AES_GCM {
public static final int GCM_IV_LENGTH = 16; public static final int GCM_IV_LENGTH = 16;
public static final int GCM_TAG_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 )
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. * Decoder to decode base64 vector to byte vector.

View File

@ -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_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 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. * Generate a number randomly.

View File

@ -12,7 +12,6 @@ public class FileSender {
public boolean sendFile(String filename, OutputStream out, long fileSize, String aesKey, String iv) throws IOException { public boolean sendFile(String filename, OutputStream out, long fileSize, String aesKey, String iv) throws IOException {
BufferedInputStream bisFile; BufferedInputStream bisFile;
System.out.printf("Envoie fichier : %s - %s - %s \n", filename, aesKey, iv);
try { try {
File f = new File(String.format("%s/%s", path, filename)); File f = new File(String.format("%s/%s", path, filename));
if (f.exists()) { if (f.exists()) {

View File

@ -1,10 +1,35 @@
package lightcontainer.utils; package lightcontainer.utils;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
public class Log { 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;
}
} }

View File

@ -19,11 +19,11 @@ public class NetChooser {
Scanner console = new Scanner(System.in); Scanner console = new Scanner(System.in);
String[] allInterfaceNames = getInterfaces(); String[] allInterfaceNames = getInterfaces();
for (int index = 0; index < allInterfaceNames.length; ++index) { 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()); 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; return selected;
} }
@ -66,7 +66,4 @@ public class NetChooser {
return null; return null;
} }
public static void main(String[] args) {
new NetChooser();
}
} }

View File

@ -21,22 +21,6 @@ public class SHA {
// Constants // Constants
public static final String SHA_VERSION = "SHA-256"; 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. * Make a borrowing of the stream.

View File

@ -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":[]}]} {"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":[]}]}

View File

@ -20,7 +20,7 @@ public class RepositoryTests {
try { try {
Files.deleteIfExists(Paths.get("src", "test", "resources", "test.json").toAbsolutePath()); Files.deleteIfExists(Paths.get("src", "test", "resources", "test.json").toAbsolutePath());
} catch (IOException e) { } catch (IOException e) {
System.out.println("Error while destroying file"); Log.getInstance().infoln("Error while destroying file");
} }
} }