Regex : modif
This commit is contained in:
parent
dd033fd19c
commit
b3fc637914
@ -1,6 +1,5 @@
|
||||
package lightcontainer.domains.client;
|
||||
|
||||
import lightcontainer.domains.server.UnicastServerListener;
|
||||
import lightcontainer.interfaces.ClientHandlerFFE;
|
||||
import lightcontainer.interfaces.ProtocolRepository;
|
||||
import lightcontainer.interfaces.UnicastCHR;
|
||||
@ -10,27 +9,23 @@ 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.protocol.rules.writer.SignOkRule;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import java.io.*;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* ClientHandler
|
||||
*
|
||||
* <p>
|
||||
* <!> UNICAST CLIENT <!>
|
||||
* Class communicating with the client, and
|
||||
* intercepting and sending files to the client.
|
||||
*
|
||||
* @author Jérémi NIHART <j.nihart@student.helmo.be>
|
||||
* @version 1.1
|
||||
* @since 1.0
|
||||
*
|
||||
* @see Runnable
|
||||
* @see AutoCloseable
|
||||
* @author Jérémi NIHART <j.nihart@student.helmo.be>
|
||||
* @since 1.0
|
||||
*/
|
||||
public class ClientHandler implements Runnable, AutoCloseable {
|
||||
// Variables
|
||||
@ -60,10 +55,9 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
||||
/**
|
||||
* Initialise the Client's Reader and Writer.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @see BufferedReader
|
||||
* @see PrintWriter
|
||||
* @since 1.0
|
||||
*/
|
||||
private void initClient() {
|
||||
// Start the thread
|
||||
@ -153,11 +147,13 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
||||
this.writer.close();
|
||||
this.client.close();
|
||||
System.out.printf("[CLIENT] %s s'est déconnecté\n", context.getLogin());
|
||||
} catch (IOException ignored) { }
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de vérifier si le client possède l'accès demandé
|
||||
*
|
||||
* @param ruleResult La règle
|
||||
* @return TRUE si le client possède l'accès demandé
|
||||
*/
|
||||
@ -175,7 +171,8 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
||||
try {
|
||||
ruleResult.getClass().asSubclass(SigninRule.Result.class);
|
||||
return true;
|
||||
} catch (ClassCastException e2) { }
|
||||
} catch (ClassCastException e2) {
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -193,13 +190,15 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
||||
|
||||
/**
|
||||
* Vérifie s'il s'âgit d'une demande de déconnexion
|
||||
*
|
||||
* @param ruleResult
|
||||
*/
|
||||
private void checkSignout(ProtocolReader.ProtocolResult ruleResult) {
|
||||
try {
|
||||
ruleResult.getClass().asSubclass(SignoutRule.Result.class);
|
||||
repository.disconnect(this);
|
||||
} catch (ClassCastException e2) { }
|
||||
} catch (ClassCastException e2) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,12 +219,15 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
||||
synchronized (this) {
|
||||
try {
|
||||
this.wait();
|
||||
} catch (InterruptedException e) { e.printStackTrace(); }
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'envoyer la réponse au client.
|
||||
*
|
||||
* @param response La réponse
|
||||
*/
|
||||
public void respond(ProtocolWriter.ProtocolResult response) {
|
||||
|
@ -5,7 +5,7 @@ public class StandardizedDefinitions {
|
||||
//Parties de regex non-utilisées en dehors de cette classe.
|
||||
private final static String DIGIT = "[\\x30-\\x39]";
|
||||
private final static String VISIBLECHAR = "[\\x20-\\xFF]";
|
||||
private final static String PASSCHAR = "[\\x20-\\xFF]";
|
||||
private final static String PASSCHAR = "[\\x22-\\xFF]";
|
||||
private final static String BINARY = "[\\x00-\\xFF]";
|
||||
private final static String LETTER = "[\\x41-\\x5A\\x61-\\x7A]";
|
||||
private final static String DIGIT_LETTER = "[\\x30-\\x39\\x41-\\x5A\\x61-\\x7A]";
|
||||
|
@ -48,6 +48,7 @@ public class SavefileRule extends ProtocolReader {
|
||||
super(context);
|
||||
this.filename = filename;
|
||||
this.size = size;
|
||||
System.out.println(size);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,6 +76,8 @@ public class SavefileRule extends ProtocolReader {
|
||||
int 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
|
||||
|
@ -1 +1,17 @@
|
||||
{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"Wi-Fi","tls":true,"storagePath":"C:\\Users\\ledou\\Documents\\ffe","users":[{"name":"aaaaa","password":"$2a$10$.nNfX6PkXw34xsA8n2mSlekmRIQ/cU0wUlbnJmvfwGxtivMFJroXe","aes_key":"nfwaw3k6SpbvzAkzYDoVwcak8SHdRn+jQ8fY3iEmXPg=","files":[{"name":"test.txt","fileNameSalt":"jW4uvNQxRB36d0CL+/68uA==","size":53,"iv":"sSZkzD1gcrJscFR4gMoNFQ==","storage":["orglightcont01"]}]}]}
|
||||
{
|
||||
"unicast_port": 8000,
|
||||
"multicast_ip": "224.66.66.1",
|
||||
"multicast_port": 15502,
|
||||
"network_interface": "",
|
||||
"tls": true,
|
||||
"storagePath": "C:\\Users\\ledou\\Documents\\ffe",
|
||||
"users": [
|
||||
{
|
||||
"name": "aaaaa",
|
||||
"password": "$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W",
|
||||
"aes_key": "kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=",
|
||||
"files": [
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user