diff --git a/README.md b/README.md index 9b8eda5..f3b33ba 100644 --- a/README.md +++ b/README.md @@ -14,23 +14,15 @@ It is estimated to require two servlets - one on the webhost (`mispbridge`), and
#### How to Run / Debug -* In `mispmock` run `core.Main`. +* `com.olexyn.misp.embedded.RunAll.main()`
#### How to Deploy -* Install Tomcat - * `apt-get install tomcat9` -* Start Tomcat: - * `/usr/bin/tomcat9-instance-create -p 9090 /tomcat/` - * `/tomcat/bin/startup.sh` -* Link this project to where Tomcat expects files: - * `ln -s /mispbridge/mispbridge/ /tomcat/webapps/` - * `ln -s /mispclient/mispclient/ /tomcat/webapps/` -* Set up your IDE to compile to: - * `/mispbridge/mispbridge/WEB-INF/classes/` - * `/mispclient/mispclient/WEB-INF/classes/` -* Compile the project & restart Tomcat. +* Set the URIs in code. +* Build (e.g. with `build-install-all.sh`) +* Put the generated `forward-0.1.war` in a servlet container (e.g. Jetty). +* Launch the `reverse-0.1.jar` on your host.
diff --git a/TODO.md b/TODO.md index dc3a5f6..4fbbcea 100644 --- a/TODO.md +++ b/TODO.md @@ -1,12 +1,6 @@ #### TODO -* FIX errors when setting WAIT to low. -* In `ClientMock` put `GET (Ride)(Request)(Data)` on it's own thread. - * Currently it is on the `POST (Ride)` thread. - * It would be better to "decouple" it. -* Clean the `mispmock` code. * Use real `app` - * Lower `sleep()` without breaking. * Replace `AppMock` with *guacamole* * Does *guac* take *json*? * Adjust `UserMock` to query *guac*. @@ -19,8 +13,5 @@ #### DO MAYBE -* In `ClientMock` put `GET (Request)` on it's own thread. - * Currently it is on the `POST (Ride)` thread. - * This might be tricky since - * `GET (Request)` doesn't neccessarily know `(Ride)` - * and thus need a trick (?) to be syncronized with it \ No newline at end of file +* +* \ No newline at end of file diff --git a/embedded/src/main/java/com/olexyn/misp/embedded/Embedded.java b/embedded/src/main/java/com/olexyn/misp/embedded/Embedded.java index d728ae6..e255a89 100644 --- a/embedded/src/main/java/com/olexyn/misp/embedded/Embedded.java +++ b/embedded/src/main/java/com/olexyn/misp/embedded/Embedded.java @@ -4,9 +4,7 @@ import com.olexyn.min.http.server.MinJettyServer; import com.olexyn.misp.forward.Forward; import com.olexyn.misp.mirror.Mirror; -/** - * Hello world! - */ + public class Embedded implements Runnable { diff --git a/embedded/src/main/java/com/olexyn/misp/embedded/RunAll.java b/embedded/src/main/java/com/olexyn/misp/embedded/RunAll.java index 0946d20..acdd022 100644 --- a/embedded/src/main/java/com/olexyn/misp/embedded/RunAll.java +++ b/embedded/src/main/java/com/olexyn/misp/embedded/RunAll.java @@ -6,14 +6,16 @@ public class RunAll { public static void main(String... args) throws InterruptedException { - Thread serverT = new Thread(new Embedded()); serverT.start(); Thread.sleep(2000); - Thread reverseT = new Thread(new Reverse()); + Reverse reverse = new Reverse(); + reverse.FORWARD_URL = "http://localhost:8090/forward"; + reverse.APP_URL = "http://localhost:8090/app"; + + Thread reverseT = new Thread(reverse); reverseT.start(); } - } diff --git a/forward/README.md b/forward/README.md index da391f5..df73a3c 100644 --- a/forward/README.md +++ b/forward/README.md @@ -1,5 +1,2 @@ #### About -The `mispbridge` servlet. -* `./src` the code. -* `./war/wrapper` supplements needed for `.war`. -* `./war/.war` copy this to `tomcat/webapps`. \ No newline at end of file +The `forward` servlet. \ No newline at end of file diff --git a/helper/pom.xml b/helper/pom.xml index 933767b..dad6ef5 100644 --- a/helper/pom.xml +++ b/helper/pom.xml @@ -9,9 +9,6 @@ 0.1 helper - A simple helper. - - http://www.example.com UTF-8 diff --git a/helper/src/main/java/com/olexyn/misp/helper/JsonHelper.java b/helper/src/main/java/com/olexyn/misp/helper/JsonHelper.java index d8a9b4c..a2ac94c 100644 --- a/helper/src/main/java/com/olexyn/misp/helper/JsonHelper.java +++ b/helper/src/main/java/com/olexyn/misp/helper/JsonHelper.java @@ -5,17 +5,12 @@ import org.json.JSONObject; public class JsonHelper { - - - public static boolean isJson(String string){ - try{ new JSONObject(string); }catch (JSONException | NullPointerException e){ return false; } - return true; } } diff --git a/helper/src/main/java/com/olexyn/misp/helper/Ride.java b/helper/src/main/java/com/olexyn/misp/helper/Ride.java index 4f693b7..ff8b5c1 100644 --- a/helper/src/main/java/com/olexyn/misp/helper/Ride.java +++ b/helper/src/main/java/com/olexyn/misp/helper/Ride.java @@ -13,9 +13,7 @@ public class Ride { private String request; private String data; - // FUTURE it might be possible to use a ride for many requests. - // private List requests = new ArrayList<>(); - // private Map data = new HashMap<>(); + public Ride() { diff --git a/helper/src/main/java/com/olexyn/misp/helper/WebPrint.java b/helper/src/main/java/com/olexyn/misp/helper/WebPrint.java index 820be86..e4c8c1a 100644 --- a/helper/src/main/java/com/olexyn/misp/helper/WebPrint.java +++ b/helper/src/main/java/com/olexyn/misp/helper/WebPrint.java @@ -7,27 +7,6 @@ import java.util.Map; public class WebPrint { - final static public String SPLIT = "io32413445353"; - - public static String list(List list, String type) { - StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - - for (String entry : list) { - sb.append(""); - } - - return sb.toString(); - } - public static String requestList(List list) { @@ -35,17 +14,14 @@ public class WebPrint { sb.append("
"); - sb.append("List: "); - sb.append(type); - sb.append("
"); - sb.append(entry); - sb.append("
"); - JSONObject obj = new JSONObject(list.get(0)); - Map map = obj.toMap(); - - + Map map = obj.toMap(); sb.append(""); - for (Map.Entry entry : map.entrySet()){ + for (Map.Entry entry : map.entrySet()) { sb.append(""); } sb.append(""); @@ -54,22 +30,16 @@ public class WebPrint { for (String entry : list) { JSONObject line = new JSONObject(entry); - Map map2 = line.toMap(); + Map map2 = line.toMap(); sb.append(""); - for (Map.Entry entry2 : map2.entrySet()){ + for (Map.Entry entry2 : map2.entrySet()) { sb.append(""); } sb.append(""); - } - return sb.toString(); } - - - - -} +} \ No newline at end of file diff --git a/helper/src/site/site.xml b/helper/src/site/site.xml deleted file mode 100644 index dcd7d4f..0000000 --- a/helper/src/site/site.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - misp-helper - https://maven.apache.org/images/apache-maven-project.png - https://www.apache.org/ - - - - https://maven.apache.org/images/maven-logo-black-on-white.png - https://maven.apache.org/ - - - - org.apache.maven.skins - maven-fluido-skin - 1.7 - - - - - - - \ No newline at end of file diff --git a/copy-restart.sh b/legacy/copy-restart.sh similarity index 100% rename from copy-restart.sh rename to legacy/copy-restart.sh diff --git a/threads-in-mock.png b/legacy/threads-in-mock.png similarity index 100% rename from threads-in-mock.png rename to legacy/threads-in-mock.png diff --git a/threads-in-mock.uxf b/legacy/threads-in-mock.uxf similarity index 100% rename from threads-in-mock.uxf rename to legacy/threads-in-mock.uxf diff --git a/mirror/src/main/java/com/olexyn/misp/mirror/Mirror.java b/mirror/src/main/java/com/olexyn/misp/mirror/Mirror.java index 467563e..db943cd 100644 --- a/mirror/src/main/java/com/olexyn/misp/mirror/Mirror.java +++ b/mirror/src/main/java/com/olexyn/misp/mirror/Mirror.java @@ -1,47 +1,36 @@ package com.olexyn.misp.mirror; -import com.olexyn.misp.helper.Ride; import com.olexyn.misp.helper.WebPrint; -import org.apache.commons.io.IOUtils; import org.json.JSONObject; -import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class Mirror extends HttpServlet { - - private final List list = new ArrayList<>(); - - private void addRequest(HttpServletRequest request){ + private void addRequest(HttpServletRequest request) { synchronized (list) { JSONObject obj = new JSONObject(); obj.put("RequestURL", request.getRequestURL()); - obj.put("RemoteAddr" , request.getRemoteAddr()); + obj.put("RemoteAddr", request.getRemoteAddr()); obj.put("Method", request.getMethod()); obj.put("Param", request.getParameterMap().toString()); obj.put("QueryString", request.getQueryString()); - obj.put("ContextPath",request.getContextPath()); - + obj.put("ContextPath", request.getContextPath()); list.add(obj.toString()); } } - // ####### - // - // ####### + @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -51,7 +40,6 @@ public class Mirror extends HttpServlet { PrintWriter print = response.getWriter(); print.println(""); - print.println(""); print.println(""); print.println(""); @@ -60,31 +48,18 @@ public class Mirror extends HttpServlet { print.println(""); print.println(""); print.println(""); - synchronized (list) { - - print.println(WebPrint.requestList(list)); - } - - - - + synchronized (list) { print.println(WebPrint.requestList(list)); } print.println(" "); - - } @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) { - - addRequest(request); - } + public void doPost(HttpServletRequest request, HttpServletResponse response) { addRequest(request); } @Override - public void doPut(HttpServletRequest request, HttpServletResponse response){ - addRequest(request); - } + public void doPut(HttpServletRequest request, HttpServletResponse response) { addRequest(request); } + } diff --git a/onion-diagram.uxf b/onion-diagram.uxf deleted file mode 100644 index a0a6a87..0000000 --- a/onion-diagram.uxf +++ /dev/null @@ -1,204 +0,0 @@ - - - 10 - - UMLClass - - 670 - 1040 - 130 - 30 - - TinyVNC - - - - UMLClass - - 670 - 1010 - 130 - 30 - - Guacamole - - - - UMLClass - - 650 - 970 - 170 - 150 - - Debian VM - - - - UMLClass - - 630 - 910 - 210 - 230 - - VirtualBox -layer=-1 - - - - UMLClass - - 670 - 1070 - 130 - 30 - - JavaFX - - - - UMLClass - - 650 - 940 - 170 - 30 - - Bridged Connection - - - - UMLClass - - 610 - 880 - 250 - 280 - - Debian Host -layer=-1 - - - - UMLClass - - 670 - 760 - 130 - 30 - - 4G Modem - - - - UMLClass - - 910 - 610 - 100 - 30 - - URL - - - - UMLClass - - 650 - 580 - 170 - 80 - - Hosting Provider - - - - UMLClass - - 910 - 760 - 100 - 30 - - IP / Port - - - - UMLClass - - 910 - 940 - 100 - 30 - - IP / Port - - - - Relation - - 960 - 780 - 30 - 180 - - lt=<-> - 10.0;10.0;10.0;160.0 - - - UMLClass - - 670 - 610 - 130 - 30 - - WordPress - - - - Relation - - 810 - 940 - 120 - 30 - - lt=- - 100.0;10.0;10.0;10.0 - - - Relation - - 790 - 760 - 140 - 30 - - lt=- - 120.0;10.0;10.0;10.0 - - - Relation - - 960 - 630 - 30 - 150 - - lt=<-> - 10.0;10.0;10.0;130.0 - - - Relation - - 790 - 610 - 140 - 30 - - lt=- - 120.0;10.0;10.0;10.0 - - diff --git a/run.sh b/run.sh deleted file mode 100755 index b3b399e..0000000 --- a/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -./make-war.sh -./copy-restart.sh \ No newline at end of file
"); - sb.append( entry.getKey()); + sb.append(entry.getKey()); sb.append("
"); sb.append(entry2.getValue().toString()); sb.append("