First commit

This commit is contained in:
2024-11-15 14:13:38 +07:00
parent df8e665e15
commit ec427a70b8
3 changed files with 74 additions and 65 deletions

View File

@@ -1,28 +1,30 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="io.javalin" type="repository"> <library name="io.javalin" type="repository">
<properties maven-id="io.javalin:javalin:6.3.0" /> <properties maven-id="io.javalin:javalin:4.6.8" />
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/javalin/javalin/6.3.0/javalin-6.3.0.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/io/javalin/javalin/4.6.8/javalin-4.6.8.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/2.0.16/slf4j-api-2.0.16.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-server/11.0.23/jetty-server-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-server/9.4.51.v20230217/jetty-server-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-http/11.0.23/jetty-http-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util/11.0.23/jetty-util-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-http/9.4.51.v20230217/jetty-http-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-io/11.0.23/jetty-io-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util/9.4.51.v20230217/jetty-util-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/toolchain/jetty-jakarta-servlet-api/5.0.2/jetty-jakarta-servlet-api-5.0.2.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-io/9.4.51.v20230217/jetty-io-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-jetty-server/11.0.23/websocket-jetty-server-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-webapp/9.4.51.v20230217/jetty-webapp-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-servlet/11.0.23/jetty-servlet-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-xml/9.4.51.v20230217/jetty-xml-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-security/11.0.23/jetty-security-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-servlet/9.4.51.v20230217/jetty-servlet-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-webapp/11.0.23/jetty-webapp-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-security/9.4.51.v20230217/jetty-security-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-xml/11.0.23/jetty-xml-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util-ajax/9.4.51.v20230217/jetty-util-ajax-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-jetty-api/11.0.23/websocket-jetty-api-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-server/9.4.51.v20230217/websocket-server-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-jetty-common/11.0.23/websocket-jetty-common-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-common/9.4.51.v20230217/websocket-common-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-core-common/11.0.23/websocket-core-common-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-api/9.4.51.v20230217/websocket-api-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-servlet/11.0.23/websocket-servlet-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-client/9.4.51.v20230217/websocket-client-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-core-server/11.0.23/websocket-core-server-11.0.23.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-client/9.4.51.v20230217/jetty-client-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.25/kotlin-stdlib-jdk8-1.9.25.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-servlet/9.4.51.v20230217/websocket-servlet-9.4.51.v20230217.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.25/kotlin-stdlib-1.9.25.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.32/kotlin-stdlib-jdk8-1.5.32.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.5.32/kotlin-stdlib-1.5.32.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.25/kotlin-stdlib-jdk7-1.9.25.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.32/kotlin-stdlib-common-1.5.32.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.32/kotlin-stdlib-jdk7-1.5.32.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@@ -1,4 +1,20 @@
package ProtegeGX; package ProtegeGX;
import lombok.Setter;
import java.util.function.Consumer;
@SuppressWarnings("unused")
public class ProtegeGX { public class ProtegeGX {
@Setter private Consumer<ProtegeData> onCardRead;
private void updateCardRead(String data) {
if (onCardRead != null) {
ProtegeData protegeData = new ProtegeData();
onCardRead.accept(protegeData);
}
}
public void Disconnect() {
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View File

@@ -2,6 +2,7 @@ package Web;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.javalin.Javalin; import io.javalin.Javalin;
import io.javalin.http.staticfiles.Location;
import lombok.Setter; import lombok.Setter;
import java.util.function.Function; import java.util.function.Function;
@@ -31,14 +32,12 @@ public class WebServer {
Javalin app; Javalin app;
public WebServer(){ public WebServer(){
app = Javalin.create(config -> { app = Javalin.create(config -> {
config.useVirtualThreads = true; config.addStaticFiles("/Web", Location.EXTERNAL);
config.staticFiles.add("/Web"); });
config.router.apiBuilder(()->{ app.get("/", ctx -> ctx.result("Hello World"));
// API for AAS Mini app.get("/aasmini", ctx -> ctx.result("AAS Mini API"));
path("aasmini", ()->{ app.get("/protegegx", ctx -> ctx.result("ProtegeGX API"));
//TODO implement API for AAS Mini app.post("/aasmini", ctx ->{
get(ctx -> ctx.result("AAS Mini API"));
post(ctx -> {
try{ try{
WebRequest request = gson.fromJson(ctx.body(), WebRequest.class); WebRequest request = gson.fromJson(ctx.body(), WebRequest.class);
WebResponse response = ProcessAAS(request); WebResponse response = ProcessAAS(request);
@@ -53,12 +52,7 @@ public class WebServer {
ctx.result("Exception: "+e.getMessage()); ctx.result("Exception: "+e.getMessage());
} }
}); });
}); app.post("/protegegx", ctx ->{
// API for ProtegeGX
path("protegegx", ()->{
//TODO implement API for ProtegeGX
get(ctx -> ctx.result("ProtegeGX API"));
post(ctx -> {
try{ try{
WebRequest request = gson.fromJson(ctx.body(), WebRequest.class); WebRequest request = gson.fromJson(ctx.body(), WebRequest.class);
WebResponse response = ProcessProtegeGX(request); WebResponse response = ProcessProtegeGX(request);
@@ -73,9 +67,6 @@ public class WebServer {
ctx.result("Exception: "+e.getMessage()); ctx.result("Exception: "+e.getMessage());
} }
}); });
});
});
});
} }
public void Start(int listenport){ public void Start(int listenport){