-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ICD to Version 1.0 (07.08.2024)
Update SEDAP Express Framework project to version 1.0.0 Update misc sample projects
- Loading branch information
1 parent
1b5df5e
commit 4ea8b77
Showing
64 changed files
with
8,831 additions
and
184 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
/** | ||
* Note: This license has also been called the “Simplified BSD License” and the “FreeBSD License”. | ||
* Note: This license has also been called the “Simplified BSD License” and the | ||
* “FreeBSD License”. | ||
* | ||
* Copyright 2024 MESE POC: Volker Voß, Federal Armed Forces of Germany | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted | ||
* provided that the following conditions are met: | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this list of | ||
* conditions and the following disclaimer. | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of | ||
* conditions and the following disclaimer in the documentation and/or other materials provided with | ||
* the distribution. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSEnARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
* CONTRIBUTORS BEn LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
* OF SUCH DAMAGE. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSEnARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
* CONTRIBUTORS BEn LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
module MessageTool { | ||
|
||
requires transitive SEDAPExpress; | ||
} |
Binary file not shown.
Binary file not shown.
120 changes: 120 additions & 0 deletions
120
SECMockUp/src/main/java/de/bundeswehr/sedap/express/mockup/SEDAPExpressMockUpRESTServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/******************************************************************************* | ||
* Copyright (C)2012-2024, German Federal Armed Forces - All rights reserved. | ||
* | ||
* MUKdo II | ||
* Wibbelhofstraße 3 | ||
* 26384 Wilhelmshaven | ||
* Germany | ||
* | ||
* This source code is part of the MEDAS/SEDAP Project. | ||
* Person of contact (POC): Volker Voß, MUKdo II A, Wilhelmshaven | ||
* | ||
* Unauthorized use, modification, redistributing, copying, selling and | ||
* printing of this file in source and binary form including accompanying | ||
* materials is STRICTLY prohibited. | ||
* | ||
* This source code and it's parts is classified as OFFEN / NATO UNCLASSIFIED! | ||
*******************************************************************************/ | ||
package de.bundeswehr.sedap.express.mockup; | ||
|
||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.net.URI; | ||
import java.nio.charset.StandardCharsets; | ||
import java.time.Instant; | ||
import java.util.function.Function; | ||
|
||
import com.sun.net.httpserver.Filter; | ||
import com.sun.net.httpserver.Headers; | ||
import com.sun.net.httpserver.HttpContext; | ||
import com.sun.net.httpserver.HttpExchange; | ||
import com.sun.net.httpserver.HttpHandler; | ||
import com.sun.net.httpserver.HttpServer; | ||
import com.sun.net.httpserver.spi.HttpServerProvider; | ||
|
||
public class SEDAPExpressMockUpRESTServer { | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
HttpServerProvider provider = HttpServerProvider.provider(); | ||
HttpServer server = provider.createHttpServer(new InetSocketAddress(9999), 64); | ||
HttpContext context = server.createContext("/hello"); | ||
context.getFilters().add(new TracingFilter()); | ||
context.setHandler(SEDAPExpressMockUpRESTServer.respondWith(req -> HttpResponse.ok("Hello " + Instant.now()).text())); | ||
server.start(); | ||
} | ||
|
||
static HttpHandler respondWith(HttpFunc hf) { | ||
return exchange -> { | ||
|
||
var req = HttpRequest.of(exchange); | ||
var res = hf.apply(req); | ||
|
||
var bytes = res.body().getBytes(StandardCharsets.UTF_8); | ||
exchange.getResponseHeaders().putAll(res.headers()); | ||
|
||
try { | ||
exchange.sendResponseHeaders(res.status(), bytes.length); | ||
try (var os = exchange.getResponseBody()) { | ||
os.write(bytes); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
}; | ||
} | ||
|
||
record HttpRequest(String method, URI requestUri, Headers headers, HttpExchange exchange) { | ||
|
||
static HttpRequest of(HttpExchange exchange) { | ||
return new HttpRequest( | ||
exchange.getRequestMethod(), | ||
exchange.getRequestURI(), | ||
exchange.getRequestHeaders(), | ||
exchange); | ||
} | ||
} | ||
|
||
interface HttpFunc extends Function<HttpRequest, HttpResponse> { | ||
} | ||
|
||
static class TracingFilter extends Filter { | ||
|
||
@Override | ||
public void doFilter(HttpExchange exchange, Chain chain) throws IOException { | ||
var req = HttpRequest.of(exchange); | ||
System.out.println(req.toString()); | ||
chain.doFilter(exchange); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Trace"; | ||
} | ||
} | ||
|
||
record HttpResponse(int status, Headers headers, String body) { | ||
|
||
static HttpResponse ok() { | ||
return HttpResponse.ok(""); | ||
} | ||
|
||
static HttpResponse ok(String body) { | ||
return new HttpResponse(200, new Headers(), body); | ||
} | ||
|
||
HttpResponse header(String name, String value) { | ||
var res = new HttpResponse(status(), headers(), body()); | ||
res.headers().add(name, value); | ||
return res; | ||
} | ||
|
||
HttpResponse json() { | ||
return header("Content-type", "application/json"); | ||
} | ||
|
||
HttpResponse text() { | ||
return header("Content-type", "text/plain"); | ||
} | ||
} | ||
} |
Oops, something went wrong.