- Réparation problème causé par benja qui causait l'impossibilité d'avoir plus de 1 fichier par personne
- Suppression nom du fichier hashé dans le config car cause problème et innutile
This commit is contained in:
parent
07f87d40e5
commit
8965f0d51b
@ -173,7 +173,7 @@ public class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getStringifiedFilesOf() {
|
public List<String> getStringifiedFilesOf() {
|
||||||
return repository.load().getStringifiedFilesOf(login);
|
return repository.getStringifiedFilesOf(login);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAddFile() {
|
public boolean canAddFile() {
|
||||||
|
@ -76,7 +76,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("Essaye : " + command);
|
||||||
if (ruleMatcher.matches()) {
|
if (ruleMatcher.matches()) {
|
||||||
ProtocolResult result = onExecuted(context, data);
|
ProtocolResult result = onExecuted(context, data);
|
||||||
result.setCommand(command);
|
result.setCommand(command);
|
||||||
|
@ -46,4 +46,9 @@ public class FilelistRule extends ProtocolReader {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <T extends ProtocolResult> T onError(Context context) {
|
||||||
|
return super.onError(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ public class SavefileRule extends ProtocolReader {
|
|||||||
if (getContext().canAddFile()) {
|
if (getContext().canAddFile()) {
|
||||||
try {
|
try {
|
||||||
FileReceiver fileReceiver = new FileReceiver(storagePath);
|
FileReceiver fileReceiver = new FileReceiver(storagePath);
|
||||||
|
getContext().putDataString("fileName", this.filename);
|
||||||
|
|
||||||
// Ajout login devant le nom du fichier
|
// Ajout login devant le nom du fichier
|
||||||
this.filename = getContext().getLogin() + "_" + this.filename;
|
this.filename = getContext().getLogin() + "_" + this.filename;
|
||||||
@ -78,7 +79,6 @@ public class SavefileRule extends ProtocolReader {
|
|||||||
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
|
||||||
getContext().putDataString("fileName", filename);
|
|
||||||
getContext().putDataInt("size", size);
|
getContext().putDataInt("size", size);
|
||||||
getContext().putDataString("iv", iv);
|
getContext().putDataString("iv", iv);
|
||||||
getContext().putDataString("fileNameSalt", fileNameSalt);
|
getContext().putDataString("fileNameSalt", fileNameSalt);
|
||||||
|
@ -31,6 +31,7 @@ public class ProtocolRepositoryImpl implements ProtocolRepository {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("COMMANDE NULL");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,20 @@ public class AppData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method when a user signs up.
|
||||||
|
*
|
||||||
|
* @return True if the user was added. False if a user with the same name already exists.
|
||||||
|
*/
|
||||||
|
public boolean addUser(User user) {
|
||||||
|
if (this.users.containsKey(user.getName())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.users.put(user.getName(), user);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canAddFile(String login) {
|
public boolean canAddFile(String login) {
|
||||||
if (this.users.containsKey(login)) {
|
if (this.users.containsKey(login)) {
|
||||||
return this.users.get(login).canAddFile();
|
return this.users.get(login).canAddFile();
|
||||||
@ -178,4 +192,5 @@ public class AppData {
|
|||||||
User user = getUser(login);
|
User user = getUser(login);
|
||||||
return user == null ? null : user.getAesKey();
|
return user == null ? null : user.getAesKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class JsonAdapter implements Adapter {
|
|||||||
AppData appData = AppData.getInstance();
|
AppData appData = AppData.getInstance();
|
||||||
appData.setAppConfig(appConfig);
|
appData.setAppConfig(appConfig);
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
appData.addUser(user.getName(), user.getPassword(), user.getAesKey(), user.getPasswordSalt());
|
appData.addUser(user);
|
||||||
}
|
}
|
||||||
return appData;
|
return appData;
|
||||||
} catch (JsonParseException parseException) {
|
} catch (JsonParseException parseException) {
|
||||||
|
@ -7,6 +7,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Repository {
|
public class Repository {
|
||||||
|
|
||||||
@ -139,4 +140,7 @@ public class Repository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> getStringifiedFilesOf(String login) {
|
||||||
|
return this.appData.getStringifiedFilesOf(login);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ public class User {
|
|||||||
this.aesKey = aesKey;
|
this.aesKey = aesKey;
|
||||||
this.passwordSalt = passwordSalt;
|
this.passwordSalt = passwordSalt;
|
||||||
this.files = files;
|
this.files = files;
|
||||||
|
System.out.println(files.size() + " fichiers trouvéssss pour " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -53,7 +54,7 @@ public class User {
|
|||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
while (fileIterator.hasNext()) {
|
while (fileIterator.hasNext()) {
|
||||||
File file = fileIterator.next();
|
File file = fileIterator.next();
|
||||||
String stringify = " " + file.getName() + "!" + file.getSize();
|
String stringify = file.getName() + "!" + file.getSize();
|
||||||
result.add(stringify);
|
result.add(stringify);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1,24 +1 @@
|
|||||||
{
|
{"unicast_port":8000,"multicast_ip":"226.66.66.1","multicast_port":15502,"network_interface":"My network interface","tls":true,"storagePath":"/home/benjamin/ffe","users":[{"name":"endmove","password":"1f82407cace28cd7d97d23f82e8235d9da97575d033a12334fc71d3517f6a90fa04af829df3c722c38d3b68842e4ca2b","aes_key":"p0G+iViPp656O6aMKgcXSDT/e9/00wQH/ztUWf4tyr4=","passwordSalt":"ItYiXkwPa84Gwb6dGHQvXQ==","files":[]},{"name":"aaaaa","password":"5d628c274ebb008324f1e199d3bfff0a3fe839730a7f2355e82850d7acca5e5ca64db9071abf3d91034295695f84a617","aes_key":"qlTH6TijnfMRnrS0Qf+k6IPKGp5LoRMXGxCq16e+mF4=","passwordSalt":"Ns8Al6DpqPsIDlCSRBVTEg==","files":[{"name":"ca.crt","fileNameSalt":"Mjo7iQeEl2PYX1RDUZbSlQ==","size":4207,"iv":"uALI+Feo1lIg1lBxbCMwIQ==","storage":["lightcontainerSB01"]},{"name":"main.py","fileNameSalt":"YRwnBiXINCJ+zyxwADgNRQ==","size":854,"iv":"9LXrJFtcgU4DeUBghc4Dgw==","storage":["lightcontainerSB01"]}]}]}
|
||||||
"unicast_port": 8000,
|
|
||||||
"multicast_ip": "226.66.66.1",
|
|
||||||
"multicast_port": 15502,
|
|
||||||
"network_interface": "My network interface",
|
|
||||||
"tls": true,
|
|
||||||
"storagePath": "D:\\ffe",
|
|
||||||
"users": [
|
|
||||||
{
|
|
||||||
"name": "endmove",
|
|
||||||
"password": "1f82407cace28cd7d97d23f82e8235d9da97575d033a12334fc71d3517f6a90fa04af829df3c722c38d3b68842e4ca2b",
|
|
||||||
"aes_key": "p0G+iViPp656O6aMKgcXSDT/e9/00wQH/ztUWf4tyr4=",
|
|
||||||
"passwordSalt": "ItYiXkwPa84Gwb6dGHQvXQ==",
|
|
||||||
"files": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "aaaaa",
|
|
||||||
"password": "5d628c274ebb008324f1e199d3bfff0a3fe839730a7f2355e82850d7acca5e5ca64db9071abf3d91034295695f84a617",
|
|
||||||
"aes_key": "qlTH6TijnfMRnrS0Qf+k6IPKGp5LoRMXGxCq16e+mF4=",
|
|
||||||
"passwordSalt": "Ns8Al6DpqPsIDlCSRBVTEg==",
|
|
||||||
"files": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user