From a42eb59be7b2ff1f8579be1eb6cddcc92fbb2733 Mon Sep 17 00:00:00 2001 From: Maximilien LEDOUX Date: Tue, 8 Mar 2022 16:15:14 +0100 Subject: [PATCH 1/3] =?UTF-8?q?SSL=20:=20impl=C3=A9ment=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domains/server/UnicastServerListener.java | 20 ++++++++++++------- .../java/lightcontainer/utils/AES_GCM.java | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java b/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java index 5970d61..39fc2ab 100644 --- a/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java +++ b/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java @@ -5,6 +5,8 @@ import lightcontainer.interfaces.ProtocolRepository; import lightcontainer.interfaces.UnicastCHR; import lightcontainer.repository.FileFrontEnd; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; @@ -31,17 +33,20 @@ public class UnicastServerListener implements Runnable { /** * Initializes the server and starts it on the previously selected port. * - * @since 1.0 - * - * @see Thread#start() - * @see ClientHandler + * @see Thread#start() + * @see ClientHandler + * @since 1.0 */ @Override public void run() { try { // Allow looping in the loop and create a socket server + SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory) SSLServerSocketFactory + .getDefault(); + SSLServerSocket sslserversocket = (SSLServerSocket) sslserversocketfactory + .createServerSocket(this.server_port); this.server_run = true; - this.server = new ServerSocket(this.server_port); + this.server = sslserversocket; while (this.server_run) { // Accepting connection requests (blocking) Socket client = this.server.accept(); @@ -61,14 +66,15 @@ public class UnicastServerListener implements Runnable { /** * Stops the server and terminates the new connection. * - * @since 1.0 + * @since 1.0 */ public void stop() { if (this.server_run) { try { this.server_run = false; this.server.close(); - } catch (IOException ignored) { } + } catch (IOException ignored) { + } } } diff --git a/app/src/main/java/lightcontainer/utils/AES_GCM.java b/app/src/main/java/lightcontainer/utils/AES_GCM.java index 5aeed9d..2a9c832 100644 --- a/app/src/main/java/lightcontainer/utils/AES_GCM.java +++ b/app/src/main/java/lightcontainer/utils/AES_GCM.java @@ -18,7 +18,7 @@ public class AES_GCM { public static void main(String[] args) throws Exception { // Text pour test : - String plainText = "salut fils de pute"; + String plainText = "salut fils de pute";//TODO enlever le text chelou de Jérémi (ce fou là) String IV = generateIV(); String key = generateSecretKey(); From 9df754f061d68dd81e2532673b72489cb33d669c Mon Sep 17 00:00:00 2001 From: Maximilien LEDOUX Date: Tue, 8 Mar 2022 16:48:22 +0100 Subject: [PATCH 2/3] SSL : ajout fichier --- .../domains/client/ClientHandler.java | 4 +++- ffe.labo.swilabus.com.p12 | Bin 0 -> 4469 bytes 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 ffe.labo.swilabus.com.p12 diff --git a/app/src/main/java/lightcontainer/domains/client/ClientHandler.java b/app/src/main/java/lightcontainer/domains/client/ClientHandler.java index 15f1ed5..6a3faa3 100644 --- a/app/src/main/java/lightcontainer/domains/client/ClientHandler.java +++ b/app/src/main/java/lightcontainer/domains/client/ClientHandler.java @@ -116,7 +116,9 @@ public class ClientHandler implements Runnable, AutoCloseable { } else { authentication(ruleResult); } - } catch (IOException ignore) { } + } catch (IOException ignore) { + ignore.printStackTrace(); + } } } diff --git a/ffe.labo.swilabus.com.p12 b/ffe.labo.swilabus.com.p12 new file mode 100644 index 0000000000000000000000000000000000000000..98ca601f97c230174c70b91ba7f73a9920b34370 GIT binary patch literal 4469 zcmV-*5sL0Gf)Q~70Ru3C5jO@2Duzgg_YDCD0ic2rCD7=>kX(ZP8a$LvTy)e5xzIuq(@ zsN%kP(HtMzFVox|F!8jkf^wRN_%E9z-6}b~kdrG=a35oG@MNROvLJ<^eK*vMG?^bT@K=yX-hQhxYgh04-mKXD&#;dK zVDm4-s}|{sQ5A=nja{*wWz6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/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domains/server/UnicastServerListener.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java b/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java index 39fc2ab..a12b5d0 100644 --- a/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java +++ b/app/src/main/java/lightcontainer/domains/server/UnicastServerListener.java @@ -41,12 +41,9 @@ public class UnicastServerListener implements Runnable { public void run() { try { // Allow looping in the loop and create a socket server - SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory) SSLServerSocketFactory - .getDefault(); - SSLServerSocket sslserversocket = (SSLServerSocket) sslserversocketfactory - .createServerSocket(this.server_port); + SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); + this.server = sslserversocketfactory.createServerSocket(this.server_port); this.server_run = true; - this.server = sslserversocket; while (this.server_run) { // Accepting connection requests (blocking) Socket client = this.server.accept();