parent
2f6e088480
commit
76b6278936
@ -1,92 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "================"
|
|
||||||
echo "START RUN"
|
|
||||||
echo "================"
|
|
||||||
cwd=$(pwd)
|
|
||||||
|
|
||||||
|
|
||||||
# compile and distribute the misphelper.jar
|
|
||||||
cd "${cwd}/out/production/misphelper" || exit
|
|
||||||
|
|
||||||
jar -cvf misphelper.jar ./com/olexyn/misp/helper/*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "================"
|
|
||||||
echo "END MispHelper JAR"
|
|
||||||
echo "================"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
a='misp'
|
|
||||||
b='bridge'
|
|
||||||
|
|
||||||
|
|
||||||
n="${a}${b}"
|
|
||||||
pkg="/com/olexyn/${a}/${b}"
|
|
||||||
out="/out/production/${n}${pkg}"
|
|
||||||
wrapper="/${n}/war/wrapper"
|
|
||||||
|
|
||||||
# copy misphelper.jar to wrapper/.../lib
|
|
||||||
cp -v"${cwd}/out/production/misphelper/misphelper.jar" "${cwd}${wrapper}/WEB-INF/lib"
|
|
||||||
|
|
||||||
# copy compiled code into the wrapper.
|
|
||||||
cp -vr "${cwd}${out}" "${cwd}${wrapper}/WEB-INF/classes/com/olexyn/${a}"
|
|
||||||
|
|
||||||
# compress .war
|
|
||||||
cd "${cwd}${wrapper}" || exit
|
|
||||||
jar -cvf "../${n}.war" *
|
|
||||||
|
|
||||||
|
|
||||||
echo "================"
|
|
||||||
echo "END MispBridge WAR"
|
|
||||||
echo "================"
|
|
||||||
|
|
||||||
|
|
||||||
a='misp'
|
|
||||||
b='client'
|
|
||||||
|
|
||||||
|
|
||||||
n="${a}${b}"
|
|
||||||
pkg="/com/olexyn/${a}/${b}"
|
|
||||||
out="/out/production/${n}${pkg}"
|
|
||||||
wrapper="/${n}/war/wrapper"
|
|
||||||
|
|
||||||
# copy misphelper.jar to wrapper/.../lib
|
|
||||||
cp -v "${cwd}/out/production/misphelper/misphelper.jar" "${cwd}${wrapper}/WEB-INF/lib"
|
|
||||||
|
|
||||||
# copy compiled code into the wrapper.
|
|
||||||
cp -vr "${cwd}${out}" "${cwd}${wrapper}/WEB-INF/classes/com/olexyn/${a}"
|
|
||||||
|
|
||||||
# compress .war
|
|
||||||
cd "${cwd}${wrapper}" || exit
|
|
||||||
jar -cvf "../${n}.war" *
|
|
||||||
|
|
||||||
|
|
||||||
echo "================"
|
|
||||||
echo "END MispClient WAR"
|
|
||||||
echo "================"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
a='mirror'
|
|
||||||
|
|
||||||
pkg="/com/olexyn/${a}"
|
|
||||||
out="/out/production/${a}${pkg}"
|
|
||||||
wrapper="/${a}/war/wrapper"
|
|
||||||
|
|
||||||
# copy misphelper.jar to wrapper/.../lib
|
|
||||||
cp -v "${cwd}/out/production/misphelper/misphelper.jar" "${cwd}${wrapper}/WEB-INF/lib"
|
|
||||||
|
|
||||||
# copy compiled code into the wrapper.
|
|
||||||
cp -vr "${cwd}${out}" "${cwd}${wrapper}/WEB-INF/classes/com/olexyn"
|
|
||||||
|
|
||||||
# compress .war
|
|
||||||
cd "${cwd}${wrapper}" || exit
|
|
||||||
jar -cvf "../${a}.war" *
|
|
||||||
|
|
||||||
echo "================"
|
|
||||||
echo "END Mirror WAR"
|
|
||||||
echo "================"
|
|
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<project name="mirror" basedir="." default="war">
|
||||||
|
|
||||||
|
<!-- DEFINE SOME VARS -->
|
||||||
|
<property name="appname" value="mirror" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<path id="compile.classpath">
|
||||||
|
<fileset dir="lib">
|
||||||
|
<include name="*.jar"/>
|
||||||
|
</fileset>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<!-- INIT -->
|
||||||
|
<target name="init">
|
||||||
|
<mkdir dir="build/classes"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- COMPILE -->
|
||||||
|
<target name="compile" depends="init" >
|
||||||
|
<javac destdir="build/classes" debug="true" srcdir="src">
|
||||||
|
<classpath refid="compile.classpath"/>
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- WAR -->
|
||||||
|
<target name="war" depends="compile">
|
||||||
|
<war destfile="${appname}A.war" webxml="web.xml">
|
||||||
|
<fileset dir="web"/>
|
||||||
|
<lib dir="lib"/>
|
||||||
|
<classes dir="build/classes"/>
|
||||||
|
</war>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="clean">
|
||||||
|
<delete dir="build" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
Binary file not shown.
Binary file not shown.
@ -1,4 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
Ant-Version: Apache Ant 1.6.5
|
|
||||||
Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
version="0.1"
|
||||||
|
file="target/misp-fwd-${version}.war"
|
||||||
|
groupId="com.olexyn.misp.fwd"
|
||||||
|
artifactId="misp-fwd"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mvn package
|
||||||
|
mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=war -DgeneratePom=true
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
|
<orderEntry type="module" module-name="misp-helper" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.json:json:20190722" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,97 @@
|
|||||||
|
<?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>com.olexyn.misp.fwd</groupId>
|
||||||
|
<artifactId>misp-fwd</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<name>misp-fwd Maven Webapp</name>
|
||||||
|
<!-- FIXME change it to the project's website -->
|
||||||
|
<url>http://www.example.com</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.olexyn.misp.helper</groupId>
|
||||||
|
<artifactId>misp-helper</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||||
|
<artifactId>javax.servlet</artifactId>
|
||||||
|
<version>3.0.0.v201112011016</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20190722</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<!-- or whatever version you use -->
|
||||||
|
<source>11</source>
|
||||||
|
<target>11</target>
|
||||||
|
<verbose>true</verbose>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.2.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>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE web-app PUBLIC
|
||||||
|
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||||
|
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||||
|
|
||||||
|
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||||
|
version="2.4">
|
||||||
|
|
||||||
|
<display-name>misp-fwd</display-name>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>misp-fwd</servlet-name>
|
||||||
|
<servlet-class>com.olexyn.misp.fwd.FwdProxy</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>misp-fwd</servlet-name>
|
||||||
|
<url-pattern>/core</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
</web-app>
|
After Width: | Height: | Size: 617 B |
@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>misp-fwd</title>
|
||||||
|
</head>
|
||||||
|
<body bgcolor=white>
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<tr>
|
||||||
|
<td align=center>
|
||||||
|
<img src="images/io42630.png">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h1>misp-fwd</h1>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
#Created by Apache Maven 3.6.3
|
||||||
|
groupId=com.olexyn.misp.fwd
|
||||||
|
artifactId=misp-fwd
|
||||||
|
version=0.1
|
@ -0,0 +1 @@
|
|||||||
|
com/olexyn/misp/fwd/BridgeServlet.class
|
@ -0,0 +1 @@
|
|||||||
|
/home/user/ws/idea/misp/misp-fwd/src/main/java/com/olexyn/misp/fwd/BridgeServlet.java
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE web-app PUBLIC
|
||||||
|
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||||
|
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||||
|
|
||||||
|
<web-app>
|
||||||
|
<display-name>Archetype Created Web Application</display-name>
|
||||||
|
</web-app>
|
@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h2>Hello World!</h2>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
version="0.1"
|
||||||
|
file="target/misp-helper-${version}.jar"
|
||||||
|
groupId="com.olexyn.misp.helper"
|
||||||
|
artifactId="misp-helper"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mvn package
|
||||||
|
mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar -DgeneratePom=true
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="org.json:json:20190722" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: junit:junit:3.8.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.json:json:20190722" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,87 @@
|
|||||||
|
<?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>com.olexyn.misp.helper</groupId>
|
||||||
|
<artifactId>misp-helper</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
|
||||||
|
<name>misp-helper</name>
|
||||||
|
<description>A simple misp-helper.</description>
|
||||||
|
<!-- 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.11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.11</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20190722</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<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>
|
||||||
|
<!-- see http://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>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
</project>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project name="misp-helper" xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd">
|
||||||
|
<bannerLeft>
|
||||||
|
<name>misp-helper</name>
|
||||||
|
<src>https://maven.apache.org/images/apache-maven-project.png</src>
|
||||||
|
<href>https://www.apache.org/</href>
|
||||||
|
</bannerLeft>
|
||||||
|
|
||||||
|
<bannerRight>
|
||||||
|
<src>https://maven.apache.org/images/maven-logo-black-on-white.png</src>
|
||||||
|
<href>https://maven.apache.org/</href>
|
||||||
|
</bannerRight>
|
||||||
|
|
||||||
|
<skin>
|
||||||
|
<groupId>org.apache.maven.skins</groupId>
|
||||||
|
<artifactId>maven-fluido-skin</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
</skin>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<menu ref="parent" />
|
||||||
|
<menu ref="reports" />
|
||||||
|
</body>
|
||||||
|
</project>
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.olexyn.misp.helper;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
public class AppTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the test case
|
||||||
|
*
|
||||||
|
* @param testName name of the test case
|
||||||
|
*/
|
||||||
|
public AppTest( String testName )
|
||||||
|
{
|
||||||
|
super( testName );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the suite of tests being tested
|
||||||
|
*/
|
||||||
|
public static Test suite()
|
||||||
|
{
|
||||||
|
return new TestSuite( AppTest.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rigourous Test :-)
|
||||||
|
*/
|
||||||
|
public void testApp()
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
#Created by Apache Maven 3.6.3
|
||||||
|
version=0.1
|
||||||
|
groupId=com.olexyn.misp.helper
|
||||||
|
artifactId=misp-helper
|
@ -0,0 +1,3 @@
|
|||||||
|
com/olexyn/misp/helper/JsonHelper.class
|
||||||
|
com/olexyn/misp/helper/Ride.class
|
||||||
|
com/olexyn/misp/helper/WebPrint.class
|
@ -0,0 +1,3 @@
|
|||||||
|
/home/user/ws/idea/misp/misp-helper/src/main/java/com/olexyn/misp/helper/Ride.java
|
||||||
|
/home/user/ws/idea/misp/misp-helper/src/main/java/com/olexyn/misp/helper/JsonHelper.java
|
||||||
|
/home/user/ws/idea/misp/misp-helper/src/main/java/com/olexyn/misp/helper/WebPrint.java
|
@ -0,0 +1 @@
|
|||||||
|
com/olexyn/misp/helper/AppTest.class
|
@ -0,0 +1 @@
|
|||||||
|
/home/user/ws/idea/misp/misp-helper/src/test/java/com/olexyn/misp/helper/AppTest.java
|
Binary file not shown.
@ -0,0 +1,61 @@
|
|||||||
|
<?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="com.olexyn.misp.helper.AppTest" time="0.004" tests="1" errors="0" skipped="0" failures="0">
|
||||||
|
<properties>
|
||||||
|
<property name="awt.toolkit" value="sun.awt.X11.XToolkit"/>
|
||||||
|
<property name="file.encoding.pkg" value="sun.io"/>
|
||||||
|
<property name="java.specification.version" value="1.8"/>
|
||||||
|
<property name="sun.cpu.isalist" value=""/>
|
||||||
|
<property name="sun.jnu.encoding" value="UTF-8"/>
|
||||||
|
<property name="java.class.path" value="/home/user/ws/idea/misp/misp-helper/target/test-classes:/home/user/ws/idea/misp/misp-helper/target/classes:/home/user/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/home/user/.m2/repository/org/json/json/20190722/json-20190722.jar:"/>
|
||||||
|
<property name="java.vm.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="sun.arch.data.model" value="64"/>
|
||||||
|
<property name="java.vendor.url" value="http://java.oracle.com/"/>
|
||||||
|
<property name="user.timezone" value=""/>
|
||||||
|
<property name="java.vm.specification.version" value="1.8"/>
|
||||||
|
<property name="os.name" value="Linux"/>
|
||||||
|
<property name="user.country" value="US"/>
|
||||||
|
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
||||||
|
<property name="sun.boot.library.path" value="/usr/lib/jvm/jdk1.8.0_162/jre/lib/amd64"/>
|
||||||
|
<property name="sun.java.command" value="/home/user/ws/idea/misp/misp-helper/target/surefire/surefirebooter7699255088655101384.jar /home/user/ws/idea/misp/misp-helper/target/surefire 2020-04-24T15-12-27_079-jvmRun1 surefire7232622910076852984tmp surefire_06057149576369880631tmp"/>
|
||||||
|
<property name="surefire.test.class.path" value="/home/user/ws/idea/misp/misp-helper/target/test-classes:/home/user/ws/idea/misp/misp-helper/target/classes:/home/user/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/home/user/.m2/repository/org/json/json/20190722/json-20190722.jar:"/>
|
||||||
|
<property name="sun.cpu.endian" value="little"/>
|
||||||
|
<property name="user.home" value="/home/user"/>
|
||||||
|
<property name="user.language" value="en"/>
|
||||||
|
<property name="java.specification.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.home" value="/usr/lib/jvm/jdk1.8.0_162/jre"/>
|
||||||
|
<property name="basedir" value="/home/user/ws/idea/misp/misp-helper"/>
|
||||||
|
<property name="file.separator" value="/"/>
|
||||||
|
<property name="line.separator" value=" "/>
|
||||||
|
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.specification.name" value="Java Platform API Specification"/>
|
||||||
|
<property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/>
|
||||||
|
<property name="surefire.real.class.path" value="/home/user/ws/idea/misp/misp-helper/target/surefire/surefirebooter7699255088655101384.jar"/>
|
||||||
|
<property name="sun.boot.class.path" value="/usr/lib/jvm/jdk1.8.0_162/jre/lib/resources.jar:/usr/lib/jvm/jdk1.8.0_162/jre/lib/rt.jar:/usr/lib/jvm/jdk1.8.0_162/jre/lib/sunrsasign.jar:/usr/lib/jvm/jdk1.8.0_162/jre/lib/jsse.jar:/usr/lib/jvm/jdk1.8.0_162/jre/lib/jce.jar:/usr/lib/jvm/jdk1.8.0_162/jre/lib/charsets.jar:/usr/lib/jvm/jdk1.8.0_162/jre/lib/jfr.jar:/usr/lib/jvm/jdk1.8.0_162/jre/classes"/>
|
||||||
|
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
||||||
|
<property name="java.runtime.version" value="1.8.0_162-b12"/>
|
||||||
|
<property name="user.name" value="user"/>
|
||||||
|
<property name="path.separator" value=":"/>
|
||||||
|
<property name="os.version" value="4.19.0-4-amd64"/>
|
||||||
|
<property name="java.endorsed.dirs" value="/usr/lib/jvm/jdk1.8.0_162/jre/lib/endorsed"/>
|
||||||
|
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
|
||||||
|
<property name="file.encoding" value="UTF-8"/>
|
||||||
|
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
|
||||||
|
<property name="localRepository" value="/home/user/.m2/repository"/>
|
||||||
|
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
|
||||||
|
<property name="java.io.tmpdir" value="/tmp"/>
|
||||||
|
<property name="java.version" value="1.8.0_162"/>
|
||||||
|
<property name="user.dir" value="/home/user/ws/idea/misp/misp-helper"/>
|
||||||
|
<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="/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib"/>
|
||||||
|
<property name="java.vm.info" value="mixed mode"/>
|
||||||
|
<property name="java.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.vm.version" value="25.162-b12"/>
|
||||||
|
<property name="java.ext.dirs" value="/usr/lib/jvm/jdk1.8.0_162/jre/lib/ext:/usr/java/packages/lib/ext"/>
|
||||||
|
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
||||||
|
<property name="java.class.version" value="52.0"/>
|
||||||
|
</properties>
|
||||||
|
<testcase name="testApp" classname="com.olexyn.misp.helper.AppTest" time="0.001"/>
|
||||||
|
</testsuite>
|
@ -0,0 +1,4 @@
|
|||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Test set: com.olexyn.misp.helper.AppTest
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s - in com.olexyn.misp.helper.AppTest
|
Binary file not shown.
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
version="0.1"
|
||||||
|
file="target/misp-rev-${version}.war"
|
||||||
|
groupId="com.olexyn.misp.rev"
|
||||||
|
artifactId="misp-rev"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mvn package
|
||||||
|
mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=war -DgeneratePom=true
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
|
<orderEntry type="module" module-name="misp-helper" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.json:json:20190722" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,90 @@
|
|||||||
|
<?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>com.olexyn.misp.rev</groupId>
|
||||||
|
<artifactId>misp-rev</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<name>misp-rev Maven Webapp</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>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.olexyn.misp.helper</groupId>
|
||||||
|
<artifactId>misp-helper</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||||
|
<artifactId>javax.servlet</artifactId>
|
||||||
|
<version>3.0.0.v201112011016</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20190722</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_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-war-plugin</artifactId>
|
||||||
|
<version>3.2.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>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.olexyn.misp.rev;
|
||||||
|
|
||||||
|
import com.olexyn.misp.helper.Ride;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class ConnectionHelper {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.olexyn.misp.rev;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String... args){
|
||||||
|
new RevProxy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
package com.olexyn.misp.rev;
|
||||||
|
|
||||||
|
|
||||||
|
import com.olexyn.misp.helper.Ride;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class RevProxy {
|
||||||
|
|
||||||
|
protected static final String MISP_BRIDGE_URL = "http://localhost:9090/mispbridge/core";
|
||||||
|
protected static final String APP_URL = "http://localhost:9090/mirror/core";
|
||||||
|
|
||||||
|
public static final int AVAILABLE_RIDES_OVERHEAD_TRIGGER = 4;
|
||||||
|
public static final int AVAILABLE_RIDES_OVERHEAD = 8;
|
||||||
|
|
||||||
|
|
||||||
|
public final Map<Long, Ride> available = new HashMap<>();
|
||||||
|
public final Map<Long, Ride> booked = new HashMap<>();
|
||||||
|
public final Map<Long, Ride> loaded = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
public RevProxy() {
|
||||||
|
|
||||||
|
Thread postRideThread = new Thread(new PostRideRunnable(this));
|
||||||
|
postRideThread.setName("postRideThread");
|
||||||
|
postRideThread.start();
|
||||||
|
|
||||||
|
Thread getRequestThread = new Thread(new GetRequestRunnable(this));
|
||||||
|
getRequestThread.setName("getRequestThread");
|
||||||
|
getRequestThread.start();
|
||||||
|
|
||||||
|
Thread getRideRequestDataThread = new Thread(new GetRideRequestDataRunnable(this));
|
||||||
|
getRideRequestDataThread.setName("getRideRequestDataThread");
|
||||||
|
getRideRequestDataThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sendPostRide() throws IOException {
|
||||||
|
|
||||||
|
final Ride ride = new Ride();
|
||||||
|
|
||||||
|
synchronized (available) { available.put(ride.getID(), ride); }
|
||||||
|
|
||||||
|
final String result = send("POST", MISP_BRIDGE_URL, ride.json());
|
||||||
|
|
||||||
|
synchronized (available) {
|
||||||
|
available.remove(ride.getID());
|
||||||
|
ride.setRequest(new Ride(result).getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (booked) { booked.put(ride.getID(), ride); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sendGetRequest(Ride ride) throws IOException {
|
||||||
|
|
||||||
|
synchronized (booked) {booked.remove(ride.getID()); }
|
||||||
|
|
||||||
|
final String result = send("GET", APP_URL, ride.getRequest());
|
||||||
|
ride.setData(result);
|
||||||
|
|
||||||
|
synchronized (loaded) {loaded.put(ride.getID(), ride); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sendGetRideRequestData(Ride ride) throws IOException {
|
||||||
|
|
||||||
|
send("GET", MISP_BRIDGE_URL, ride.json());
|
||||||
|
|
||||||
|
synchronized (loaded) {loaded.remove(ride.getID()); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String send(String method, String urlString, String body) throws IOException {
|
||||||
|
|
||||||
|
URL url = new URL(urlString);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod(method);
|
||||||
|
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||||
|
outputStream.writeBytes(body);
|
||||||
|
outputStream.flush();
|
||||||
|
outputStream.close();
|
||||||
|
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String out;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while ((out = in.readLine()) != null) { sb.append(out); }
|
||||||
|
in.close();
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class PostRideRunnable implements Runnable {
|
||||||
|
|
||||||
|
final private RevProxy adapter;
|
||||||
|
|
||||||
|
public PostRideRunnable(RevProxy adapter) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (true) {
|
||||||
|
synchronized (adapter.available) {
|
||||||
|
if (adapter.available.size() < RevProxy.AVAILABLE_RIDES_OVERHEAD_TRIGGER) {
|
||||||
|
for (int i = 0; i < RevProxy.AVAILABLE_RIDES_OVERHEAD; i++) {
|
||||||
|
try {adapter.sendPostRide();} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class GetRequestRunnable implements Runnable {
|
||||||
|
|
||||||
|
final private RevProxy adapter;
|
||||||
|
|
||||||
|
public GetRequestRunnable(RevProxy adapter) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (true) {
|
||||||
|
synchronized (adapter.booked) {
|
||||||
|
if (adapter.booked.size() > 0) {
|
||||||
|
final Ride ride = adapter.booked.entrySet().iterator().next().getValue();
|
||||||
|
try { adapter.sendGetRequest(ride); } catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetRideRequestDataRunnable implements Runnable {
|
||||||
|
|
||||||
|
final private RevProxy adapter;
|
||||||
|
|
||||||
|
public GetRideRequestDataRunnable(RevProxy adapter) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (true) {
|
||||||
|
synchronized (adapter.loaded) {
|
||||||
|
if (adapter.loaded.size() > 0) {
|
||||||
|
final Ride ride = adapter.loaded.entrySet().iterator().next().getValue();
|
||||||
|
try { adapter.sendGetRideRequestData(ride); } catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE web-app PUBLIC
|
||||||
|
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||||
|
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||||
|
|
||||||
|
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||||
|
version="2.4">
|
||||||
|
|
||||||
|
<display-name>misp-fwd</display-name>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>misp-rev</servlet-name>
|
||||||
|
<servlet-class>com.olexyn.misp.rev.RevProxy</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>misp-rev</servlet-name>
|
||||||
|
<url-pattern>/core</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
</web-app>
|
After Width: | Height: | Size: 617 B |
@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>misp-rev</title>
|
||||||
|
</head>
|
||||||
|
<body bgcolor=white>
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<tr>
|
||||||
|
<td align=center>
|
||||||
|
<img src="images/io42630.png">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h1>misp-rev</h1>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,4 @@
|
|||||||
|
#Created by Apache Maven 3.6.3
|
||||||
|
groupId=com.olexyn.misp.rev
|
||||||
|
artifactId=misp-rev
|
||||||
|
version=0.1
|
@ -0,0 +1,6 @@
|
|||||||
|
com/olexyn/misp/rev/PostRideRunnable.class
|
||||||
|
com/olexyn/misp/rev/GetRideRequestDataRunnable.class
|
||||||
|
com/olexyn/misp/rev/Main.class
|
||||||
|
com/olexyn/misp/rev/ConnectionHelper.class
|
||||||
|
com/olexyn/misp/rev/GetRequestRunnable.class
|
||||||
|
com/olexyn/misp/rev/RevProxy.class
|
@ -0,0 +1,3 @@
|
|||||||
|
/home/user/ws/idea/misp/misp-rev/src/main/java/com/olexyn/misp/rev/Main.java
|
||||||
|
/home/user/ws/idea/misp/misp-rev/src/main/java/com/olexyn/misp/rev/RevProxy.java
|
||||||
|
/home/user/ws/idea/misp/misp-rev/src/main/java/com/olexyn/misp/rev/ConnectionHelper.java
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE web-app PUBLIC
|
||||||
|
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||||
|
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||||
|
|
||||||
|
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||||
|
version="2.4">
|
||||||
|
|
||||||
|
<display-name>misp-fwd</display-name>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>misp-rev</servlet-name>
|
||||||
|
<servlet-class>com.olexyn.misp.rev.RevProxy</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>misp-rev</servlet-name>
|
||||||
|
<url-pattern>/core</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
</web-app>
|
After Width: | Height: | Size: 617 B |
@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>misp-rev</title>
|
||||||
|
</head>
|
||||||
|
<body bgcolor=white>
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<tr>
|
||||||
|
<td align=center>
|
||||||
|
<img src="images/io42630.png">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h1>misp-rev</h1>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,183 +0,0 @@
|
|||||||
package com.olexyn.misp.adapter;
|
|
||||||
|
|
||||||
|
|
||||||
import com.olexyn.misp.helper.Ride;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
public class Adapter {
|
|
||||||
|
|
||||||
protected static final String MISP_BRIDGE_URL = "http://localhost:9090/mispbridge/core";
|
|
||||||
protected static final String APP_URL = "http://localhost:9090/mirror/core";
|
|
||||||
|
|
||||||
public static final int AVAILABLE_RIDES_OVERHEAD_TRIGGER = 2;
|
|
||||||
public static final int AVAILABLE_RIDES_OVERHEAD = 4;
|
|
||||||
|
|
||||||
|
|
||||||
public final Map<Long, Ride> available = new HashMap<>();
|
|
||||||
public final Map<Long, Ride> booked = new HashMap<>();
|
|
||||||
public final Map<Long, Ride> loaded = new HashMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
public Adapter() {
|
|
||||||
|
|
||||||
// Thread : while AvailableRides < 256 , add Ride to AvailableRides , send POST (Ride) [DONE]
|
|
||||||
Thread postRideThread = new Thread(new PostRideRunnable(this));
|
|
||||||
postRideThread.setName("postRideThread");
|
|
||||||
postRideThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generated by Loop.
|
|
||||||
* Prepare payload for the request.
|
|
||||||
* Process the parsed response.
|
|
||||||
*/
|
|
||||||
final void sendPostRide() throws IOException, InterruptedException, ServletException {
|
|
||||||
|
|
||||||
final Ride ride = new Ride();
|
|
||||||
|
|
||||||
synchronized (available) {
|
|
||||||
available.put(ride.getID(), ride);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Ride parsedRide = doSendPostRide(ride);
|
|
||||||
|
|
||||||
synchronized (available) {
|
|
||||||
available.remove(ride.getID());
|
|
||||||
ride.setRequest(parsedRide.getRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (booked) {
|
|
||||||
booked.put(ride.getID(), ride);
|
|
||||||
}
|
|
||||||
sendGetRequest(ride);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send POST (Ride).
|
|
||||||
* Parse response.
|
|
||||||
*/
|
|
||||||
protected Ride doSendPostRide(Ride ride) throws IOException, InterruptedException, ServletException {
|
|
||||||
// send POST (Ride)
|
|
||||||
final HttpURLConnection connection = ConnectionHelper.make("POST", MISP_BRIDGE_URL);
|
|
||||||
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
|
||||||
outputStream.writeBytes(ride.json());
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
|
|
||||||
Ride rideXa= ConnectionHelper.parseRide(connection);
|
|
||||||
rideXa.setRequest("ff");
|
|
||||||
return rideXa;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare payload for the request.
|
|
||||||
* Process the parsed response.
|
|
||||||
*/
|
|
||||||
final void sendGetRequest(Ride ride) throws IOException, InterruptedException {
|
|
||||||
|
|
||||||
|
|
||||||
ride.setData(doSendGetRequest(ride.getRequest()));
|
|
||||||
|
|
||||||
synchronized (booked) {
|
|
||||||
booked.remove(ride.getID());
|
|
||||||
}
|
|
||||||
synchronized (loaded) {
|
|
||||||
loaded.put(ride.getID(), ride);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendGetRideRequestData(ride);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send GET (Request) to App.
|
|
||||||
* Parse response.
|
|
||||||
*/
|
|
||||||
protected String doSendGetRequest(String request) throws IOException, InterruptedException {
|
|
||||||
|
|
||||||
// send GET (Ride)
|
|
||||||
final HttpURLConnection connection = ConnectionHelper.make("GET", APP_URL);
|
|
||||||
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
|
||||||
outputStream.writeBytes(request);
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
|
|
||||||
return ConnectionHelper.parseString(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare payload for the request.
|
|
||||||
* Process the parsed response.
|
|
||||||
*/
|
|
||||||
final protected void sendGetRideRequestData(Ride ride) throws IOException, InterruptedException {
|
|
||||||
doSendGetRideRequest(ride);
|
|
||||||
synchronized (loaded) {
|
|
||||||
loaded.remove(ride.getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send GET (Ride)(Request)(Data).
|
|
||||||
* Parse response.
|
|
||||||
*/
|
|
||||||
protected void doSendGetRideRequest(Ride ride) throws IOException, InterruptedException {
|
|
||||||
|
|
||||||
HttpURLConnection connection = ConnectionHelper.make("GET", MISP_BRIDGE_URL);
|
|
||||||
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
|
||||||
outputStream.writeBytes(ride.json());
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* While AvailableRides < 256 ,
|
|
||||||
* add Ride to AvailableRides ,
|
|
||||||
* send POST (Ride).
|
|
||||||
*/
|
|
||||||
class PostRideRunnable implements Runnable {
|
|
||||||
|
|
||||||
Adapter adapter;
|
|
||||||
|
|
||||||
public PostRideRunnable(Adapter adapter) {
|
|
||||||
this.adapter = adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (true) {
|
|
||||||
if (adapter.available.size() < Adapter.AVAILABLE_RIDES_OVERHEAD_TRIGGER) {
|
|
||||||
for (int i = 0; i < Adapter.AVAILABLE_RIDES_OVERHEAD; i++) {
|
|
||||||
try {adapter.sendPostRide();} catch (IOException | InterruptedException | ServletException e) { e.printStackTrace(); }
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
package com.olexyn.misp.adapter;
|
|
||||||
|
|
||||||
import com.olexyn.misp.helper.Ride;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
public class ConnectionHelper {
|
|
||||||
|
|
||||||
|
|
||||||
public static HttpURLConnection make(String method, String urlString) throws IOException {
|
|
||||||
URL url = new URL(urlString);
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
connection.setRequestMethod(method);
|
|
||||||
connection.setRequestProperty("User-Agent", "USER_AGENT");
|
|
||||||
connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
|
|
||||||
connection.setRequestProperty("Content-Type", "application/json");
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Ride parseRide(HttpURLConnection connection) throws IOException {
|
|
||||||
return new Ride(parseString(connection));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parseString(HttpURLConnection connection) throws IOException {
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
||||||
String out;
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
while ((out = in.readLine()) != null) { sb.append(out); }
|
|
||||||
in.close();
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package com.olexyn.misp.adapter;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void Main(String... args){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,67 @@
|
|||||||
|
<?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>com.olexyn.app.sub</groupId>
|
||||||
|
<artifactId>aub-app</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<name>aub-app Maven Webapp</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>
|
||||||
|
<finalName>aub-app</finalName>
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_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-war-plugin</artifactId>
|
||||||
|
<version>3.2.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>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<project name="misphelper" basedir="." default="dist">
|
||||||
|
|
||||||
|
<!-- DEFINE SOME VARS -->
|
||||||
|
<property name="appname" value="misphelper" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- INIT -->
|
||||||
|
<target name="init">
|
||||||
|
<mkdir dir="build/classes"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- COMPILE -->
|
||||||
|
<target name="compile" depends="init" >
|
||||||
|
<javac destdir="build/classes" debug="true" srcdir="src"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- DIST -->
|
||||||
|
<target name="dist" depends="compile">
|
||||||
|
<jar destfile="${appname}A.jar" basedir="build/classes"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="clean">
|
||||||
|
<delete dir="build" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,22 @@
|
|||||||
|
<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>com.olexyn.misp.helper</groupId>
|
||||||
|
<artifactId>misphelper</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20190722</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
|||||||
|
#Generated by Maven
|
||||||
|
#Fri Apr 24 00:43:07 CEST 2020
|
||||||
|
version=1.0-SNAPSHOT
|
||||||
|
groupId=com.olexyn.misp.helper
|
||||||
|
artifactId=misphelper
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue