Skip to content
Snippets Groups Projects
Commit 80319325 authored by Dominique Blouin's avatar Dominique Blouin
Browse files

check input, format strings in the detail panel, add client server

parent e16c117d
No related branches found
No related tags found
No related merge requests found
......@@ -63,9 +63,9 @@
<LastOpenFile data="/home/trhuy/TURTLE/stuxnet.xml"/>
<ExternalServer data="localhost:1587"/>
<ExternalServer data="localhost:12345"/>
<LastWindowAttributes x="-1" y="25" width="1368" height="743" max="true" />
<LastWindowAttributes x="547" y="86" width="792" height="597" max="false" />
</TURTLECONFIGURATION>
......@@ -27,8 +27,8 @@ import org.jsoup.parser.Parser;
import org.jsoup.nodes.Document;
public class Client {
public static String dbaddr="localhost";
public static int dpport=9999;
//public static String dbaddr="localhost";
//public static int dpport=9999;
public Object parserAnswerMessage(Message answerMsg) {
//Analyse the message from the server,
//Depends on the cmd, we can determine the values
......@@ -39,13 +39,20 @@ public class Client {
return null;
} else if (cmd.equals(Message.RESULT_SEARCH)) {
ArrayList<Record> lrecord = new ArrayList<>();
try {
// try {
//byte[] encoded = Files.readAllBytes(Paths.get("/home/trhuy/Downloads/02-51-34.xml"));
//ArrayList<Object> res = new ArrayList();
//res = answerMsg.getContent();
//System.out.println("\n"+res);
byte[] encoded = (byte[])answerMsg.getContent().get(0);
//byte[] encoded = (byte[])answerMsg.getContent().get(0);
String resultxml = new String(encoded, "UTF-8");
String resultxml = (String)answerMsg.getContent().get(0);
//System.out.print(resultxml);
Document doc = Jsoup.parse(resultxml);
for (Element e : doc.select("Row")) {
......@@ -59,17 +66,20 @@ public class Client {
r.setSummary(e_des.text());
lrecord.add(r);
}
} catch (IOException e) {
e.printStackTrace();
}
// } catch (IOException e) {
// e.printStackTrace();
// }
//System.out.println(lrecord.toArray());
return (Object)lrecord;
} else if (cmd.equals(Message.RESULT_DETAIL)) {
Record r = new Record();
try {
// try {
//byte[] encoded = Files.readAllBytes(Paths.get("/home/trhuy/Downloads/02-40-06.xml"));
byte[] encoded = (byte[])answerMsg.getContent().get(0);
String resultxml = new String(encoded, "UTF-8");
// /byte[] encoded = (byte[])answerMsg.getContent().get(0);
String resultxml = (String)answerMsg.getContent().get(0);
//String resultxml = new String(encoded, "UTF-8");
Document doc = Jsoup.parse(resultxml);
for (Element e : doc.select("Row")) {
......@@ -111,10 +121,12 @@ public class Client {
r.setLink(link.text());
System.out.print(r.toString());
}
} catch (IOException e) {
e.printStackTrace();
}
// } catch (IOException e) {
// e.printStackTrace();
//}
return (Object)r;
......@@ -139,12 +151,12 @@ public class Client {
return requestMsg;
}
public Message send(Message msg){
public Message send(Message msg, String server, int port){
SSLSocket sslClient = null;
try {
// Socket client = new Socket(dbaddr,dpport);
//Socket client = new Socket(dbaddr,dpport);
SSLSocketFactory sslSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
sslClient = (SSLSocket)sslSocketFactory.createSocket("LocalHost",12345);
sslClient = (SSLSocket)sslSocketFactory.createSocket(server,port);
sslClient.setEnabledCipherSuites(sslClient.getSupportedCipherSuites());
System.out.println("Client has been created successfully!");
......
......@@ -33,13 +33,13 @@ import javax.imageio.ImageIO;
public class Message implements Serializable {
public static String PIC_SRC = "test2.png";
public static String PIC_DES = "clonetest2.png";
public static String ERR_CMD = "Message command is empty";
public static String ERR_CMD2 = "Wrong message command";
public static String PIC_SRC = "server_visualisation.png";
public static String PIC_DES = "client_visualisation.png";
public static String ERR_CMD = "Message command is empty\n";
public static String ERR_CMD2 = "Wrong message command\n";
public static String SUC_CREATE_REQ_MESSAGE = "The request message is created ";
public static String SUC_CREATE_ANS_MESSAGE = "The answer message is created ";
public static String SUC_CREATE_REQ_MESSAGE = "The request message is created\n";
public static String SUC_CREATE_ANS_MESSAGE = "The answer message is created\n";
......@@ -206,8 +206,4 @@ public class Message implements Serializable {
else System.out.print("Image can't not be created!");
}
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -2,6 +2,6 @@
java -version
cd bin;
java -Xmx1024m -jar ttool.jar -config config.xml -experimental -debug -avatar -uppaal -launcher
java -Xmx1024m -jar ttool.jar -config config.xml -experimental -debug -avatar -uppaal -launcher -Djavax.net.ssl.trustStore=ServerKeyStore -Djavax.net.ssl.trustStorePassword=123456 -Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol -Djavax.net.debug=ssl
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment