Skip to content
Snippets Groups Projects
Commit a0cf3c26 authored by Esteban Collard's avatar Esteban Collard
Browse files

Importation du projet sur git

parent 4ecc463b
Branches
Tags v0.1
No related merge requests found
Showing
with 434 additions and 0 deletions
<?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>
File added
File added
File added
#Created by Apache Maven 3.6.3
groupId=sr
artifactId=Projet1
version=1.0-SNAPSHOT
sr/App.class
/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/src/main/java/sr/App.java
sr/AppTest.class
/home/collard/Documents/ecole/Master 1/M1S2/SR/Projet1/Projet1/src/test/java/sr/AppTest.java
<?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="&#10;"/>
<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
-------------------------------------------------------------------------------
Test set: sr.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 s - in sr.AppTest
pom.xml 0 → 100644
<?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>
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();
}
}
package ftp;
public class main {
public static void main (String[] args){
ClientFtp c = new ClientFtp("ftp.ubuntu.com", 21);
c.connection();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment