From a0cf3c2626e2545af45214805ea5a32c14f389bf Mon Sep 17 00:00:00 2001 From: Collard <esteban.collard.etu@univ-lille.fr> Date: Wed, 27 Jan 2021 22:38:14 +0100 Subject: [PATCH] Importation du projet sur git --- bin/pom.xml | 75 +++++++ bin/src/main/java/sr/App.class | Bin 0 -> 1038 bytes bin/src/test/java/sr/AppTest.class | Bin 0 -> 1015 bytes bin/target/Projet1-1.0-SNAPSHOT.jar | Bin 0 -> 2361 bytes bin/target/maven-archiver/pom.properties | 4 + .../compile/default-compile/createdFiles.lst | 1 + .../compile/default-compile/inputFiles.lst | 1 + .../default-testCompile/createdFiles.lst | 1 + .../default-testCompile/inputFiles.lst | 1 + .../surefire-reports/TEST-sr.AppTest.xml | 61 ++++++ bin/target/surefire-reports/sr.AppTest.txt | 4 + pom.xml | 75 +++++++ src/main/java/ftp/ClientFtp.java | 200 ++++++++++++++++++ src/main/java/ftp/main.java | 11 + 14 files changed, 434 insertions(+) create mode 100644 bin/pom.xml create mode 100644 bin/src/main/java/sr/App.class create mode 100644 bin/src/test/java/sr/AppTest.class create mode 100644 bin/target/Projet1-1.0-SNAPSHOT.jar create mode 100644 bin/target/maven-archiver/pom.properties create mode 100644 bin/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 bin/target/surefire-reports/TEST-sr.AppTest.xml create mode 100644 bin/target/surefire-reports/sr.AppTest.txt create mode 100644 pom.xml create mode 100644 src/main/java/ftp/ClientFtp.java create mode 100644 src/main/java/ftp/main.java diff --git a/bin/pom.xml b/bin/pom.xml new file mode 100644 index 0000000..7e45602 --- /dev/null +++ b/bin/pom.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>sr</groupId> + <artifactId>Projet1</artifactId> + <version>1.0-SNAPSHOT</version> + + <name>Projet1</name> + <!-- FIXME change it to the project's website --> + <url>http://www.example.com</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> + <plugins> + <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.1.0</version> + </plugin> + <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.1</version> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <version>2.5.2</version> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.8.2</version> + </plugin> + <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <version>3.7.1</version> + </plugin> + <plugin> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>3.0.0</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/bin/src/main/java/sr/App.class b/bin/src/main/java/sr/App.class new file mode 100644 index 0000000000000000000000000000000000000000..b7497996410c64131f5c83714c3707111d8c0535 GIT binary patch literal 1038 zcmX^0Z`VEs1_omW8FmIHMh21MqGbKt#LPVXti-ZJ{o*2h$ASWO1{OvJ0kA+$VqUtw ze^ORzatR{?n@wh3W{Djm1G9!^7$XCVbAC!HI|C;p13yBoYf({t5eEY|BjfwfyrR_N z{G77X6ousc+=9%U#FEVXJcWXy{G^=J++r&QF3ymQRE3htf>Z^N0eT?I^dOcgBq!$O z<(DWVr7FM-(Npj&QOGP-$jnR0EJ{r-$*EK*N=-{GO3h17O;JcI%Fk6ON-ZqSEJ{sL z&`ZuqEG||^%gjkF#%fD&Nl|8AI@N7SNlng41UaA}F*!RiJyk)exJXGMB|o)T0py$9 z#FFF;g_4X^h180I)Z~)X6a^%O$$FrO&;tiWagh=ir)O?KPG)jui9&H{L28jga(-TM zNl|HXNq&(6B$PBXK><>lmy(*6nFk7l{33;v)U?FXoDyW!dJ4X!#U&t_%)C^E#5|Dg z5QCA7<l@8`CJH6_3W?x&;^GXhEG|jS#S(B_TnroxygUr741A0Xq8dIRZ|H+!R3Bol zH7LpO`();&`jzG;r51%GCgr3uG6?zPCnx5FB^G6Z_)tNXl8nq^Mg}n-Y^l?lk%0vi zP>c*b8qq#*!#Nnl7#Wg?NOKS!SbRX7HyIhYg7Zs@l2hF>LGI^pEGPg+89Rd%BLf@6 za7G3m-^}9T%)IoF%7WBl21N!&24)5jU}9ioU}a!qU}RutU|=v|U}j)sU|`_d&A<^U z#I>D)XFmf20}}&30|QtM0|O(200RR94@4D%AcGJC0|O_6FoOux1T7R3M6sB_2{wTV UY_2$%lwgo%U|?WjU}TU40F;C*#Q*>R literal 0 HcmV?d00001 diff --git a/bin/src/test/java/sr/AppTest.class b/bin/src/test/java/sr/AppTest.class new file mode 100644 index 0000000000000000000000000000000000000000..6fa22fc01842d51a9a5c58d5cadaf35bbf5649ef GIT binary patch literal 1015 zcmX^0Z`VEs1_omWDRu@XMh1!EqGbJ&)Z!BTti-ZJ{o*2h$AW^8)Z!9$1{OvJ0kB|B zVqUtwe^ORzatR{?n@wh3W{Djm1G9!^7$XCVbAC!HI|C;p13yBoYf({t5eEY|BV%7^ zUQudseok3xib8UJZb4>FVo7Fxo<c!Ueo{_qZn2dD7iUODszOR?a!z7VYKlTZVsdt3 zda8m_agmZjN`7jwLSBA}LT+M7a)v@lMyf(;ML}wE397<mJ&*_VK=$hu7b!tZ%*-vw zFDg;UFG^QPPRs)tl9Z|da|=;QJaY?jGLth)6pBj=Qi~Ll^Ye;Jib|79@{1H8fuW(P zkXfuynwOHAmYJ8DqL7wfq>z%DmROoof~;Ck!MC)y1SFH0m#UDM2l4~NU?d~CI6;Aq z#i<G<`3i{&C6xuK5J%^xmSp6oC?pmarxulj6qTlGB<1Jlq$cKJaSSNHKsptmamvNT zz`?-F!@$bG$H*Y6;R6aWeQ@jsmlS2@rCWnyl;0;aFV(L!Hz~C!Brz!`m61WnCqFqc zCoHij6U2uKvXo?G7BezP`QS=G){G1y#TogfIVp~L#pS6*;h7~FAonsdNC%bXm1O3o zdghg77H1~qq&kA)2b?g985!7oKp|nx!644a&`wP9Ni8m+b+|Dya0Ta=7A2>;Wr6~P z2O6H>B*&o0z{tSN00K-5j0~&{Yz&MH><kPHCJf9Bj0_A6T)P=KB89lNGw|$ZU|?Wk z;Ada}t6^YZWDsCrVBmqMVi05yVgQK=Gq5o*F^E7_i83%?F-;7MY5Z7ClK|T(2>`Sr BBk}+M literal 0 HcmV?d00001 diff --git a/bin/target/Projet1-1.0-SNAPSHOT.jar b/bin/target/Projet1-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..291841a0a63555c3cd77799607e7f4bfb8d27165 GIT binary patch literal 2361 zcmWIWW@h1H;Nak3nBr?0)UfvVhA0LGhC~Ji1`!4Z24B|@M_o@pH+^46KT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T>veOk&Od|CUTkprBH-%x@=ej1j#r=dJXVqWdrHtWZ-1*V`5;q3g!U-s#H4Y literal 0 HcmV?d00001 diff --git a/bin/target/maven-archiver/pom.properties b/bin/target/maven-archiver/pom.properties new file mode 100644 index 0000000..ef30520 --- /dev/null +++ b/bin/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.6.3 +groupId=sr +artifactId=Projet1 +version=1.0-SNAPSHOT diff --git a/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..ae50ae0 --- /dev/null +++ b/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +sr/App.class diff --git a/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..ba6a79a --- /dev/null +++ b/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/src/main/java/sr/App.java diff --git a/bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..a697f23 --- /dev/null +++ b/bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +sr/AppTest.class diff --git a/bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..eb8e48a --- /dev/null +++ b/bin/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/src/test/java/sr/AppTest.java diff --git a/bin/target/surefire-reports/TEST-sr.AppTest.xml b/bin/target/surefire-reports/TEST-sr.AppTest.xml new file mode 100644 index 0000000..25cb967 --- /dev/null +++ b/bin/target/surefire-reports/TEST-sr.AppTest.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="sr.AppTest" time="0.042" tests="1" errors="0" skipped="0" failures="0"> + <properties> + <property name="sun.desktop" value="gnome"/> + <property name="awt.toolkit" value="sun.awt.X11.XToolkit"/> + <property name="java.specification.version" value="11"/> + <property name="sun.cpu.isalist" value=""/> + <property name="sun.jnu.encoding" value="UTF-8"/> + <property name="java.class.path" value="/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/test-classes:/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/classes:/home/collard/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/collard/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/> + <property name="java.vm.vendor" value="Ubuntu"/> + <property name="sun.arch.data.model" value="64"/> + <property name="java.vendor.url" value="https://ubuntu.com/"/> + <property name="user.timezone" value=""/> + <property name="java.vm.specification.version" value="11"/> + <property name="os.name" value="Linux"/> + <property name="sun.java.launcher" value="SUN_STANDARD"/> + <property name="user.country" value="FR"/> + <property name="sun.boot.library.path" value="/usr/lib/jvm/java-11-openjdk-amd64/lib"/> + <property name="sun.java.command" value="/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/surefire/surefirebooter7067009550800621557.jar /home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/surefire 2021-01-25T09-44-40_084-jvmRun1 surefire4957153508783893532tmp surefire_013465013777986831042tmp"/> + <property name="jdk.debug" value="release"/> + <property name="surefire.test.class.path" value="/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/test-classes:/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/classes:/home/collard/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/collard/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/> + <property name="sun.cpu.endian" value="little"/> + <property name="user.home" value="/home/collard"/> + <property name="user.language" value="fr"/> + <property name="java.specification.vendor" value="Oracle Corporation"/> + <property name="java.version.date" value="2020-11-04"/> + <property name="java.home" value="/usr/lib/jvm/java-11-openjdk-amd64"/> + <property name="file.separator" value="/"/> + <property name="basedir" value="/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1"/> + <property name="java.vm.compressedOopsMode" value="32-bit"/> + <property name="line.separator" value=" "/> + <property name="java.specification.name" value="Java Platform API Specification"/> + <property name="java.vm.specification.vendor" value="Oracle Corporation"/> + <property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/> + <property name="surefire.real.class.path" value="/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/target/surefire/surefirebooter7067009550800621557.jar"/> + <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> + <property name="java.runtime.version" value="11.0.9.1+1-Ubuntu-0ubuntu1.20.04"/> + <property name="user.name" value="collard"/> + <property name="path.separator" value=":"/> + <property name="os.version" value="5.8.0-38-generic"/> + <property name="java.runtime.name" value="OpenJDK Runtime Environment"/> + <property name="file.encoding" value="UTF-8"/> + <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/> + <property name="localRepository" value="/home/collard/.m2/repository"/> + <property name="java.vendor.url.bug" value="https://bugs.launchpad.net/ubuntu/+source/openjdk-lts"/> + <property name="java.io.tmpdir" value="/tmp"/> + <property name="java.version" value="11.0.9.1"/> + <property name="user.dir" value="/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1"/> + <property name="os.arch" value="amd64"/> + <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> + <property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/> + <property name="sun.os.patch.level" value="unknown"/> + <property name="java.library.path" value="/home/collard/catkin_ws/devel/lib:/opt/ros/noetic/lib:/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/> + <property name="java.vm.info" value="mixed mode, sharing"/> + <property name="java.vendor" value="Ubuntu"/> + <property name="java.vm.version" value="11.0.9.1+1-Ubuntu-0ubuntu1.20.04"/> + <property name="sun.io.unicode.encoding" value="UnicodeLittle"/> + <property name="java.class.version" value="55.0"/> + </properties> + <testcase name="shouldAnswerWithTrue" classname="sr.AppTest" time="0.002"/> +</testsuite> \ No newline at end of file diff --git a/bin/target/surefire-reports/sr.AppTest.txt b/bin/target/surefire-reports/sr.AppTest.txt new file mode 100644 index 0000000..b17a297 --- /dev/null +++ b/bin/target/surefire-reports/sr.AppTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: sr.AppTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 s - in sr.AppTest diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7e45602 --- /dev/null +++ b/pom.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>sr</groupId> + <artifactId>Projet1</artifactId> + <version>1.0-SNAPSHOT</version> + + <name>Projet1</name> + <!-- FIXME change it to the project's website --> + <url>http://www.example.com</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> + <plugins> + <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.1.0</version> + </plugin> + <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.1</version> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <version>2.5.2</version> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.8.2</version> + </plugin> + <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <version>3.7.1</version> + </plugin> + <plugin> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>3.0.0</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> diff --git a/src/main/java/ftp/ClientFtp.java b/src/main/java/ftp/ClientFtp.java new file mode 100644 index 0000000..d8cc17e --- /dev/null +++ b/src/main/java/ftp/ClientFtp.java @@ -0,0 +1,200 @@ +package ftp; + +import java.io.*; +import java.net.Socket; +import java.net.UnknownHostException; + +public class ClientFtp { + + private Socket socket; + + private String serveur; + private int port; + + private String user; + private String password; + + private InputStream inputStream; + private InputStreamReader inputStreamReader; + private BufferedReader reader; + private BufferedWriter writer; + + + + public ClientFtp(String serveur, int port) { + this.serveur = serveur; + this.port = port; + this.user = null; + this.password = null; + } + + public ClientFtp(String serveur, int port, String user) { + this.serveur = serveur; + this.port = port; + this.user = user; + this.password = null; + } + + public ClientFtp(String serveur, int port, String user, String password) { + this.serveur = serveur; + this.port = port; + this.user = user; + this.password = password; + } + + + public void connection() { + try { + this.socket = new Socket(this.serveur,this.port); + this.inputStream = this.socket.getInputStream(); + this.inputStreamReader = new InputStreamReader(this.inputStream); + this.reader = new BufferedReader(this.inputStreamReader); + this.writer = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream())); + + + String message = readMessage(); + if (!message.startsWith("220 ")) { + throw new IOException( + "SimpleFTP received an unknown response when connecting to the FTP server: " + + message); + } + else { + System.out.print(message); + } + + sendUser(); + message = readMessage(); + if (!message.startsWith("331 ")) { + throw new IOException("SimpleFTP received an unknown response after sending the user: "+ message); + } + + sendPass(); + message = readMessage(); + if (!message.startsWith("230 ")) { + throw new IOException("SimpleFTP was unable to log in with the supplied password: "+ message); + } + + sendPasv(); + message = readMessage(); + String[] resConnection = message.substring(message.indexOf("(")+1,message.indexOf(")")).split(","); + + //test new socket + + Socket socketTest = new Socket(resConnection[0]+"."+resConnection[1]+"."+resConnection[2]+"."+resConnection[3], + (Integer.parseInt(resConnection[4])*256 + Integer.parseInt(resConnection[5])) + ); + + + BufferedReader reader2 = new BufferedReader(new InputStreamReader(socketTest.getInputStream())); + sendList(null); + System.out.print(reader2.readLine()); + sendList(null); + System.out.print(reader2.readLine()); + + + socketTest.close(); + + sendList(null); + + System.out.print(readMessage()); + + + this.socket.close(); + } + catch(UnknownHostException e) { + System.out.print("UnknownHostException\n"); + } + catch(IOException e) { + System.out.print("IOException\n"); + } + } + + /** + * Envoye l'identifiant au serveur ftp + * @throws IOException + */ + private void sendUser() throws IOException { + if(this.user == null) { + sendMessage("USER anonymous"); + } + else { + sendMessage("USER "+this.user); + } + } + + /** + * Envoye le mot de passe au serveur ftp + * @throws IOException + */ + private void sendPass() throws IOException { + if(this.user == null) { + sendMessage("PASS anonymous@domain.com"); + } + else { + sendMessage("PASS "+this.password); + } + } + + /** + * Envoye le message PORT au serveur ftp + * Cette commande permet de specifier une adresse et un port de connexion. + * @throws IOException + */ + private void sendPort() throws IOException { + //sendMessage("PORT "+this.port); + } + + /** + * Permet d'envoyer la message PASV au serveur ftp + * Cette commande permet de se connecter en mode passif. + * @throws IOException + */ + private void sendPasv() throws IOException { + sendMessage("PASV"); + } + + /** + * Envoi le message LIST au serveur ftp + * Affiche les informations d'un fichier ou d'un repertoire specifique, ou du repertoire courant. + * @param parameter : repertoire specifique, null si repertoire courant + * @throws IOException + */ + private void sendList(String parameter) throws IOException { + if(parameter == null) { + sendMessage("LIST"); + } + else { + + sendMessage("LIST "+parameter); + } + } + + /** + * Permet d'envoyer un message au serveur ftp + * @param message : message a envoyer au serveur ftp + * @throws IOException + */ + private void sendMessage(String message) throws IOException { + if (socket == null) { + throw new IOException("SimpleFTP is not connected."); + } + try { + this.writer.write(message + "\r\n"); + this.writer.flush(); + } catch (IOException e) { + socket = null; + throw e; + } + } + + /** + * Permet de recuperer le message envoyer par le serveur ftp + * @return String valeur envoyer par le serveur ftp + * @throws IOException + */ + private String readMessage() throws IOException { + return this.reader.readLine(); + } + + +} diff --git a/src/main/java/ftp/main.java b/src/main/java/ftp/main.java new file mode 100644 index 0000000..34beac8 --- /dev/null +++ b/src/main/java/ftp/main.java @@ -0,0 +1,11 @@ +package ftp; + +public class main { + public static void main (String[] args){ + ClientFtp c = new ClientFtp("ftp.ubuntu.com", 21); + + c.connection(); + + + } +} -- GitLab