Regex : complètes et centralisées

This commit is contained in:
Maximilien LEDOUX 2022-03-15 11:48:12 +01:00
parent 6f04606c69
commit d89cadb55e

View File

@ -2,24 +2,55 @@ package lightcontainer.protocol;
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 VISIBLECHAR = "[\\x20-\\xFF]";
private final static String PASSCHAR = "[\\x20-\\xFF]";
private final static String BINARY = "[\\x00-\\xFF]";
private final static String LETTER = "[\\x41-\\x5A\\x61-\\x7A]";
private final static String DIGIT_LETTER = DIGIT + "|" + LETTER;
private final static String PORT = "(6553[\\x30-\\x35])|(655[\\x30-\\x32][\\x30-\\x39])|(65[\\x30-\\x34][\\x30-\\x32]{2})|(6[\\x30-\\x34][\\x30-\\x39]{3})|([\\x31-\\x35][\\x30-\\x39]{4})|([\\x30-\\x35]{0,5})|([\\x30-\\x39]{1,4})";
private final static String SIZE = DIGIT + "{1,10}";
private final static String LINE = "\\x0D\\x0A";
private final static String PASSWORD = PASSCHAR + "{5,50}";
private final static String BL = "\\x20";
private final static String FILENAME = PASSCHAR + "{1,20}";
private final static String DOMAIN = DIGIT_LETTER + "{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 LOGIN = DIGIT_LETTER + "{5,20}";
//Parties de regex pouvant être utilisées en dehors de cette classe
public final static String PORT = "(6553[\\x30-\\x35])|(655[\\x30-\\x32][\\x30-\\x39])|(65[\\x30-\\x34][\\x30-\\x32]{2})|(6[\\x30-\\x34][\\x30-\\x39]{3})|([\\x31-\\x35][\\x30-\\x39]{4})|([\\x30-\\x35]{0,5})|([\\x30-\\x39]{1,4})";
public final static String SIZE = DIGIT + "{1,10}";
public final static String LINE = "\\x0D\\x0A";
public final static String PASSWORD = PASSCHAR + "{5,50}";
public final static String BL = "\\x20";
public final static String FILENAME = PASSCHAR + "{1,20}";
public final static String DOMAIN = DIGIT_LETTER + "{5,20}[.]";
public final static String HASH_FILENAME = DIGIT_LETTER + "{50,200}";
public final static String HASH_FILECONTENT = DIGIT_LETTER + "{50,200}";
public final static String FILE_INFO = HASH_FILENAME + BL + SIZE + BL + HASH_FILECONTENT;
public final static String LOGIN = DIGIT_LETTER + "{5,20}";
//Regex à utiliser dans les différents protocoles.
//SBE s'annonce à FFE.
public final static String SBE_HELLO = "HELLO" + BL + "(" + DOMAIN + ")" + BL + "(" + PORT + ")" + LINE;
//FFE demande à SBE une tâche. SBE répond à FFE.
public final static String FFE_SENDFILE = "SENDFILE" + BL + FILE_INFO + LINE;
public final static String SBE_SEND_RESULT_OK = "SEND_OK" + LINE;
public final static String SBE_SEND_RESULT_ERROR = "SEND_ERROR" + LINE;
public final static String FFE_ERASE_FILE = "ERASEFILE" + BL + HASH_FILENAME + LINE;
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_ERROR = "RETRIEVE_ERROR" + LINE;
//Client demande à FFE une tâche. FFE répond à client.
public final static String CLIENT_SIGN_IN = "SIGNIN" + BL + "(" + LOGIN + ")" + BL + "(" + PASSWORD + ")" + LINE;
public final static String CLIENT_SIGN_UP = "SIGNUP" + BL + "(" + LOGIN + ")" + BL + "(" + PASSWORD + ")" + LINE;
public final static String FFE_SIGN_OK = "SIGN_OK" + LINE;
public final static String FFE_SIGN_ERROR = "SIGN_ERROR" + LINE;
public final static String CLIENT_FILE_LIST = "FILELIST" + LINE;
public final static String FFE_FILE_LIST_RESULT = "FILES" + "((" + PASSCHAR + "{1,20})!(" + DIGIT + "{1,10})){0,50}" + LINE;
public final static String CLIENT_SAVE_FILE = "SAVEFILE" + BL + "(" + FILENAME + ")" + BL + "(" + SIZE + ")" + LINE;
public final static String FFE_SAVE_FILE_OK = "SAVEFILE_OK" + LINE;
public final static String FFE_SAVE_FILE_ERROR = "SAVEFILE_ERROR" + LINE;
public final static String CLIENT_GET_FILE = "GETFILE" + BL + "(" + FILENAME + ")" + LINE;
public final static String FFE_GET_FILE_RESULT_OK = "GETFILE_OK" + BL + FILENAME + BL + SIZE + LINE;
public final static String FFE_GET_FILE_RESULT_ERROR = "GETFILE_ERROR" + LINE;
public final static String CLIENT_REMOVE_FILE = "REMOVEFILE" + BL + "(" + FILENAME + ")" + LINE;
public final static String FFE_REMOVE_OK = "REMOVEFILE_OK" + LINE;
public final static String FFE_REMOVE_ERROR = "REMOVEFILE_ERROR" + LINE;
public final static String CLIENT_SIGN_OUT = "SIGNOUT" + LINE;
}