Initial commit
This commit is contained in:
26
src/main/java/fr/istic/chiffrement/Client.java
Normal file
26
src/main/java/fr/istic/chiffrement/Client.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package fr.istic.chiffrement;
|
||||
|
||||
public class Client {
|
||||
|
||||
private static char[] PASSWORD = "654321".toCharArray();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Création d'un SSLContext comme pour le serveur
|
||||
// avec les caractéristiques suivantes :
|
||||
// + protocole utilisé : TLS
|
||||
// + format de clef PKCS12
|
||||
// + mot de passe store et clef : variable PASSWORD plus haut (ou null)
|
||||
// + keystore : clientstore.keys
|
||||
|
||||
// ...
|
||||
// ks.load(new FileInputStream("clientstore.keys"), null);
|
||||
// ..
|
||||
|
||||
// Creation des printwriter et buffered reader puis :
|
||||
|
||||
// out.write("PING");
|
||||
// out.flush();
|
||||
// System.out.println(in.readLine());
|
||||
}
|
||||
|
||||
}
|
||||
45
src/main/java/fr/istic/chiffrement/Serveur.java
Normal file
45
src/main/java/fr/istic/chiffrement/Serveur.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package fr.istic.chiffrement;
|
||||
|
||||
import java.net.ServerSocket;
|
||||
|
||||
public class Serveur {
|
||||
static int PORT = 9999;
|
||||
// NE FAITES PAS CA EN PROD :
|
||||
private static char[] PASSWORD = "123456".toCharArray();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
long time = System.currentTimeMillis();
|
||||
// Choisir l'un ou l'autre en fonction de la question :
|
||||
ServerSocket server = creerSocketTLS(); // creerSocketClassique();
|
||||
System.out.printf("temps écoulé : %d ms %n", System.currentTimeMillis() - time);
|
||||
readPingSendPong(server);
|
||||
}
|
||||
|
||||
public static ServerSocket creerSocketClassique() throws Exception {
|
||||
// TODO : retourner une socket classique qui écoute sur le port 9999
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Créer une ServerSocket TLS qui écoute sur le port 9999
|
||||
*
|
||||
* @return une socket classique
|
||||
* @throws Exception
|
||||
*/
|
||||
public static ServerSocket creerSocketTLS() throws Exception {
|
||||
// Créer une ServerSocket TLS qui écoute sur le port 9999, avec les
|
||||
// caractéristiques suivantes :
|
||||
// + protocole utilisé : TLS
|
||||
// + format de clef PKCS12
|
||||
// + mot de passe store et clef : variable PASSWORD plus haut.
|
||||
// + keystore, serveurstore.keys
|
||||
|
||||
return null; // Retourner la socket correctement configurée
|
||||
}
|
||||
|
||||
public static void readPingSendPong(ServerSocket server) throws Exception {
|
||||
// accepter une connexion
|
||||
// lire PING
|
||||
// écrire PONG vers le client
|
||||
}
|
||||
}
|
||||
17
src/main/java/fr/istic/chiffrement/TestSite.java
Normal file
17
src/main/java/fr/istic/chiffrement/TestSite.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package fr.istic.chiffrement;
|
||||
|
||||
public class TestSite {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public static void connecteEtAffiche(String host, int port) {
|
||||
// Creation de la socket
|
||||
// Choix de la cipher suite si nécessaire (sinon laisser defaut).
|
||||
// Connexion
|
||||
|
||||
// Affichage des infos demandées :
|
||||
|
||||
}
|
||||
}
|
||||
8
src/main/java/fr/istic/nio/PingPong.java
Normal file
8
src/main/java/fr/istic/nio/PingPong.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package fr.istic.nio;
|
||||
|
||||
public class PingPong {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user