Skip to content
Snippets Groups Projects
Commit 042f9503 authored by mokeddes's avatar mokeddes
Browse files

doc

parent 90531f37
Branches
Tags
No related merge requests found
Showing
with 156 additions and 7 deletions
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java=UTF-8 encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8
...@@ -5,6 +5,11 @@ import java.io.IOException; ...@@ -5,6 +5,11 @@ import java.io.IOException;
import sr.projet2.Server.ConnectionServer; import sr.projet2.Server.ConnectionServer;
public class Main { public class Main {
/**
* la classe qui nous permet de lancer notre application
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException{ public static void main(String[] args) throws IOException{
ConnectionServer server=new ConnectionServer(2020); ConnectionServer server=new ConnectionServer(2020);
server.serverConnect(); server.serverConnect();
......
...@@ -5,12 +5,18 @@ import java.io.IOException; ...@@ -5,12 +5,18 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class AUTH_SSL implements request { public class AUTH_SSL implements request {
/**
* authentification de notre application
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public AUTH_SSL(FtpConnexion ftp) { public AUTH_SSL(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
} }
@Override
/*
*
*/
public void send() throws IOException{ public void send() throws IOException{
if (this.ftp.getSocket() == null ) { if (this.ftp.getSocket() == null ) {
throw new IOException("Ftp server error"); throw new IOException("Ftp server error");
......
...@@ -5,6 +5,9 @@ import java.io.IOException; ...@@ -5,6 +5,9 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class AUTH_TLS implements request { public class AUTH_TLS implements request {
/**
* authentification de notre application
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public AUTH_TLS(FtpConnexion ftp) { public AUTH_TLS(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -6,6 +6,11 @@ import java.io.IOException; ...@@ -6,6 +6,11 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class CDUP implements request { public class CDUP implements request {
/**
* retour au dossier parent
* Process pour retourner au dossier parent
* [CDUP]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public CDUP(FtpConnexion ftp) { public CDUP(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -6,6 +6,12 @@ import java.io.IOException; ...@@ -6,6 +6,12 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class CWD implements request { public class CWD implements request {
/**
*
* Process pour ouvrir un dossier
* [CWD]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String directory; private String directory;
public CWD(FtpConnexion ftp,String directory) { public CWD(FtpConnexion ftp,String directory) {
......
...@@ -5,6 +5,7 @@ import java.io.IOException; ...@@ -5,6 +5,7 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class FEAT implements request { public class FEAT implements request {
private FtpConnexion ftp; private FtpConnexion ftp;
public FEAT(FtpConnexion ftp) { public FEAT(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -14,6 +14,12 @@ import java.text.SimpleDateFormat; ...@@ -14,6 +14,12 @@ import java.text.SimpleDateFormat;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class LIST implements request { public class LIST implements request {
/**
*
* Process qui permet de lister un repertoir
* [LIST]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public LIST(FtpConnexion ftp) { public LIST(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -6,6 +6,11 @@ import java.io.IOException; ...@@ -6,6 +6,11 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class MKD implements request { public class MKD implements request {
/**
* Process pour creer un dossier
* [MKD]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String DIR; private String DIR;
public MKD(FtpConnexion ftp, String DIR) { public MKD(FtpConnexion ftp, String DIR) {
......
...@@ -5,6 +5,10 @@ import java.io.IOException; ...@@ -5,6 +5,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class PASS implements request { public class PASS implements request {
/**
* procces pour l'authentification -> mot de passe
* [PASS]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String pass; private String pass;
public PASS(FtpConnexion ftp, String pass) { public PASS(FtpConnexion ftp, String pass) {
......
...@@ -7,6 +7,10 @@ import java.net.Socket; ...@@ -7,6 +7,10 @@ import java.net.Socket;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class PASV implements request { public class PASV implements request {
/**
* Process pour passer en mode passif
* [PASV]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public PASV(FtpConnexion ftp) { public PASV(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -5,6 +5,10 @@ import java.io.IOException; ...@@ -5,6 +5,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class PWD implements request { public class PWD implements request {
/**
* Process pour renvoyer l'enplacement courant (le chemin)
* [PWD]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public PWD(FtpConnexion ftp) { public PWD(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -5,6 +5,10 @@ import java.io.IOException; ...@@ -5,6 +5,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class QUIT implements request { public class QUIT implements request {
/**
* process pour fermer un socket
* [QUIT]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public QUIT(FtpConnexion ftp) { public QUIT(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -6,6 +6,10 @@ import java.io.IOException; ...@@ -6,6 +6,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class RNFR implements request { public class RNFR implements request {
/**
* Process rename from pour sauvgarder le nom du dossier a renomer
* [RNFR]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String name; private String name;
public RNFR(FtpConnexion ftp, String name) { public RNFR(FtpConnexion ftp, String name) {
......
...@@ -6,6 +6,11 @@ import java.io.IOException; ...@@ -6,6 +6,11 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class RNTO implements request { public class RNTO implements request {
/**
* Process rename to ( renomer le dossier sauvgardé avec rnfr )
* [RNTO]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String name; private String name;
public RNTO(FtpConnexion ftp, String name) { public RNTO(FtpConnexion ftp, String name) {
......
...@@ -5,6 +5,10 @@ import java.io.IOException; ...@@ -5,6 +5,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class SYST implements request { public class SYST implements request {
/**
* Process rename to ( renomer le dossier sauvgardé avec rnfr )
* [SYST]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
public SYST(FtpConnexion ftp) { public SYST(FtpConnexion ftp) {
this.ftp =ftp; this.ftp =ftp;
......
...@@ -5,6 +5,10 @@ import java.io.IOException; ...@@ -5,6 +5,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class TYPE implements request { public class TYPE implements request {
/**
* return mode type
* [TYPE]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String type; private String type;
public TYPE(FtpConnexion ftp,String type) { public TYPE(FtpConnexion ftp,String type) {
......
...@@ -5,6 +5,10 @@ import java.io.IOException; ...@@ -5,6 +5,10 @@ import java.io.IOException;
import sr.projet2.Server.FtpConnexion; import sr.projet2.Server.FtpConnexion;
public class USER implements request { public class USER implements request {
/**
* process pour l'authentification -> utilisateur
* [USER]
*/
private FtpConnexion ftp; private FtpConnexion ftp;
private String user; private String user;
public USER(FtpConnexion ftp,String user) { public USER(FtpConnexion ftp,String user) {
......
...@@ -10,9 +10,17 @@ import java.net.Socket; ...@@ -10,9 +10,17 @@ import java.net.Socket;
import java.util.Random; import java.util.Random;
public class ConnectionServer { public class ConnectionServer {
/**
* connexion au serveur
*/
private int PORT; private int PORT;
private ServerSocket srvSckt; private ServerSocket srvSckt;
/**
* verifie si le port est bon , sinon on va generer un autre aléatoirment
* @param PORT
* @throws IOException
*/
public ConnectionServer (int PORT) throws IOException { public ConnectionServer (int PORT) throws IOException {
if(PORT>1024 && PORT<8080){ if(PORT>1024 && PORT<8080){
this.PORT=PORT; this.PORT=PORT;
...@@ -26,7 +34,10 @@ public class ConnectionServer { ...@@ -26,7 +34,10 @@ public class ConnectionServer {
} }
/**
*
* @throws IOException
*/
public void server() throws IOException { public void server() throws IOException {
try { try {
this.srvSckt=new ServerSocket(this.PORT); this.srvSckt=new ServerSocket(this.PORT);
...@@ -37,9 +48,17 @@ public class ConnectionServer { ...@@ -37,9 +48,17 @@ public class ConnectionServer {
} }
} }
/**
*
* @return serveSocket
*/
public ServerSocket getServ() { public ServerSocket getServ() {
return this.srvSckt; return this.srvSckt;
} }
/**
*
* @throws IOException
*/
public void serverConnect() throws IOException { public void serverConnect() throws IOException {
try { try {
Socket socket=this.srvSckt.accept(); Socket socket=this.srvSckt.accept();
......
...@@ -26,6 +26,9 @@ import sr.projet2.Request.TYPE; ...@@ -26,6 +26,9 @@ import sr.projet2.Request.TYPE;
import sr.projet2.Request.USER; import sr.projet2.Request.USER;
public class FtpConnexion extends Thread { public class FtpConnexion extends Thread {
/**
* établir une connexion ftp
*/
private Socket socket; private Socket socket;
private BufferedReader bfR; private BufferedReader bfR;
private BufferedWriter bfW; private BufferedWriter bfW;
...@@ -40,7 +43,10 @@ public class FtpConnexion extends Thread { ...@@ -40,7 +43,10 @@ public class FtpConnexion extends Thread {
this.Connected=false; this.Connected=false;
this.directory="/"; this.directory="/";
} }
/**
*
* @throws IOException
*/
public void auth() throws IOException{ public void auth() throws IOException{
try { try {
this.bfW.write("220 FTP SERVER\r\n"); this.bfW.write("220 FTP SERVER\r\n");
...@@ -49,7 +55,9 @@ public class FtpConnexion extends Thread { ...@@ -49,7 +55,9 @@ public class FtpConnexion extends Thread {
throw new IOException("FTP Connexion failed"); throw new IOException("FTP Connexion failed");
} }
} }
/**
*
*/
public void run() { public void run() {
try { try {
this.auth(); this.auth();
...@@ -66,7 +74,11 @@ public class FtpConnexion extends Thread { ...@@ -66,7 +74,11 @@ public class FtpConnexion extends Thread {
} }
} }
/**
* appliquer la méthode send d'une commande selon son type
* @param readLine
* @throws IOException
*/
public void read(String readLine) throws IOException { public void read(String readLine) throws IOException {
if(readLine.startsWith("AUTH TLS")) { if(readLine.startsWith("AUTH TLS")) {
AUTH_TLS request= new AUTH_TLS(this); AUTH_TLS request= new AUTH_TLS(this);
...@@ -149,40 +161,85 @@ public class FtpConnexion extends Thread { ...@@ -149,40 +161,85 @@ public class FtpConnexion extends Thread {
} }
} }
/**
*
* @return socket
*/
public Socket getSocket() { public Socket getSocket() {
return this.socket; return this.socket;
} }
/**
*
* @return bufferwriter
*/
public BufferedWriter getBufferedWriter() { public BufferedWriter getBufferedWriter() {
return this.bfW; return this.bfW;
} }
/**
*
* @return bufferReader
*/
public BufferedReader getBufferedReader() { public BufferedReader getBufferedReader() {
return this.bfR; return this.bfR;
} }
/**
*
* @return connexionstate
*/
public boolean getConnectedState(){ public boolean getConnectedState(){
return this.Connected; return this.Connected;
} }
/**
* connexion
*/
public void connect() { public void connect() {
this.Connected=true; this.Connected=true;
} }
/**
* deconnexion
*/
public void disconnect(){ public void disconnect(){
this.Connected=false; this.Connected=false;
} }
/**
*
* @return rep
*/
public String getDirectory(){ public String getDirectory(){
return this.directory; return this.directory;
} }
/**
* modifier le repertoir ou l'initialiser
* @param Directory
*/
public void SetDirectory(String Directory){ public void SetDirectory(String Directory){
this.directory=Directory; this.directory=Directory;
} }
/**
*
* @return socketserver
*/
public ServerSocket getServerSocket(){ public ServerSocket getServerSocket(){
return this.socketServer; return this.socketServer;
} }
/**
*
* @param s
*/
public void SetServerSocket(ServerSocket s){ public void SetServerSocket(ServerSocket s){
this.socketServer=s; this.socketServer=s;
} }
/**
*
* @return rename
*/
public String getRename(){ public String getRename(){
return this.rename; return this.rename;
} }
/**
* rename
* @param s
*/
public void SetRename(String s){ public void SetRename(String s){
this.rename=s; this.rename=s;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment