Regex : modif
This commit is contained in:
parent
dd033fd19c
commit
b3fc637914
@ -1,6 +1,5 @@
|
|||||||
package lightcontainer.domains.client;
|
package lightcontainer.domains.client;
|
||||||
|
|
||||||
import lightcontainer.domains.server.UnicastServerListener;
|
|
||||||
import lightcontainer.interfaces.ClientHandlerFFE;
|
import lightcontainer.interfaces.ClientHandlerFFE;
|
||||||
import lightcontainer.interfaces.ProtocolRepository;
|
import lightcontainer.interfaces.ProtocolRepository;
|
||||||
import lightcontainer.interfaces.UnicastCHR;
|
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.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.protocol.rules.writer.SignOkRule;
|
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
|
||||||
import javax.net.ssl.SSLHandshakeException;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClientHandler
|
* ClientHandler
|
||||||
*
|
* <p>
|
||||||
* <!> UNICAST CLIENT <!>
|
* <!> UNICAST CLIENT <!>
|
||||||
* Class communicating with the client, and
|
* Class communicating with the client, and
|
||||||
* intercepting and sending files to the client.
|
* intercepting and sending files to the client.
|
||||||
*
|
*
|
||||||
|
* @author Jérémi NIHART <j.nihart@student.helmo.be>
|
||||||
* @version 1.1
|
* @version 1.1
|
||||||
* @since 1.0
|
|
||||||
*
|
|
||||||
* @see Runnable
|
* @see Runnable
|
||||||
* @see AutoCloseable
|
* @see AutoCloseable
|
||||||
* @author Jérémi NIHART <j.nihart@student.helmo.be>
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class ClientHandler implements Runnable, AutoCloseable {
|
public class ClientHandler implements Runnable, AutoCloseable {
|
||||||
// Variables
|
// Variables
|
||||||
@ -60,10 +55,9 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
|||||||
/**
|
/**
|
||||||
* Initialise the Client's Reader and Writer.
|
* Initialise the Client's Reader and Writer.
|
||||||
*
|
*
|
||||||
* @since 1.0
|
|
||||||
*
|
|
||||||
* @see BufferedReader
|
* @see BufferedReader
|
||||||
* @see PrintWriter
|
* @see PrintWriter
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
private void initClient() {
|
private void initClient() {
|
||||||
// Start the thread
|
// Start the thread
|
||||||
@ -153,11 +147,13 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
|||||||
this.writer.close();
|
this.writer.close();
|
||||||
this.client.close();
|
this.client.close();
|
||||||
System.out.printf("[CLIENT] %s s'est déconnecté\n", context.getLogin());
|
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é
|
* Permet de vérifier si le client possède l'accès demandé
|
||||||
|
*
|
||||||
* @param ruleResult La règle
|
* @param ruleResult La règle
|
||||||
* @return TRUE si le client possède l'accès demandé
|
* @return TRUE si le client possède l'accès demandé
|
||||||
*/
|
*/
|
||||||
@ -175,7 +171,8 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
|||||||
try {
|
try {
|
||||||
ruleResult.getClass().asSubclass(SigninRule.Result.class);
|
ruleResult.getClass().asSubclass(SigninRule.Result.class);
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassCastException e2) { }
|
} catch (ClassCastException e2) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -193,13 +190,15 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Vérifie s'il s'âgit d'une demande de déconnexion
|
* Vérifie s'il s'âgit d'une demande de déconnexion
|
||||||
|
*
|
||||||
* @param ruleResult
|
* @param ruleResult
|
||||||
*/
|
*/
|
||||||
private void checkSignout(ProtocolReader.ProtocolResult ruleResult) {
|
private void checkSignout(ProtocolReader.ProtocolResult ruleResult) {
|
||||||
try {
|
try {
|
||||||
ruleResult.getClass().asSubclass(SignoutRule.Result.class);
|
ruleResult.getClass().asSubclass(SignoutRule.Result.class);
|
||||||
repository.disconnect(this);
|
repository.disconnect(this);
|
||||||
} catch (ClassCastException e2) { }
|
} catch (ClassCastException e2) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,12 +219,15 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
this.wait();
|
this.wait();
|
||||||
} catch (InterruptedException e) { e.printStackTrace(); }
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permet d'envoyer la réponse au client.
|
* Permet d'envoyer la réponse au client.
|
||||||
|
*
|
||||||
* @param response La réponse
|
* @param response La réponse
|
||||||
*/
|
*/
|
||||||
public void respond(ProtocolWriter.ProtocolResult response) {
|
public void respond(ProtocolWriter.ProtocolResult response) {
|
||||||
|
@ -5,7 +5,7 @@ public class StandardizedDefinitions {
|
|||||||
//Parties de regex non-utilisées en dehors de cette classe.
|
//Parties de regex non-utilisées en dehors de cette classe.
|
||||||
private final static String DIGIT = "[\\x30-\\x39]";
|
private final static String DIGIT = "[\\x30-\\x39]";
|
||||||
private final static String VISIBLECHAR = "[\\x20-\\xFF]";
|
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 BINARY = "[\\x00-\\xFF]";
|
||||||
private final static String LETTER = "[\\x41-\\x5A\\x61-\\x7A]";
|
private final static String LETTER = "[\\x41-\\x5A\\x61-\\x7A]";
|
||||||
private final static String DIGIT_LETTER = "[\\x30-\\x39\\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);
|
super(context);
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
System.out.println(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,6 +76,8 @@ public class SavefileRule extends ProtocolReader {
|
|||||||
int encryptedFileSize = fileReceiver.receiveFile(reader, this.filename, this.size, key, iv);
|
int 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
|
||||||
|
@ -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