Regex : quelques implémentations
This commit is contained in:
parent
1a91271324
commit
5dd70d9bcf
@ -18,7 +18,7 @@ public class StandardizedDefinitions {
|
||||
private final static String DOMAIN = "[a-z-A-Z0-9\\.]{5,20}";
|
||||
private final static String HASH_FILENAME = DIGIT_LETTER + "{50,200}";
|
||||
private final static String HASH_FILECONTENT = DIGIT_LETTER + "{50,200}";
|
||||
private final static String FILE_INFO = HASH_FILENAME + BL + SIZE + BL + HASH_FILECONTENT;
|
||||
private final static String FILE_INFO = "(" + HASH_FILENAME + ")" + BL + "(" + SIZE + ")" + BL + "(" + HASH_FILECONTENT + ")";
|
||||
private final static String LOGIN = DIGIT_LETTER + "{5,20}";
|
||||
|
||||
//Regex à utiliser dans les différents protocoles.
|
||||
@ -33,7 +33,7 @@ public class StandardizedDefinitions {
|
||||
public final static String SBE_ERASE_RESULT_OK = "^ERASE_OK" + LINE + "$";
|
||||
public final static String SBE_ERASE_RESULT_ERROR = "^ERASE_ERROR" + LINE + "$";
|
||||
public final static String FFE_RETRIEVE_FILE = "^RETRIEVEFILE" + BL + HASH_FILENAME + LINE + "$";
|
||||
public final static String SBE_RETRIEVE_RESULT_OK = "^RETRIEVE_OK" + BL + "(" + FILE_INFO + ")" + LINE + "$";
|
||||
public final static String SBE_RETRIEVE_RESULT_OK = "^RETRIEVE_OK" + BL + FILE_INFO + LINE + "$";
|
||||
public final static String SBE_RETRIEVE_RESULT_ERROR = "^RETRIEVE_ERROR" + LINE + "$";
|
||||
|
||||
//Client demande à FFE une tâche. FFE répond à client.
|
||||
|
@ -5,9 +5,11 @@ import lightcontainer.interfaces.ProtocolRepository;
|
||||
import lightcontainer.protocol.ProtocolReader;
|
||||
import lightcontainer.protocol.rules.writer.RemoveFileErrorRule;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.SBE_ERASE_RESULT_ERROR;
|
||||
|
||||
public class EraseErrorRule extends ProtocolReader {
|
||||
|
||||
private static final String PATTERN = "^ERASE_ERROR\r\n$";
|
||||
private static final String PATTERN = SBE_ERASE_RESULT_ERROR;
|
||||
|
||||
private static final String NAME = "ERASE_ERROR";
|
||||
|
||||
|
@ -5,9 +5,11 @@ import lightcontainer.interfaces.ProtocolRepository;
|
||||
import lightcontainer.protocol.ProtocolReader;
|
||||
import lightcontainer.protocol.rules.writer.RemoveFileOkRule;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.SBE_ERASE_RESULT_OK;
|
||||
|
||||
public class EraseOkRule extends ProtocolReader {
|
||||
|
||||
private static final String PATTERN = "^ERASE_OK\r\n$";
|
||||
private static final String PATTERN = SBE_ERASE_RESULT_OK;
|
||||
|
||||
private static final String NAME = "ERASE_OK";
|
||||
|
||||
|
@ -7,12 +7,14 @@ import lightcontainer.protocol.rules.writer.FilesRule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.CLIENT_FILE_LIST;
|
||||
|
||||
/**
|
||||
* Règle permettant de récupérer la liste des fichiers d'un utilisateur
|
||||
*/
|
||||
public class FilelistRule extends ProtocolReader {
|
||||
// Constants
|
||||
private static final String PATTERN = "^FILELIST\r\n$";
|
||||
private static final String PATTERN = CLIENT_FILE_LIST;
|
||||
|
||||
private static final String NAME = "FILELIST";
|
||||
|
||||
|
@ -4,15 +4,16 @@ import lightcontainer.domains.client.Context;
|
||||
import lightcontainer.interfaces.ProtocolRepository;
|
||||
import lightcontainer.protocol.ProtocolReader;
|
||||
import lightcontainer.protocol.rules.writer.GetFileErrorRule;
|
||||
import lightcontainer.protocol.rules.writer.RemoveFileErrorRule;
|
||||
import lightcontainer.protocol.rules.writer.RetrieveFileRule;
|
||||
import lightcontainer.storage.ReadOnlyFile;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.CLIENT_GET_FILE;
|
||||
|
||||
public class GetFileRule extends ProtocolReader {
|
||||
// Constants
|
||||
private static final String PATTERN = "^GETFILE ([^ !]{1,20})\r\n$";
|
||||
private static final String PATTERN = CLIENT_GET_FILE;
|
||||
private static final String NAME = "GETFILE";
|
||||
// -- arguments
|
||||
private static final int FILE_NAME = 0; // Index file name.
|
||||
@ -80,9 +81,11 @@ public class GetFileRule extends ProtocolReader {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** TMP
|
||||
/**
|
||||
* TMP
|
||||
* TODO : But futur est de pouvoir en avoir plusieurs (sbe)
|
||||
* Cette méthode permet de choisir le domaine voulu.
|
||||
*
|
||||
* @param storageIterator Les domaines
|
||||
* @return Le domain choisi
|
||||
*/
|
||||
|
@ -3,12 +3,14 @@ package lightcontainer.protocol.rules.reader;
|
||||
import lightcontainer.domains.client.Context;
|
||||
import lightcontainer.protocol.ProtocolReader;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.SBE_HELLO;
|
||||
|
||||
/**
|
||||
* Règle permettant d'être alerter de l'annoncement d'un SBE
|
||||
*/
|
||||
public class HelloRule extends ProtocolReader {
|
||||
|
||||
private static final String PATTERN = "^HELLO ([A-Za-z0-9]{5,20}) ([0-9]{1,5})\r\n$";
|
||||
private static final String PATTERN = SBE_HELLO;
|
||||
|
||||
private static final String NAME = "HELLO";
|
||||
|
||||
|
@ -9,9 +9,11 @@ import lightcontainer.storage.ReadOnlyFile;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.CLIENT_REMOVE_FILE;
|
||||
|
||||
public class RemoveFileRule extends ProtocolReader {
|
||||
|
||||
private static final String PATTERN = "^REMOVEFILE ([^ !]{1,20})\r\n$";
|
||||
private static final String PATTERN = CLIENT_REMOVE_FILE;
|
||||
|
||||
private static final String NAME = "REMOVEFILE";
|
||||
|
||||
|
@ -5,9 +5,11 @@ import lightcontainer.interfaces.ProtocolRepository;
|
||||
import lightcontainer.protocol.ProtocolReader;
|
||||
import lightcontainer.protocol.rules.writer.GetFileErrorRule;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.SBE_RETRIEVE_RESULT_ERROR;
|
||||
|
||||
public class RetrieveErrorRule extends ProtocolReader {
|
||||
// Constants
|
||||
private static final String PATTERN = "^RETRIEVE_ERROR\r\n$";
|
||||
private static final String PATTERN = SBE_RETRIEVE_RESULT_ERROR;
|
||||
private static final String NAME = "RETRIEVE_ERROR";
|
||||
|
||||
// Variables
|
||||
|
@ -6,13 +6,14 @@ import lightcontainer.protocol.ProtocolReader;
|
||||
import lightcontainer.protocol.rules.writer.GetFileOkRule;
|
||||
import lightcontainer.protocol.rules.writer.SaveFileErrorRule;
|
||||
import lightcontainer.utils.FileReceiver;
|
||||
import lightcontainer.utils.FileSender;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import static lightcontainer.protocol.StandardizedDefinitions.SBE_RETRIEVE_RESULT_OK;
|
||||
|
||||
public class RetrieveOkRule extends ProtocolReader {
|
||||
// Constants
|
||||
private static final String PATTERN = "^RETRIEVE_OK ([A-Za-z0-9.]{50,200}) ([0-9]{1,10}) ([A-Za-z0-9.]{50,200})\r\n$";
|
||||
private static final String PATTERN = SBE_RETRIEVE_RESULT_OK;
|
||||
private static final String NAME = "RETRIEVE_OK";
|
||||
// -- arguments
|
||||
private static final int HASHED_FILE_NAME = 0; // Index hashed filename
|
||||
@ -45,6 +46,7 @@ public class RetrieveOkRule extends ProtocolReader {
|
||||
|
||||
/**
|
||||
* Bitch has bettern than my money
|
||||
*
|
||||
* @param reader Buffer rempli du fichier
|
||||
*/
|
||||
@Override
|
||||
|
@ -1 +1 @@
|
||||
{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"","tls":true,"storagePath":"/home/benjamin/ffe","users":[{"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":"Wi-Fi","tls":true,"storagePath":"C:\\Users\\ledou\\Documents\\ffe","users":[{"name":"aaaaa","password":"$2a$10$pUtcOXsQvLWYq1TJHTT8peb7ev/0YJFhrGUpj39InIstnSq1QcFGy","aes_key":"msCPN6nRJ9brhfLAZqmVuBkddtLH2ub1oEnlh73sEw8=","files":[{"name":"Reoutage.txt","fileNameSalt":"HX9Rd6VQgAzACtDHJ7S1aQ==","size":168,"iv":"unBbaL17c4pSaVi315RKaw==","storage":["orglightcont01"]}]}]}
|
Loading…
Reference in New Issue
Block a user