From a9b41f10d0bf55dc6f6bbe7bf5bc15a5519aa101 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Sun, 8 Sep 2024 13:24:03 +0330 Subject: [PATCH 01/25] Add base image for Java benchmarks on OpenWhisk --- config/systems.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config/systems.json b/config/systems.json index bf095d3f..3fbfe706 100644 --- a/config/systems.json +++ b/config/systems.json @@ -243,6 +243,24 @@ "minio": "7.0.16" } } + }, + "java": { + "base_images": { + "8": "openwhisk/actionloop-java-v8", + }, + "images": [ + "function" + ], + "username": "docker_user", + "deployment": { + "files": [ + "index.js", + "storage.js" + ], + "packages": { + "minio": "8.5.9" + } + } } } } From b0e04838bf77855aba2cc6c608ef14f99885d238 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Sun, 8 Sep 2024 17:55:11 +0330 Subject: [PATCH 02/25] Add Dockerfile for running Java benchmarks on OpenWhisk --- dockerfiles/openwhisk/java/Dockerfile.function | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 dockerfiles/openwhisk/java/Dockerfile.function diff --git a/dockerfiles/openwhisk/java/Dockerfile.function b/dockerfiles/openwhisk/java/Dockerfile.function new file mode 100644 index 00000000..d86cd461 --- /dev/null +++ b/dockerfiles/openwhisk/java/Dockerfile.function @@ -0,0 +1,8 @@ +ARG BASE_IMAGE +FROM $BASE_IMAGE +COPY . /function/ + +RUN apt-get update && apt-get install -y maven + +# Check if pom.xml exists before running Maven +RUN if [ -f ./pom.xml ]; then mvn clean install; else echo "pom.xml not found, aborting build." && exit 1; fi From f9db75555b70bf37f48756e4d855a1a1b6dc985a Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Sun, 8 Sep 2024 19:30:20 +0330 Subject: [PATCH 03/25] Update base image of java on OpenWhisk --- config/systems.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/systems.json b/config/systems.json index 3fbfe706..757ad388 100644 --- a/config/systems.json +++ b/config/systems.json @@ -246,7 +246,7 @@ }, "java": { "base_images": { - "8": "openwhisk/actionloop-java-v8", + "8": "openwhisk/java8action" }, "images": [ "function" @@ -254,8 +254,8 @@ "username": "docker_user", "deployment": { "files": [ - "index.js", - "storage.js" + "Main.java", + "Storage.java" ], "packages": { "minio": "8.5.9" From b1307e138eb9652f473a7349b68f9c8049c54dff Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Tue, 10 Sep 2024 21:02:36 +0330 Subject: [PATCH 04/25] Add Java-based handler for OpenWhisk --- benchmarks/wrappers/openwhisk/java/Main.java | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 benchmarks/wrappers/openwhisk/java/Main.java diff --git a/benchmarks/wrappers/openwhisk/java/Main.java b/benchmarks/wrappers/openwhisk/java/Main.java new file mode 100644 index 00000000..d21960ae --- /dev/null +++ b/benchmarks/wrappers/openwhisk/java/Main.java @@ -0,0 +1,55 @@ +import com.google.gson.JsonObject; +import java.util.faas.Function; +import java.time.Instant; +import java.time.Duration; +import java.io.File; +import java.io.IOException; + + +public class Main { + public static JsonObject main(JsonObject args) { + + // Logger logger = Logger.getLogger(FunctionHandler.class.getName()); + // logger.setLevel(Level.INFO); + + Gson gson = new Gson(); + Function function = new Function(); + + Instant begin = Instant.now(); + JsonObject result = function.handler(args); + Instant end = Instant.now(); + + long computeTime = Duration.between(begin, end).toNanos() / 1000; // Convert nanoseconds to microseconds + + boolean isCold = false; + String fileName = "/cold_run"; + + File file = new File(fileName); + if (!file.exists()) { + isCold = true; + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // Convert to Unix timestamp in seconds.microseconds + String formattedBegin = String.format("%d.%06d", begin.getEpochSecond(), begin.getNano() / 1000); // Convert nanoseconds to microseconds + String formattedEnd = String.format("%d.%06d", end.getEpochSecond(), end.getNano() / 1000); + + String requestId = System.getenv("__OW_ACTIVATION_ID"); + + JsonObject jsonResult = new JsonObject(); + jsonObject.put("begin", formattedBegin); + jsonObject.put("end", formattedEnd); + jsonObject.put("request_id", "requestId"); + jsonObject.put("compute_time", computeTime); + jsonObject.put("is_cold", isCold); + jsonObject.put("result", result); + return jsonResult; + } +} + + + \ No newline at end of file From 29e7d3fbca67b84c8999edd0ebaa1b92c6e18a27 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 19 Sep 2024 03:35:44 +0330 Subject: [PATCH 05/25] Add example config file for running java benchmarks on OpenWhisk --- config/example2.json | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 config/example2.json diff --git a/config/example2.json b/config/example2.json new file mode 100644 index 00000000..1cf21c81 --- /dev/null +++ b/config/example2.json @@ -0,0 +1,69 @@ +{ + "experiments": { + "deployment": "openwhisk", + "update_code": false, + "update_storage": false, + "download_results": false, + "runtime": { + "language": "java", + "version": "8" + }, + "type": "invocation-overhead", + "perf-cost": { + "benchmark": "110.dynamic-html", + "experiments": ["cold", "warm", "burst", "sequential"], + "input-size": "test", + "repetitions": 50, + "concurrent-invocations": 50, + "memory-sizes": [128, 256] + }, + "network-ping-pong": { + "invocations": 50, + "repetitions": 1000, + "threads": 1 + }, + "invocation-overhead": { + "repetitions": 5, + "N": 20, + "type": "payload", + "payload_begin": 1024, + "payload_end": 6251000, + "payload_points": 20, + "code_begin": 1048576, + "code_end": 261619712, + "code_points": 20 + }, + "eviction-model": { + "invocations": 1, + "function_copy_idx": 0, + "repetitions": 5, + "sleep": 1 + } + }, + "deployment": { + "openwhisk": { + "shutdownStorage": false, + "removeCluster": false, + "wskBypassSecurity": "true", + "wskExec": "wsk", + "experimentalManifest": false, + "docker_registry": { + "registry": "", + "username": "", + "password": "" + }, + "storage": { + "address": "", + "mapped_port": 9011, + "access_key": "", + "secret_key": "", + "instance_id": "", + "output_buckets": [], + "input_buckets": [], + "type": "minio" + } + + } + } + } + \ No newline at end of file From bced3067ba65fdda399faf093facad7e87fa69c6 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 19 Sep 2024 03:41:50 +0330 Subject: [PATCH 06/25] Add JAVA enum to list of languages --- sebs/faas/function.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sebs/faas/function.py b/sebs/faas/function.py index c2226cee..b58e9785 100644 --- a/sebs/faas/function.py +++ b/sebs/faas/function.py @@ -263,6 +263,7 @@ def deserialize(cached_config: dict) -> "Trigger": class Language(Enum): PYTHON = "python" NODEJS = "nodejs" + JAVA = "java" # FIXME: 3.7+ python with future annotations @staticmethod @@ -299,7 +300,7 @@ def serialize(self) -> dict: @staticmethod def deserialize(config: dict) -> Runtime: - languages = {"python": Language.PYTHON, "nodejs": Language.NODEJS} + languages = {"python": Language.PYTHON, "nodejs": Language.NODEJS, "java": Language.JAVA} return Runtime(language=languages[config["language"]], version=config["version"]) From 3c53e5f4eb20d98d8402a980d2acfd7d4978106d Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 19 Sep 2024 03:45:34 +0330 Subject: [PATCH 07/25] Add config of 601.hello-world (A simple java benchmark) --- benchmarks/600.java/601.hello-world/config.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 benchmarks/600.java/601.hello-world/config.json diff --git a/benchmarks/600.java/601.hello-world/config.json b/benchmarks/600.java/601.hello-world/config.json new file mode 100644 index 00000000..0c5d480e --- /dev/null +++ b/benchmarks/600.java/601.hello-world/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 120, + "memory": 512, + "languages": ["java"] + } + \ No newline at end of file From 49deef789b01e05dfcb1318016f2b61b4900958c Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 19 Sep 2024 04:12:42 +0330 Subject: [PATCH 08/25] Init maven structure of 601.hello-world and add some codes for running java benchmarks --- benchmarks/600.java/601.hello-world/java/pom.xml | 0 .../601.hello-world/java/src/java/Function.java | 0 benchmarks/wrappers/openwhisk/java/Storage.java | 0 sebs.py | 2 +- sebs/benchmark.py | 14 ++++++++++++++ 5 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 benchmarks/600.java/601.hello-world/java/pom.xml create mode 100644 benchmarks/600.java/601.hello-world/java/src/java/Function.java create mode 100644 benchmarks/wrappers/openwhisk/java/Storage.java diff --git a/benchmarks/600.java/601.hello-world/java/pom.xml b/benchmarks/600.java/601.hello-world/java/pom.xml new file mode 100644 index 00000000..e69de29b diff --git a/benchmarks/600.java/601.hello-world/java/src/java/Function.java b/benchmarks/600.java/601.hello-world/java/src/java/Function.java new file mode 100644 index 00000000..e69de29b diff --git a/benchmarks/wrappers/openwhisk/java/Storage.java b/benchmarks/wrappers/openwhisk/java/Storage.java new file mode 100644 index 00000000..e69de29b diff --git a/sebs.py b/sebs.py index ff7f7769..bef07717 100755 --- a/sebs.py +++ b/sebs.py @@ -63,7 +63,7 @@ def simplified_common_params(func): @click.option( "--language", default=None, - type=click.Choice(["python", "nodejs"]), + type=click.Choice(["python", "nodejs", "java"]), help="Benchmark language", ) @click.option("--language-version", default=None, type=str, help="Benchmark language version") diff --git a/sebs/benchmark.py b/sebs/benchmark.py index 90eed6ae..7900c741 100644 --- a/sebs/benchmark.py +++ b/sebs/benchmark.py @@ -250,6 +250,8 @@ def copy_code(self, output_dir): FILES = { "python": ["*.py", "requirements.txt*"], "nodejs": ["*.js", "package.json"], + "java": ["pom.xml"], + } path = os.path.join(self.benchmark_path, self.language_name) for file_type in FILES[self.language_name]: @@ -288,6 +290,16 @@ def add_deployment_files(self, output_dir): for file in handlers: shutil.copy2(file, os.path.join(output_dir)) + def add_deployment_package_java(self, output_dir): + # append to the end of requirements file + packages = self._system_config.deployment_packages( + self._deployment_name, self.language_name + ) + if len(packages): + with open(os.path.join(output_dir, "requirements.txt"), "a") as out: + for package in packages: + out.write(package) + def add_deployment_package_python(self, output_dir): # append to the end of requirements file packages = self._system_config.deployment_packages( @@ -319,6 +331,8 @@ def add_deployment_package(self, output_dir): self.add_deployment_package_python(output_dir) elif self.language == Language.NODEJS: self.add_deployment_package_nodejs(output_dir) + elif self.language == Language.JAVA: + self.add_deployment_package_java(output_dir) else: raise NotImplementedError From 722b447565b39905db02dc6b35e42f2d57bf9c69 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Fri, 20 Sep 2024 00:46:17 +0330 Subject: [PATCH 09/25] Sync hello-world maven paroject with the wrapper of openwhisk --- .../600.java/601.hello-world/my-app/pom.xml | 18 +++++++++ .../main/java/com/example/project/App.java | 17 +++++++++ .../java/com/example/project/AppTest.java | 38 +++++++++++++++++++ benchmarks/wrappers/openwhisk/java/Main.java | 4 +- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 benchmarks/600.java/601.hello-world/my-app/pom.xml create mode 100644 benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java create mode 100644 benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java diff --git a/benchmarks/600.java/601.hello-world/my-app/pom.xml b/benchmarks/600.java/601.hello-world/my-app/pom.xml new file mode 100644 index 00000000..f61b9e7f --- /dev/null +++ b/benchmarks/600.java/601.hello-world/my-app/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + com.example.project + my-app + jar + 1.0-SNAPSHOT + my-app + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java b/benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java new file mode 100644 index 00000000..f59864ee --- /dev/null +++ b/benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java @@ -0,0 +1,17 @@ +package com.example.project; +import com.google.gson.JsonObject; + +/** + * Hello world! + * + */ +public class App +{ + + + public JsonObject handler( String[] args ) + { + JsonObject jsonResult = new JsonObject(); + jsonObject.put("my string=", "heloooo worlddd!"); + } +} diff --git a/benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java b/benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java new file mode 100644 index 00000000..b3a7066d --- /dev/null +++ b/benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java @@ -0,0 +1,38 @@ +package com.example.project; + +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 ); + } +} diff --git a/benchmarks/wrappers/openwhisk/java/Main.java b/benchmarks/wrappers/openwhisk/java/Main.java index d21960ae..828aa64f 100644 --- a/benchmarks/wrappers/openwhisk/java/Main.java +++ b/benchmarks/wrappers/openwhisk/java/Main.java @@ -1,5 +1,5 @@ import com.google.gson.JsonObject; -import java.util.faas.Function; +import com.example.project.App ; import java.time.Instant; import java.time.Duration; import java.io.File; @@ -13,7 +13,7 @@ public static JsonObject main(JsonObject args) { // logger.setLevel(Level.INFO); Gson gson = new Gson(); - Function function = new Function(); + App function = new App(); Instant begin = Instant.now(); JsonObject result = function.handler(args); From 930813e4014622615300bd223b994a56f99e1234 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Tue, 24 Sep 2024 01:21:32 +0330 Subject: [PATCH 10/25] Example config file for running 601.hello-world on openwhisk --- config/example2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/example2.json b/config/example2.json index 1cf21c81..3575d601 100644 --- a/config/example2.json +++ b/config/example2.json @@ -10,7 +10,7 @@ }, "type": "invocation-overhead", "perf-cost": { - "benchmark": "110.dynamic-html", + "benchmark": "601.hello-world", "experiments": ["cold", "warm", "burst", "sequential"], "input-size": "test", "repetitions": 50, From f295e01417dd3b0bb4eebeb9f5984f227510168c Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Tue, 24 Sep 2024 01:23:03 +0330 Subject: [PATCH 11/25] Correct Structure of maven project in 601.hello-world benchmark --- .../600.java/601.hello-world/java/pom.xml | 38 +++++++++++++++++++ .../java/src/java/Function.java | 0 .../java/src/main/java/faas/App.java | 7 ++++ .../600.java/601.hello-world/my-app/pom.xml | 18 --------- .../main/java/com/example/project/App.java | 17 --------- .../java/com/example/project/AppTest.java | 38 ------------------- 6 files changed, 45 insertions(+), 73 deletions(-) delete mode 100644 benchmarks/600.java/601.hello-world/java/src/java/Function.java create mode 100644 benchmarks/600.java/601.hello-world/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/601.hello-world/my-app/pom.xml delete mode 100644 benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java delete mode 100644 benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java diff --git a/benchmarks/600.java/601.hello-world/java/pom.xml b/benchmarks/600.java/601.hello-world/java/pom.xml index e69de29b..eb4f359e 100644 --- a/benchmarks/600.java/601.hello-world/java/pom.xml +++ b/benchmarks/600.java/601.hello-world/java/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + + faas + 601.hello-world + 1.0-SNAPSHOT + jar + + + + 1.8 + 1.8 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + faas.App + + + + + + + + diff --git a/benchmarks/600.java/601.hello-world/java/src/java/Function.java b/benchmarks/600.java/601.hello-world/java/src/java/Function.java deleted file mode 100644 index e69de29b..00000000 diff --git a/benchmarks/600.java/601.hello-world/java/src/main/java/faas/App.java b/benchmarks/600.java/601.hello-world/java/src/main/java/faas/App.java new file mode 100644 index 00000000..365a6201 --- /dev/null +++ b/benchmarks/600.java/601.hello-world/java/src/main/java/faas/App.java @@ -0,0 +1,7 @@ +package faas; + +public class App { + public static void main(String[] args) { + System.out.println("Hellooooooooooooooooooo, World!"); + } +} \ No newline at end of file diff --git a/benchmarks/600.java/601.hello-world/my-app/pom.xml b/benchmarks/600.java/601.hello-world/my-app/pom.xml deleted file mode 100644 index f61b9e7f..00000000 --- a/benchmarks/600.java/601.hello-world/my-app/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - 4.0.0 - com.example.project - my-app - jar - 1.0-SNAPSHOT - my-app - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - diff --git a/benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java b/benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java deleted file mode 100644 index f59864ee..00000000 --- a/benchmarks/600.java/601.hello-world/my-app/src/main/java/com/example/project/App.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.project; -import com.google.gson.JsonObject; - -/** - * Hello world! - * - */ -public class App -{ - - - public JsonObject handler( String[] args ) - { - JsonObject jsonResult = new JsonObject(); - jsonObject.put("my string=", "heloooo worlddd!"); - } -} diff --git a/benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java b/benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java deleted file mode 100644 index b3a7066d..00000000 --- a/benchmarks/600.java/601.hello-world/my-app/src/test/java/com/example/project/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.example.project; - -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 ); - } -} From 0fa43be50f395bd1a054d33f442f49974e71033d Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Tue, 24 Sep 2024 01:23:55 +0330 Subject: [PATCH 12/25] Expand add_code functions for maven java rojects --- sebs/benchmark.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sebs/benchmark.py b/sebs/benchmark.py index 7900c741..771fde7f 100644 --- a/sebs/benchmark.py +++ b/sebs/benchmark.py @@ -251,12 +251,23 @@ def copy_code(self, output_dir): "python": ["*.py", "requirements.txt*"], "nodejs": ["*.js", "package.json"], "java": ["pom.xml"], - } path = os.path.join(self.benchmark_path, self.language_name) + for file_type in FILES[self.language_name]: for f in glob.glob(os.path.join(path, file_type)): shutil.copy2(os.path.join(path, f), output_dir) + + # copy src folder of java (java benchmarks are maven project and need directories) + if self.language_name == "java": + output_src_dir = os.path.join(output_dir, "src") + + if os.path.exists(output_src_dir): + # If src dir in output exist, remove the directory and all its contents + shutil.rmtree(output_src_dir) + #To have contents of src directory in the direcory named src located in output + shutil.copytree(os.path.join(path, "src"), output_src_dir) + # support node.js benchmarks with language specific packages nodejs_package_json = os.path.join(path, f"package.json.{self.language_version}") if os.path.exists(nodejs_package_json): From 3fb661f7f5bb55e8d69f0ceb25ece21d986d55da Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Tue, 24 Sep 2024 01:26:57 +0330 Subject: [PATCH 13/25] Exclude Java main wrapper from Docker directory created in runtimes. --- sebs/openwhisk/openwhisk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sebs/openwhisk/openwhisk.py b/sebs/openwhisk/openwhisk.py index 00660de9..d49f3e19 100644 --- a/sebs/openwhisk/openwhisk.py +++ b/sebs/openwhisk/openwhisk.py @@ -168,7 +168,7 @@ def build_base_image( ) for fn in os.listdir(directory): - if fn not in ("index.js", "__main__.py"): + if fn not in ("index.js", "__main__.py", "Main.java"): file = os.path.join(directory, fn) shutil.move(file, build_dir) @@ -219,6 +219,7 @@ def package_code( CONFIG_FILES = { "python": ["__main__.py"], "nodejs": ["index.js"], + "nodejs": ["Main.java"], } package_config = CONFIG_FILES[language_name] From a14d0a0b67e5e959f632557ecf3029facad4cbeb Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Wed, 25 Sep 2024 13:31:49 +0330 Subject: [PATCH 14/25] Fix a big --- sebs/openwhisk/openwhisk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sebs/openwhisk/openwhisk.py b/sebs/openwhisk/openwhisk.py index d49f3e19..01684ed3 100644 --- a/sebs/openwhisk/openwhisk.py +++ b/sebs/openwhisk/openwhisk.py @@ -219,7 +219,7 @@ def package_code( CONFIG_FILES = { "python": ["__main__.py"], "nodejs": ["index.js"], - "nodejs": ["Main.java"], + "java": ["Main.java"], } package_config = CONFIG_FILES[language_name] From aab419db9c955b21714d7a87f42c4991f65c9284 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Wed, 25 Sep 2024 19:06:48 +0330 Subject: [PATCH 15/25] making jar file is working correctly --- .vscode/launch.json | 27 ++ .../600.java/602.login-checker/config.json | 6 + .../600.java/602.login-checker/java/pom.xml | 58 ++++ .../java/src/main/java/faas/App.java | 29 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 ++++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 +++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/wrappers/openwhisk/java/Main.java | 22 +- config/example.json | 12 +- config/example2.json | 10 +- config/systems.json | 2 +- .../openwhisk/java/Dockerfile.function | 6 +- experiments.json | 268 +++++++++++++++++ out_storage.json | 10 + sebs/benchmark.py | 24 ++ sebs/openwhisk/openwhisk.py | 2 +- 20 files changed, 1205 insertions(+), 26 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 benchmarks/600.java/602.login-checker/config.json create mode 100644 benchmarks/600.java/602.login-checker/java/pom.xml create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/602.login-checker/java/src/main/java/util/ShaSecurityProvider.java create mode 100644 experiments.json create mode 100644 out_storage.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..b30a810f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ + +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Debug sebs.py Command", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/sebs.py", // Path to sebs.py script + "args": [ + "benchmark", + "invoke", + "602.login-checker", + "test", + "--config", + "config/example2.json", + "--deployment", + "openwhisk", + "--verbose" + ], + "console": "integratedTerminal", // Runs in VS Code's integrated terminal + "cwd": "${workspaceFolder}", // Set the current working directory to the workspace + "justMyCode": false + } + ] + } + \ No newline at end of file diff --git a/benchmarks/600.java/602.login-checker/config.json b/benchmarks/600.java/602.login-checker/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/602.login-checker/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/602.login-checker/java/pom.xml b/benchmarks/600.java/602.login-checker/java/pom.xml new file mode 100644 index 00000000..b847b28c --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + + org.example + check_login + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java b/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java new file mode 100644 index 00000000..30f98d2f --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java @@ -0,0 +1,29 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + +// Base version in TeaStore: (Commented out due to dependency issues, as the code below was run in the servlet space) +// Response.status(Response.Status.OK).entity(new ShaSecurityProvider().validate(blob)).build(); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/Order.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/602.login-checker/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/wrappers/openwhisk/java/Main.java b/benchmarks/wrappers/openwhisk/java/Main.java index 828aa64f..b41e4405 100644 --- a/benchmarks/wrappers/openwhisk/java/Main.java +++ b/benchmarks/wrappers/openwhisk/java/Main.java @@ -1,9 +1,13 @@ +import faas.App; +import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.example.project.App ; +import util.SessionBlob; +import util.ShaSecurityProvider; import java.time.Instant; import java.time.Duration; import java.io.File; import java.io.IOException; +//import jakarta.ws.rs.core.Response; public class Main { @@ -41,15 +45,13 @@ public static JsonObject main(JsonObject args) { String requestId = System.getenv("__OW_ACTIVATION_ID"); JsonObject jsonResult = new JsonObject(); - jsonObject.put("begin", formattedBegin); - jsonObject.put("end", formattedEnd); - jsonObject.put("request_id", "requestId"); - jsonObject.put("compute_time", computeTime); - jsonObject.put("is_cold", isCold); - jsonObject.put("result", result); + jsonResult.addProperty("begin", formattedBegin); + jsonResult.addProperty("end", formattedEnd); + jsonResult.addProperty("request_id", "requestId"); + jsonResult.addProperty("compute_time", computeTime); + jsonResult.addProperty("is_cold", isCold); + jsonResult.addProperty("result", result.toString()); return jsonResult; } -} - - \ No newline at end of file +} diff --git a/config/example.json b/config/example.json index dc4da9ad..c0410594 100644 --- a/config/example.json +++ b/config/example.json @@ -78,13 +78,13 @@ "password": "" }, "storage": { - "address": "", - "mapped_port": -1, - "access_key": "", - "secret_key": "", - "instance_id": "", - "input_buckets": [], + "address": "172.20.10.3:9011", + "mapped_port": 9011, + "access_key": "mtkTCw_sA0UqcSkgGD60AN8tLr2nx1sXympC6q7wCLA", + "secret_key": "4bea2b1443d8fd7e537176c52f2f979dd42026b2321019c59435a4bfe872381c", + "instance_id": "c7b51cf6f93e85580994550ec08ae7edad9245b6a56ebde1a39265adaa1e7818", "output_buckets": [], + "input_buckets": [], "type": "minio" } } diff --git a/config/example2.json b/config/example2.json index 3575d601..97f90b09 100644 --- a/config/example2.json +++ b/config/example2.json @@ -53,15 +53,15 @@ "password": "" }, "storage": { - "address": "", + "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "", - "secret_key": "", - "instance_id": "", + "access_key": "mtkTCw_sA0UqcSkgGD60AN8tLr2nx1sXympC6q7wCLA", + "secret_key": "4bea2b1443d8fd7e537176c52f2f979dd42026b2321019c59435a4bfe872381c", + "instance_id": "c7b51cf6f93e85580994550ec08ae7edad9245b6a56ebde1a39265adaa1e7818", "output_buckets": [], "input_buckets": [], "type": "minio" - } + } } } diff --git a/config/systems.json b/config/systems.json index 757ad388..30c6a7cc 100644 --- a/config/systems.json +++ b/config/systems.json @@ -1,6 +1,6 @@ { "general": { - "docker_repository": "spcleth/serverless-benchmarks" + "docker_repository": "duckerhubformahla/serverless_benchmarks" }, "local": { "experiments": { diff --git a/dockerfiles/openwhisk/java/Dockerfile.function b/dockerfiles/openwhisk/java/Dockerfile.function index d86cd461..b72ceb15 100644 --- a/dockerfiles/openwhisk/java/Dockerfile.function +++ b/dockerfiles/openwhisk/java/Dockerfile.function @@ -2,7 +2,7 @@ ARG BASE_IMAGE FROM $BASE_IMAGE COPY . /function/ -RUN apt-get update && apt-get install -y maven +# RUN apt-get update && apt-get install -y maven -# Check if pom.xml exists before running Maven -RUN if [ -f ./pom.xml ]; then mvn clean install; else echo "pom.xml not found, aborting build." && exit 1; fi +# # Check if pom.xml exists before running Maven +# RUN if [ -f ./pom.xml ]; then mvn clean install; else echo "pom.xml not found, aborting build." && exit 1; fi diff --git a/experiments.json b/experiments.json new file mode 100644 index 00000000..515655c5 --- /dev/null +++ b/experiments.json @@ -0,0 +1,268 @@ +{ + "_invocations": { + "110.dynamic-html-python-3.7": { + "1bc1a7e7f98d45bc81a7e7f98dc5bc66": { + "billing": { + "_billed_time": null, + "_gb_seconds": 0, + "_memory": null + }, + "output": { + "begin": "1727260258.245192", + "end": "1727260258.248223", + "is_cold": false, + "request_id": "1bc1a7e7f98d45bc81a7e7f98dc5bc66", + "result": { + "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.245248!

\n

Requested random numbers:

\n
    \n \n
  • 556459
  • \n \n
  • 634380
  • \n \n
  • 287477
  • \n \n
  • 378970
  • \n \n
  • 700815
  • \n \n
  • 358077
  • \n \n
  • 305374
  • \n \n
  • 499827
  • \n \n
  • 132624
  • \n \n
  • 297035
  • \n \n
\n
\n \n" + }, + "results_time": 3031.0 + }, + "provider_times": { + "execution": 0, + "initialization": 0 + }, + "request_id": "1bc1a7e7f98d45bc81a7e7f98dc5bc66", + "stats": { + "cold_start": false, + "failure": false, + "memory_used": null + }, + "times": { + "benchmark": 3031, + "client": 80917, + "client_begin": "2024-09-25 14:00:58.178803", + "client_end": "2024-09-25 14:00:58.259720", + "http_first_byte_return": 0.080867, + "http_startup": 0.011578, + "initialization": 0 + } + }, + "36f39e7b2e6e4890b39e7b2e6e08901e": { + "billing": { + "_billed_time": null, + "_gb_seconds": 0, + "_memory": null + }, + "output": { + "begin": "1727260258.296474", + "end": "1727260258.299672", + "is_cold": false, + "request_id": "36f39e7b2e6e4890b39e7b2e6e08901e", + "result": { + "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.296539!

\n

Requested random numbers:

\n
    \n \n
  • 680199
  • \n \n
  • 799261
  • \n \n
  • 995416
  • \n \n
  • 761086
  • \n \n
  • 922233
  • \n \n
  • 309715
  • \n \n
  • 923649
  • \n \n
  • 139665
  • \n \n
  • 187927
  • \n \n
  • 370913
  • \n \n
\n
\n \n" + }, + "results_time": 3198.0 + }, + "provider_times": { + "execution": 0, + "initialization": 0 + }, + "request_id": "36f39e7b2e6e4890b39e7b2e6e08901e", + "stats": { + "cold_start": false, + "failure": false, + "memory_used": null + }, + "times": { + "benchmark": 3198, + "client": 52343, + "client_begin": "2024-09-25 14:00:58.261501", + "client_end": "2024-09-25 14:00:58.313844", + "http_first_byte_return": 0.052286, + "http_startup": 0.014218, + "initialization": 0 + } + }, + "37482e3f37a64947882e3f37a6294786": { + "billing": { + "_billed_time": null, + "_gb_seconds": 0, + "_memory": null + }, + "output": { + "begin": "1727260258.357643", + "end": "1727260258.360452", + "is_cold": false, + "request_id": "37482e3f37a64947882e3f37a6294786", + "result": { + "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.357690!

\n

Requested random numbers:

\n
    \n \n
  • 941472
  • \n \n
  • 184064
  • \n \n
  • 260745
  • \n \n
  • 838242
  • \n \n
  • 23648
  • \n \n
  • 926420
  • \n \n
  • 892181
  • \n \n
  • 240386
  • \n \n
  • 733303
  • \n \n
  • 742026
  • \n \n
\n
\n \n" + }, + "results_time": 2809.0 + }, + "provider_times": { + "execution": 0, + "initialization": 0 + }, + "request_id": "37482e3f37a64947882e3f37a6294786", + "stats": { + "cold_start": false, + "failure": false, + "memory_used": null + }, + "times": { + "benchmark": 2809, + "client": 61803, + "client_begin": "2024-09-25 14:00:58.315898", + "client_end": "2024-09-25 14:00:58.377701", + "http_first_byte_return": 0.061741, + "http_startup": 0.01383, + "initialization": 0 + } + }, + "6a4d6917f5f24d778d6917f5f23d77a9": { + "billing": { + "_billed_time": null, + "_gb_seconds": 0, + "_memory": null + }, + "output": { + "begin": "1727260257.852574", + "end": "1727260257.895806", + "is_cold": true, + "request_id": "6a4d6917f5f24d778d6917f5f23d77a9", + "result": { + "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:57.892237!

\n

Requested random numbers:

\n
    \n \n
  • 817049
  • \n \n
  • 943791
  • \n \n
  • 48301
  • \n \n
  • 215860
  • \n \n
  • 786018
  • \n \n
  • 14929
  • \n \n
  • 113673
  • \n \n
  • 684912
  • \n \n
  • 658472
  • \n \n
  • 786099
  • \n \n
\n
\n \n" + }, + "results_time": 43232.0 + }, + "provider_times": { + "execution": 0, + "initialization": 0 + }, + "request_id": "6a4d6917f5f24d778d6917f5f23d77a9", + "stats": { + "cold_start": true, + "failure": false, + "memory_used": null + }, + "times": { + "benchmark": 43232, + "client": 6182570, + "client_begin": "2024-09-25 14:00:51.913951", + "client_end": "2024-09-25 14:00:58.096521", + "http_first_byte_return": 6.182509, + "http_startup": 0.01411, + "initialization": 0 + } + }, + "96846c0588e348dc846c0588e318dc38": { + "billing": { + "_billed_time": null, + "_gb_seconds": 0, + "_memory": null + }, + "output": { + "begin": "1727260258.163636", + "end": "1727260258.165759", + "is_cold": false, + "request_id": "96846c0588e348dc846c0588e318dc38", + "result": { + "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.163680!

\n

Requested random numbers:

\n
    \n \n
  • 412413
  • \n \n
  • 897361
  • \n \n
  • 954868
  • \n \n
  • 199790
  • \n \n
  • 601703
  • \n \n
  • 902026
  • \n \n
  • 286946
  • \n \n
  • 207139
  • \n \n
  • 546276
  • \n \n
  • 966623
  • \n \n
\n
\n \n" + }, + "results_time": 2123.0 + }, + "provider_times": { + "execution": 0, + "initialization": 0 + }, + "request_id": "96846c0588e348dc846c0588e318dc38", + "stats": { + "cold_start": false, + "failure": false, + "memory_used": null + }, + "times": { + "benchmark": 2123, + "client": 79529, + "client_begin": "2024-09-25 14:00:58.097919", + "client_end": "2024-09-25 14:00:58.177448", + "http_first_byte_return": 0.079477, + "http_startup": 0.007485, + "initialization": 0 + } + } + } + }, + "_metrics": {}, + "begin_time": 1727260251.825095, + "config": { + "deployment": { + "credentials": {}, + "experimentalManifest": false, + "name": "openwhisk", + "removeCluster": false, + "resources": { + "benchmarks": "sebs-benchmarks-045723a0", + "docker_password": "", + "docker_registry": "", + "docker_username": "", + "resources_id": "045723a0", + "storage": { + "access_key": "zNelUuRKxte4sXTtYImPi-Ci6q_UM9mv2buQEorpbeg", + "address": "172.20.10.3:9011", + "input_buckets": [], + "instance_id": "ad9aff4d5b0f461139a4ce304f331805ec5c058a89abfc9ad0462fcec21297aa", + "mapped_port": 9011, + "output_buckets": [], + "secret_key": "565390385cd9634346028200a209ef9f43a47238433c125f719fcd6cfea45e6e", + "type": "minio" + } + }, + "shutdownStorage": false, + "wskBypassSecurity": "true", + "wskExec": "wsk" + }, + "experiments": { + "download_results": false, + "experiments": { + "eviction-model": { + "function_copy_idx": 0, + "invocations": 1, + "repetitions": 5, + "sleep": 1 + }, + "invocation-overhead": { + "N": 20, + "code_begin": 1048576, + "code_end": 261619712, + "code_points": 20, + "payload_begin": 1024, + "payload_end": 6251000, + "payload_points": 20, + "repetitions": 5, + "type": "payload" + }, + "network-ping-pong": { + "invocations": 50, + "repetitions": 1000, + "threads": 1 + }, + "perf-cost": { + "benchmark": "110.dynamic-html", + "concurrent-invocations": 50, + "experiments": [ + "cold", + "warm", + "burst", + "sequential" + ], + "input-size": "test", + "memory-sizes": [ + 128, + 256 + ], + "repetitions": 50 + } + }, + "flags": {}, + "runtime": { + "language": "python", + "version": "3.7" + }, + "update_code": false, + "update_storage": false + } + }, + "end_time": 1727260258.378968, + "result_bucket": null +} \ No newline at end of file diff --git a/out_storage.json b/out_storage.json new file mode 100644 index 00000000..4cea7645 --- /dev/null +++ b/out_storage.json @@ -0,0 +1,10 @@ +{ + "address": "172.20.10.3:9011", + "mapped_port": 9011, + "access_key": "mtkTCw_sA0UqcSkgGD60AN8tLr2nx1sXympC6q7wCLA", + "secret_key": "4bea2b1443d8fd7e537176c52f2f979dd42026b2321019c59435a4bfe872381c", + "instance_id": "c7b51cf6f93e85580994550ec08ae7edad9245b6a56ebde1a39265adaa1e7818", + "output_buckets": [], + "input_buckets": [], + "type": "minio" +} \ No newline at end of file diff --git a/sebs/benchmark.py b/sebs/benchmark.py index 771fde7f..adff9612 100644 --- a/sebs/benchmark.py +++ b/sebs/benchmark.py @@ -1,6 +1,7 @@ import glob import hashlib import json +import subprocess import os import shutil import subprocess @@ -273,6 +274,28 @@ def copy_code(self, output_dir): if os.path.exists(nodejs_package_json): shutil.copy2(nodejs_package_json, os.path.join(output_dir, "package.json")) + #This is for making jar file and add it to docker directory + def add_java_output(self, code_dir): + + if self.language_name == "java": + + # Step 1: Move Main.java o src directory + src_dir = os.path.join(code_dir, "src", "main", "java") + if os.path.exists(code_dir): + main_java_path = os.path.join(code_dir, "Main.java") + if os.path.exists(main_java_path): + shutil.move(main_java_path, src_dir) + + # Step 2: Run mvn clean install + try: + # Navigate to the code directory where the pom.xml file is located + subprocess.run(['mvn', 'clean', 'install'], cwd=code_dir, check=True, text=True, capture_output=True) + print("Maven build successful!") + except subprocess.CalledProcessError as e: + print(f"Error during Maven build:\n{e.stdout}\n{e.stderr}") + return + + def add_benchmark_data(self, output_dir): cmd = "/bin/bash {benchmark_path}/init.sh {output_dir} false" paths = [ @@ -522,6 +545,7 @@ def build( self.copy_code(self._output_dir) self.add_benchmark_data(self._output_dir) self.add_deployment_files(self._output_dir) + self.add_java_output(self._output_dir) self.add_deployment_package(self._output_dir) self.install_dependencies(self._output_dir) self._code_location, self._code_size = deployment_build_step( diff --git a/sebs/openwhisk/openwhisk.py b/sebs/openwhisk/openwhisk.py index 01684ed3..85e673ca 100644 --- a/sebs/openwhisk/openwhisk.py +++ b/sebs/openwhisk/openwhisk.py @@ -168,7 +168,7 @@ def build_base_image( ) for fn in os.listdir(directory): - if fn not in ("index.js", "__main__.py", "Main.java"): + if fn not in ("index.js", "__main__.py"): file = os.path.join(directory, fn) shutil.move(file, build_dir) From a80e91f82091609b576b49eb583175e3f7e31902 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Wed, 25 Sep 2024 22:28:27 +0330 Subject: [PATCH 16/25] loginChecker running successfly on openwhisk --- .vscode/settings.json | 3 + .../600.java/602.login-checker/input.py | 5 + .../600.java/602.login-checker/java/pom.xml | 6 +- config/example.json | 6 +- config/example2.json | 7 +- experiments.json | 190 ++---------------- out_storage.json | 6 +- sebs/benchmark.py | 3 +- sebs/openwhisk/openwhisk.py | 107 ++++++---- 9 files changed, 112 insertions(+), 221 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 benchmarks/600.java/602.login-checker/input.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..c5f3f6b9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/benchmarks/600.java/602.login-checker/input.py b/benchmarks/600.java/602.login-checker/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/602.login-checker/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/602.login-checker/java/pom.xml b/benchmarks/600.java/602.login-checker/java/pom.xml index b847b28c..ea706a39 100644 --- a/benchmarks/600.java/602.login-checker/java/pom.xml +++ b/benchmarks/600.java/602.login-checker/java/pom.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.example - check_login - 1.0-SNAPSHOT + faas + benchmark + 1 8 diff --git a/config/example.json b/config/example.json index c0410594..8180cab3 100644 --- a/config/example.json +++ b/config/example.json @@ -80,9 +80,9 @@ "storage": { "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "mtkTCw_sA0UqcSkgGD60AN8tLr2nx1sXympC6q7wCLA", - "secret_key": "4bea2b1443d8fd7e537176c52f2f979dd42026b2321019c59435a4bfe872381c", - "instance_id": "c7b51cf6f93e85580994550ec08ae7edad9245b6a56ebde1a39265adaa1e7818", + "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", + "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", + "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", "output_buckets": [], "input_buckets": [], "type": "minio" diff --git a/config/example2.json b/config/example2.json index 97f90b09..cc2d469e 100644 --- a/config/example2.json +++ b/config/example2.json @@ -55,14 +55,13 @@ "storage": { "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "mtkTCw_sA0UqcSkgGD60AN8tLr2nx1sXympC6q7wCLA", - "secret_key": "4bea2b1443d8fd7e537176c52f2f979dd42026b2321019c59435a4bfe872381c", - "instance_id": "c7b51cf6f93e85580994550ec08ae7edad9245b6a56ebde1a39265adaa1e7818", + "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", + "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", + "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", "output_buckets": [], "input_buckets": [], "type": "minio" } - } } } diff --git a/experiments.json b/experiments.json index 515655c5..62b5271c 100644 --- a/experiments.json +++ b/experiments.json @@ -1,190 +1,44 @@ { "_invocations": { - "110.dynamic-html-python-3.7": { - "1bc1a7e7f98d45bc81a7e7f98dc5bc66": { + "602.login-checker-java-8": { + "requestId": { "billing": { "_billed_time": null, "_gb_seconds": 0, "_memory": null }, "output": { - "begin": "1727260258.245192", - "end": "1727260258.248223", - "is_cold": false, - "request_id": "1bc1a7e7f98d45bc81a7e7f98dc5bc66", - "result": { - "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.245248!

\n

Requested random numbers:

\n
    \n \n
  • 556459
  • \n \n
  • 634380
  • \n \n
  • 287477
  • \n \n
  • 378970
  • \n \n
  • 700815
  • \n \n
  • 358077
  • \n \n
  • 305374
  • \n \n
  • 499827
  • \n \n
  • 132624
  • \n \n
  • 297035
  • \n \n
\n
\n \n" - }, - "results_time": 3031.0 - }, - "provider_times": { - "execution": 0, - "initialization": 0 - }, - "request_id": "1bc1a7e7f98d45bc81a7e7f98dc5bc66", - "stats": { - "cold_start": false, - "failure": false, - "memory_used": null - }, - "times": { - "benchmark": 3031, - "client": 80917, - "client_begin": "2024-09-25 14:00:58.178803", - "client_end": "2024-09-25 14:00:58.259720", - "http_first_byte_return": 0.080867, - "http_startup": 0.011578, - "initialization": 0 - } - }, - "36f39e7b2e6e4890b39e7b2e6e08901e": { - "billing": { - "_billed_time": null, - "_gb_seconds": 0, - "_memory": null - }, - "output": { - "begin": "1727260258.296474", - "end": "1727260258.299672", - "is_cold": false, - "request_id": "36f39e7b2e6e4890b39e7b2e6e08901e", - "result": { - "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.296539!

\n

Requested random numbers:

\n
    \n \n
  • 680199
  • \n \n
  • 799261
  • \n \n
  • 995416
  • \n \n
  • 761086
  • \n \n
  • 922233
  • \n \n
  • 309715
  • \n \n
  • 923649
  • \n \n
  • 139665
  • \n \n
  • 187927
  • \n \n
  • 370913
  • \n \n
\n
\n \n" - }, - "results_time": 3198.0 - }, - "provider_times": { - "execution": 0, - "initialization": 0 - }, - "request_id": "36f39e7b2e6e4890b39e7b2e6e08901e", - "stats": { - "cold_start": false, - "failure": false, - "memory_used": null - }, - "times": { - "benchmark": 3198, - "client": 52343, - "client_begin": "2024-09-25 14:00:58.261501", - "client_end": "2024-09-25 14:00:58.313844", - "http_first_byte_return": 0.052286, - "http_startup": 0.014218, - "initialization": 0 - } - }, - "37482e3f37a64947882e3f37a6294786": { - "billing": { - "_billed_time": null, - "_gb_seconds": 0, - "_memory": null - }, - "output": { - "begin": "1727260258.357643", - "end": "1727260258.360452", - "is_cold": false, - "request_id": "37482e3f37a64947882e3f37a6294786", - "result": { - "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.357690!

\n

Requested random numbers:

\n
    \n \n
  • 941472
  • \n \n
  • 184064
  • \n \n
  • 260745
  • \n \n
  • 838242
  • \n \n
  • 23648
  • \n \n
  • 926420
  • \n \n
  • 892181
  • \n \n
  • 240386
  • \n \n
  • 733303
  • \n \n
  • 742026
  • \n \n
\n
\n \n" - }, - "results_time": 2809.0 - }, - "provider_times": { - "execution": 0, - "initialization": 0 - }, - "request_id": "37482e3f37a64947882e3f37a6294786", - "stats": { - "cold_start": false, - "failure": false, - "memory_used": null - }, - "times": { - "benchmark": 2809, - "client": 61803, - "client_begin": "2024-09-25 14:00:58.315898", - "client_end": "2024-09-25 14:00:58.377701", - "http_first_byte_return": 0.061741, - "http_startup": 0.01383, - "initialization": 0 - } - }, - "6a4d6917f5f24d778d6917f5f23d77a9": { - "billing": { - "_billed_time": null, - "_gb_seconds": 0, - "_memory": null - }, - "output": { - "begin": "1727260257.852574", - "end": "1727260257.895806", + "begin": "1727290018.301000", + "compute_time": 26000, + "end": "1727290018.327000", "is_cold": true, - "request_id": "6a4d6917f5f24d778d6917f5f23d77a9", - "result": { - "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:57.892237!

\n

Requested random numbers:

\n
    \n \n
  • 817049
  • \n \n
  • 943791
  • \n \n
  • 48301
  • \n \n
  • 215860
  • \n \n
  • 786018
  • \n \n
  • 14929
  • \n \n
  • 113673
  • \n \n
  • 684912
  • \n \n
  • 658472
  • \n \n
  • 786099
  • \n \n
\n
\n \n" - }, - "results_time": 43232.0 + "request_id": "requestId", + "result": "{\"Authorization-Status\":\"Unauthorized\"}" }, "provider_times": { "execution": 0, "initialization": 0 }, - "request_id": "6a4d6917f5f24d778d6917f5f23d77a9", + "request_id": "requestId", "stats": { "cold_start": true, "failure": false, "memory_used": null }, "times": { - "benchmark": 43232, - "client": 6182570, - "client_begin": "2024-09-25 14:00:51.913951", - "client_end": "2024-09-25 14:00:58.096521", - "http_first_byte_return": 6.182509, - "http_startup": 0.01411, - "initialization": 0 - } - }, - "96846c0588e348dc846c0588e318dc38": { - "billing": { - "_billed_time": null, - "_gb_seconds": 0, - "_memory": null - }, - "output": { - "begin": "1727260258.163636", - "end": "1727260258.165759", - "is_cold": false, - "request_id": "96846c0588e348dc846c0588e318dc38", - "result": { - "result": "\n\n \n Randomly generated data.\n \n \n \n \n \n
\n

Welcome testname!

\n

Data generated at: 2024-09-25 10:30:58.163680!

\n

Requested random numbers:

\n
    \n \n
  • 412413
  • \n \n
  • 897361
  • \n \n
  • 954868
  • \n \n
  • 199790
  • \n \n
  • 601703
  • \n \n
  • 902026
  • \n \n
  • 286946
  • \n \n
  • 207139
  • \n \n
  • 546276
  • \n \n
  • 966623
  • \n \n
\n
\n \n" - }, - "results_time": 2123.0 - }, - "provider_times": { - "execution": 0, - "initialization": 0 - }, - "request_id": "96846c0588e348dc846c0588e318dc38", - "stats": { - "cold_start": false, - "failure": false, - "memory_used": null - }, - "times": { - "benchmark": 2123, - "client": 79529, - "client_begin": "2024-09-25 14:00:58.097919", - "client_end": "2024-09-25 14:00:58.177448", - "http_first_byte_return": 0.079477, - "http_startup": 0.007485, + "benchmark": 26000, + "client": 3975488, + "client_begin": "2024-09-25 22:16:54.373253", + "client_end": "2024-09-25 22:16:58.348741", + "http_first_byte_return": 3.975434, + "http_startup": 0.013632, "initialization": 0 } } } }, "_metrics": {}, - "begin_time": 1727260251.825095, + "begin_time": 1727290007.749544, "config": { "deployment": { "credentials": {}, @@ -198,13 +52,13 @@ "docker_username": "", "resources_id": "045723a0", "storage": { - "access_key": "zNelUuRKxte4sXTtYImPi-Ci6q_UM9mv2buQEorpbeg", + "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", "address": "172.20.10.3:9011", "input_buckets": [], - "instance_id": "ad9aff4d5b0f461139a4ce304f331805ec5c058a89abfc9ad0462fcec21297aa", + "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", "mapped_port": 9011, "output_buckets": [], - "secret_key": "565390385cd9634346028200a209ef9f43a47238433c125f719fcd6cfea45e6e", + "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", "type": "minio" } }, @@ -238,7 +92,7 @@ "threads": 1 }, "perf-cost": { - "benchmark": "110.dynamic-html", + "benchmark": "601.hello-world", "concurrent-invocations": 50, "experiments": [ "cold", @@ -256,13 +110,13 @@ }, "flags": {}, "runtime": { - "language": "python", - "version": "3.7" + "language": "java", + "version": "8" }, "update_code": false, "update_storage": false } }, - "end_time": 1727260258.378968, + "end_time": 1727290018.349986, "result_bucket": null } \ No newline at end of file diff --git a/out_storage.json b/out_storage.json index 4cea7645..02fd81f6 100644 --- a/out_storage.json +++ b/out_storage.json @@ -1,9 +1,9 @@ { "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "mtkTCw_sA0UqcSkgGD60AN8tLr2nx1sXympC6q7wCLA", - "secret_key": "4bea2b1443d8fd7e537176c52f2f979dd42026b2321019c59435a4bfe872381c", - "instance_id": "c7b51cf6f93e85580994550ec08ae7edad9245b6a56ebde1a39265adaa1e7818", + "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", + "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", + "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", "output_buckets": [], "input_buckets": [], "type": "minio" diff --git a/sebs/benchmark.py b/sebs/benchmark.py index adff9612..e18c8d4d 100644 --- a/sebs/benchmark.py +++ b/sebs/benchmark.py @@ -201,8 +201,9 @@ def hash_directory(directory: str, deployment: str, language: str): FILES = { "python": ["*.py", "requirements.txt*"], "nodejs": ["*.js", "package.json"], + "java": ["*.java", "pom.xml"], } - WRAPPERS = {"python": "*.py", "nodejs": "*.js"} + WRAPPERS = {"python": "*.py", "nodejs": "*.js", "java": "*.java"} NON_LANG_FILES = ["*.sh", "*.json"] selected_files = FILES[language] + NON_LANG_FILES for file_type in selected_files: diff --git a/sebs/openwhisk/openwhisk.py b/sebs/openwhisk/openwhisk.py index 85e673ca..a83b5b8d 100644 --- a/sebs/openwhisk/openwhisk.py +++ b/sebs/openwhisk/openwhisk.py @@ -214,24 +214,27 @@ def package_code( # to allow registration of function with OpenWhisk self.build_base_image(directory, language_name, language_version, benchmark, is_cached) - # We deploy Minio config in code package since this depends on local - # deployment - it cannnot be a part of Docker image - CONFIG_FILES = { - "python": ["__main__.py"], - "nodejs": ["index.js"], - "java": ["Main.java"], - } - package_config = CONFIG_FILES[language_name] - - benchmark_archive = os.path.join(directory, f"{benchmark}.zip") - subprocess.run( - ["zip", benchmark_archive] + package_config, stdout=subprocess.DEVNULL, cwd=directory - ) - self.logging.info(f"Created {benchmark_archive} archive") - bytes_size = os.path.getsize(benchmark_archive) - self.logging.info("Zip archive size {:2f} MB".format(bytes_size / 1024.0 / 1024.0)) - return benchmark_archive, bytes_size - + if language_name != 'java': + # We deploy Minio config in code package since this depends on local + # deployment - it cannnot be a part of Docker image + CONFIG_FILES = { + "python": ["__main__.py"], + "nodejs": ["index.js"], + } + package_config = CONFIG_FILES[language_name] + + benchmark_archive = os.path.join(directory, f"{benchmark}.zip") + subprocess.run( + ["zip", benchmark_archive] + package_config, stdout=subprocess.DEVNULL, cwd=directory + ) + self.logging.info(f"Created {benchmark_archive} archive") + bytes_size = os.path.getsize(benchmark_archive) + self.logging.info("Zip archive size {:2f} MB".format(bytes_size / 1024.0 / 1024.0)) + return benchmark_archive, bytes_size + benchmark_jar = os.path.join(directory, "docker", "target", "benchmark-1.jar") + bytes_size = os.path.getsize(benchmark_jar) + + return benchmark_jar, bytes_size def storage_arguments(self) -> List[str]: storage = cast(Minio, self.get_storage()) return [ @@ -281,27 +284,53 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "OpenWhisk code_package.language_name, code_package.language_version, ) - subprocess.run( - [ - *self.get_wsk_cmd(), - "action", - "create", - func_name, - "--web", - "true", - "--docker", - docker_image, - "--memory", - str(code_package.benchmark_config.memory), - "--timeout", - str(code_package.benchmark_config.timeout * 1000), - *self.storage_arguments(), - code_package.code_location, - ], - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, - check=True, - ) + if code_package.language_name == 'java': + subprocess.run( + [ + *self.get_wsk_cmd(), + "action", + "create", + func_name, + "--web", + "true", + "--docker", + docker_image, + "--memory", + str(code_package.benchmark_config.memory), + "--timeout", + str(code_package.benchmark_config.timeout * 1000), + *self.storage_arguments(), + code_package.code_location, + "--main", + "Main" + ], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + check=True, + ) + + else: + subprocess.run( + [ + *self.get_wsk_cmd(), + "action", + "create", + func_name, + "--web", + "true", + "--docker", + docker_image, + "--memory", + str(code_package.benchmark_config.memory), + "--timeout", + str(code_package.benchmark_config.timeout * 1000), + *self.storage_arguments(), + code_package.code_location, + ], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + check=True, + ) function_cfg.docker_image = docker_image res = OpenWhiskFunction( func_name, code_package.benchmark, code_package.hash, function_cfg From 686b536901bd16e5753ebfba988dada2203e6fb0 Mon Sep 17 00:00:00 2001 From: Mahla Sharifi <69010140+mahlashrifi@users.noreply.github.com> Date: Sun, 6 Oct 2024 20:11:21 +0330 Subject: [PATCH 17/25] Update config.json --- benchmarks/600.java/602.login-checker/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmarks/600.java/602.login-checker/config.json b/benchmarks/600.java/602.login-checker/config.json index 11be1ace..4a592102 100644 --- a/benchmarks/600.java/602.login-checker/config.json +++ b/benchmarks/600.java/602.login-checker/config.json @@ -1,6 +1,6 @@ { "timeout": 60, - "memory": 512, + "memory": 24, "languages": ["java"] } - \ No newline at end of file + From 4f24bd35b8cf20ca2ea89f09fa7bc50aa5742b9f Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 17 Oct 2024 21:41:29 +0330 Subject: [PATCH 18/25] Add all codes --- .vscode/launch.json | 14 +- benchmarks/600.java/601.hello-world/input.py | 0 .../java/src/main/java/faas/App.java | 3 - .../603.train-recommender/config.json | 6 + .../600.java/603.train-recommender/input.py | 5 + .../603.train-recommender/java/pom.xml | 46 +++ .../java/src/main/java/faas/App.java | 119 +++++++ .../java/src/main/java/util/Order.java | 293 ++++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 180 +++++++++++ .../java/src/main/java/util/OrderItemSet.java | 80 +++++ benchmarks/600.java/benchmark2/config.json | 6 + benchmarks/600.java/benchmark2/input.py | 5 + benchmarks/600.java/benchmark2/java/pom.xml | 64 ++++ .../java/src/main/java/faas/App.java | 26 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 +++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 ++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/600.java/benchmark3/config.json | 6 + benchmarks/600.java/benchmark3/input.py | 5 + benchmarks/600.java/benchmark3/java/pom.xml | 63 ++++ .../java/src/main/java/faas/App.java | 26 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 +++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 ++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/600.java/benchmark4/config.json | 6 + benchmarks/600.java/benchmark4/input.py | 5 + benchmarks/600.java/benchmark4/java/pom.xml | 63 ++++ .../java/src/main/java/faas/App.java | 26 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 +++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 ++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/600.java/benchmark5/config.json | 6 + benchmarks/600.java/benchmark5/input.py | 5 + benchmarks/600.java/benchmark5/java/pom.xml | 63 ++++ .../java/src/main/java/faas/App.java | 26 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 +++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 ++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/600.java/benchmark6/config.json | 6 + benchmarks/600.java/benchmark6/input.py | 5 + benchmarks/600.java/benchmark6/java/pom.xml | 68 ++++ .../java/src/main/java/faas/App.java | 26 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 +++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 ++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/600.java/benchmark7/config.json | 6 + benchmarks/600.java/benchmark7/input.py | 5 + benchmarks/600.java/benchmark7/java/pom.xml | 73 +++++ .../java/src/main/java/faas/App.java | 26 ++ .../main/java/util/ConstantKeyProvider.java | 21 ++ .../java/src/main/java/util/IKeyProvider.java | 23 ++ .../src/main/java/util/ISecurityProvider.java | 39 +++ .../java/src/main/java/util/Order.java | 281 +++++++++++++++++ .../java/src/main/java/util/OrderItem.java | 179 +++++++++++ .../java/src/main/java/util/SessionBlob.java | 133 ++++++++ .../main/java/util/ShaSecurityProvider.java | 79 +++++ benchmarks/wrappers/openwhisk/java/Main.java | 9 +- config/{example2.json => example-train.json} | 8 +- config/example.json | 66 +--- config/login-checker-config.json | 38 +++ experiments.json | 122 -------- out_storage.json | 6 +- 82 files changed, 5942 insertions(+), 199 deletions(-) create mode 100644 benchmarks/600.java/601.hello-world/input.py create mode 100644 benchmarks/600.java/603.train-recommender/config.json create mode 100644 benchmarks/600.java/603.train-recommender/input.py create mode 100644 benchmarks/600.java/603.train-recommender/java/pom.xml create mode 100644 benchmarks/600.java/603.train-recommender/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/603.train-recommender/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItemSet.java create mode 100644 benchmarks/600.java/benchmark2/config.json create mode 100644 benchmarks/600.java/benchmark2/input.py create mode 100644 benchmarks/600.java/benchmark2/java/pom.xml create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java create mode 100644 benchmarks/600.java/benchmark3/config.json create mode 100644 benchmarks/600.java/benchmark3/input.py create mode 100644 benchmarks/600.java/benchmark3/java/pom.xml create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java create mode 100644 benchmarks/600.java/benchmark4/config.json create mode 100644 benchmarks/600.java/benchmark4/input.py create mode 100644 benchmarks/600.java/benchmark4/java/pom.xml create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java create mode 100644 benchmarks/600.java/benchmark5/config.json create mode 100644 benchmarks/600.java/benchmark5/input.py create mode 100644 benchmarks/600.java/benchmark5/java/pom.xml create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java create mode 100644 benchmarks/600.java/benchmark6/config.json create mode 100644 benchmarks/600.java/benchmark6/input.py create mode 100644 benchmarks/600.java/benchmark6/java/pom.xml create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java create mode 100644 benchmarks/600.java/benchmark7/config.json create mode 100644 benchmarks/600.java/benchmark7/input.py create mode 100644 benchmarks/600.java/benchmark7/java/pom.xml create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java create mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java rename config/{example2.json => example-train.json} (83%) create mode 100644 config/login-checker-config.json delete mode 100644 experiments.json diff --git a/.vscode/launch.json b/.vscode/launch.json index b30a810f..a7605f17 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,24 +2,30 @@ { "version": "0.2.0", "configurations": [ + { + "type": "java", + "name": "Main", + "request": "launch", + "mainClass": "Main" + }, { "name": "Python: Debug sebs.py Command", "type": "python", "request": "launch", - "program": "${workspaceFolder}/sebs.py", // Path to sebs.py script + "program": "${workspaceFolder}/sebs.py", "args": [ "benchmark", "invoke", "602.login-checker", "test", "--config", - "config/example2.json", + "config/login-checker-config.json", "--deployment", "openwhisk", "--verbose" ], - "console": "integratedTerminal", // Runs in VS Code's integrated terminal - "cwd": "${workspaceFolder}", // Set the current working directory to the workspace + "console": "integratedTerminal", + "cwd": "${workspaceFolder}", "justMyCode": false } ] diff --git a/benchmarks/600.java/601.hello-world/input.py b/benchmarks/600.java/601.hello-world/input.py new file mode 100644 index 00000000..e69de29b diff --git a/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java b/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java index 30f98d2f..ff55cef8 100644 --- a/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java +++ b/benchmarks/600.java/602.login-checker/java/src/main/java/faas/App.java @@ -20,9 +20,6 @@ public JsonObject handler(JsonObject args) { jsonResult.addProperty("Authorization-Status", "Authorized"); else jsonResult.addProperty("Authorization-Status", "Unauthorized"); - -// Base version in TeaStore: (Commented out due to dependency issues, as the code below was run in the servlet space) -// Response.status(Response.Status.OK).entity(new ShaSecurityProvider().validate(blob)).build(); return jsonResult; } } diff --git a/benchmarks/600.java/603.train-recommender/config.json b/benchmarks/600.java/603.train-recommender/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/603.train-recommender/input.py b/benchmarks/600.java/603.train-recommender/input.py new file mode 100644 index 00000000..0db725de --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return {"orderItems":[{"id":0,"productId":201,"orderId":1,"quantity":2,"unitPriceInCents":0},{"id":0,"productId":202,"orderId":1,"quantity":1,"unitPriceInCents":0},{"id":0,"productId":203,"orderId":2,"quantity":5,"unitPriceInCents":0}],"orders":[{"id":1,"userId":101,"totalPriceInCents":0},{"id":2,"userId":102,"totalPriceInCents":0}]} diff --git a/benchmarks/600.java/603.train-recommender/java/pom.xml b/benchmarks/600.java/603.train-recommender/java/pom.xml new file mode 100644 index 00000000..9c9494cf --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/java/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/603.train-recommender/java/src/main/java/faas/App.java b/benchmarks/600.java/603.train-recommender/java/src/main/java/faas/App.java new file mode 100644 index 00000000..7db2fafb --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/java/src/main/java/faas/App.java @@ -0,0 +1,119 @@ +package faas; +import com.google.gson.*; +import utils.Order; +import utils.OrderItem; +import utils.OrderItemSet; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.HashSet; +import java.util.HashMap; + +public class App { + + + private static boolean trainingFinished = false; + + public static final int MAX_NUMBER_OF_RECOMMENDATIONS = 10; + + + + public static JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + JsonObject jsonResult = new JsonObject(); + // Deserialize JSON input to Lists of OrderItem and Order + JsonArray orderItemsArray = args.getAsJsonArray("orderItems"); + JsonArray ordersArray = args.getAsJsonArray("orders"); + + List orderItems = new ArrayList<>(); + for (JsonElement element : orderItemsArray) { + orderItems.add(gson.fromJson(element, OrderItem.class)); + } + + List orders = new ArrayList<>(); + for (JsonElement element : ordersArray) { + orders.add(gson.fromJson(element, Order.class)); + } + Map> userBuyingMatrix; + Map> userItemSets; + Set totalProducts; + long tic = System.currentTimeMillis(); + totalProducts = new HashSet<>(); + // first create order mapping unorderized + Map unOrderizeditemSets = new HashMap<>(); + for (OrderItem orderItem : orderItems) { + if (!unOrderizeditemSets.containsKey(orderItem.getOrderId())) { + unOrderizeditemSets.put(orderItem.getOrderId(), new OrderItemSet()); + unOrderizeditemSets.get(orderItem.getOrderId()).setOrderId(orderItem.getOrderId()); + } + unOrderizeditemSets.get(orderItem.getOrderId()).getOrderset().put(orderItem.getProductId(), + orderItem.getQuantity()); + // see, if we already have our item + if (!totalProducts.contains(orderItem.getProductId())) { + // if not known yet -> add + totalProducts.add(orderItem.getProductId()); + } + } + // now map each id with the corresponding order + Map itemSets = new HashMap<>(); + for (Long orderid : unOrderizeditemSets.keySet()) { + Order realOrder = findOrder(orders, orderid); + itemSets.put(realOrder, unOrderizeditemSets.get(orderid)); + } + userItemSets = new HashMap<>(); + for (Order order : itemSets.keySet()) { + if (!userItemSets.containsKey(order.getUserId())) { + userItemSets.put(order.getUserId(), new HashSet()); + } + itemSets.get(order).setUserId(order.getUserId()); + userItemSets.get(order.getUserId()).add(itemSets.get(order)); + } + userBuyingMatrix = createUserBuyingMatrix(userItemSets); + executePreprocessing(); + trainingFinished = true; + jsonResult.addProperty("trainingFinished", trainingFinished); + return jsonResult; + } + protected static void executePreprocessing() { + // do nothing + } + + private static Order findOrder(List orders, long orderid) { + for (Order order : orders) { + if (order.getId() == orderid) { + return order; + } + } + return null; + } + + private static Map> createUserBuyingMatrix(Map> useritemsets) { + Map> matrix = new HashMap<>(); + // for each user + for (Map.Entry> entry : useritemsets.entrySet()) { + // create a new line for this user-ID + Map line = new HashMap<>(); + // for all orders of that user + for (OrderItemSet orderset : entry.getValue()) { + // for all orderitems of that orderset + for (Entry product : orderset.getOrderset().entrySet()) { + // if key was not known before -> first occurence + if (!line.containsKey(product.getKey())) { + line.put(product.getKey(), Double.valueOf(product.getValue())); + } else { + // if key was known before -> increase counter + line.put(product.getKey(), Double.valueOf(line.get(product.getKey()) + product.getValue())); + } + } + } + // add this user-ID to the matrix + matrix.put(entry.getKey(), line); + } + return matrix; + } + + } +//} diff --git a/benchmarks/600.java/603.train-recommender/java/src/main/java/util/Order.java b/benchmarks/600.java/603.train-recommender/java/src/main/java/util/Order.java new file mode 100644 index 00000000..975e828a --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/java/src/main/java/util/Order.java @@ -0,0 +1,293 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package utils; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..d49de786 --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItem.java @@ -0,0 +1,180 @@ +package utils; + + + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItemSet.java b/benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItemSet.java new file mode 100644 index 00000000..f8fb7bf8 --- /dev/null +++ b/benchmarks/600.java/603.train-recommender/java/src/main/java/util/OrderItemSet.java @@ -0,0 +1,80 @@ +package utils; +import java.util.HashMap; +import java.util.Map; + +/** + * Objects of this class holds a mapping of {@link Product} IDs to quantities + * that were bought in the same {@link Order} by one {@link User}. Non-present + * {@link Product} IDs imply a quantity of 0. + * + * @author Johannes Grohmann + * + */ +public class OrderItemSet { + + /** + * Standard constructor. + */ + public OrderItemSet() { + orderset = new HashMap<>(); + } + + /** + * The user that made this order. + */ + private long userId; + + /** + * The orderId that the Items were bought in. + */ + private long orderId; + + /** + * The productIds that were bought together with the given quantity. + */ + private Map orderset; + + /** + * @return the orderset + */ + public Map getOrderset() { + return orderset; + } + + /** + * @param orderset + * the orderset to set + */ + public void setOrderset(Map orderset) { + this.orderset = orderset; + } + + /** + * @return the orderId + */ + public long getOrderId() { + return orderId; + } + + /** + * @param orderId + * the orderId to set + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /** + * @return the userId + */ + public long getUserId() { + return userId; + } + + /** + * @param userId the userId to set + */ + public void setUserId(long userId) { + this.userId = userId; + } +} diff --git a/benchmarks/600.java/benchmark2/config.json b/benchmarks/600.java/benchmark2/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/benchmark2/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/benchmark2/input.py b/benchmarks/600.java/benchmark2/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/benchmark2/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark2/java/pom.xml b/benchmarks/600.java/benchmark2/java/pom.xml new file mode 100644 index 00000000..5851f090 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java new file mode 100644 index 00000000..ff55cef8 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java @@ -0,0 +1,26 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/600.java/benchmark3/config.json b/benchmarks/600.java/benchmark3/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/benchmark3/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/benchmark3/input.py b/benchmarks/600.java/benchmark3/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/benchmark3/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark3/java/pom.xml b/benchmarks/600.java/benchmark3/java/pom.xml new file mode 100644 index 00000000..37bd1c84 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + commons-io + commons-io + 2.11.0 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java new file mode 100644 index 00000000..ff55cef8 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java @@ -0,0 +1,26 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/600.java/benchmark4/config.json b/benchmarks/600.java/benchmark4/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/benchmark4/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/benchmark4/input.py b/benchmarks/600.java/benchmark4/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/benchmark4/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark4/java/pom.xml b/benchmarks/600.java/benchmark4/java/pom.xml new file mode 100644 index 00000000..dacfe9bf --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + org.apache.poi + poi-ooxml + 5.2.3 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java new file mode 100644 index 00000000..ff55cef8 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java @@ -0,0 +1,26 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/600.java/benchmark5/config.json b/benchmarks/600.java/benchmark5/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/benchmark5/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/benchmark5/input.py b/benchmarks/600.java/benchmark5/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/benchmark5/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark5/java/pom.xml b/benchmarks/600.java/benchmark5/java/pom.xml new file mode 100644 index 00000000..32025ca0 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + io.netty + netty-all + 4.1.65.Final + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java new file mode 100644 index 00000000..ff55cef8 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java @@ -0,0 +1,26 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/600.java/benchmark6/config.json b/benchmarks/600.java/benchmark6/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/benchmark6/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/benchmark6/input.py b/benchmarks/600.java/benchmark6/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/benchmark6/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark6/java/pom.xml b/benchmarks/600.java/benchmark6/java/pom.xml new file mode 100644 index 00000000..e159f1f8 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + io.netty + netty-all + 4.1.65.Final + + + org.apache.pdfbox + pdfbox + 2.0.24 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java new file mode 100644 index 00000000..ff55cef8 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java @@ -0,0 +1,26 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/600.java/benchmark7/config.json b/benchmarks/600.java/benchmark7/config.json new file mode 100644 index 00000000..11be1ace --- /dev/null +++ b/benchmarks/600.java/benchmark7/config.json @@ -0,0 +1,6 @@ +{ + "timeout": 60, + "memory": 512, + "languages": ["java"] +} + \ No newline at end of file diff --git a/benchmarks/600.java/benchmark7/input.py b/benchmarks/600.java/benchmark7/input.py new file mode 100644 index 00000000..136f8bc5 --- /dev/null +++ b/benchmarks/600.java/benchmark7/input.py @@ -0,0 +1,5 @@ +def buckets_count(): + return (0, 0) + +def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): + return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark7/java/pom.xml b/benchmarks/600.java/benchmark7/java/pom.xml new file mode 100644 index 00000000..f3a97c70 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + faas + benchmark + 1 + + + 8 + 8 + UTF-8 + + + + + + com.google.code.gson + gson + 2.11.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.17.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.17.2 + + + io.netty + netty-all + 4.1.65.Final + + + org.apache.pdfbox + pdfbox + 2.0.24 + + + org.apache.poi + poi-ooxml + 5.2.3 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java new file mode 100644 index 00000000..ff55cef8 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java @@ -0,0 +1,26 @@ +package faas; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import util.SessionBlob; +import util.ShaSecurityProvider; + +//import jakarta.ws.rs.core.Response; + + +public class App { + public JsonObject handler(JsonObject args) { + Gson gson = new Gson(); + SessionBlob blob = gson.fromJson(args, SessionBlob.class); + + ShaSecurityProvider securityProvider = new ShaSecurityProvider(); + SessionBlob validatedBlob = securityProvider.validate(blob); + + JsonObject jsonResult = new JsonObject(); + if (validatedBlob != null) + jsonResult.addProperty("Authorization-Status", "Authorized"); + else + jsonResult.addProperty("Authorization-Status", "Unauthorized"); + return jsonResult; + } +} + diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java new file mode 100644 index 00000000..ed377e1f --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java @@ -0,0 +1,21 @@ +package util; + + +/** + * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL + * PRODUCTION WORKLOAD! + * + * @author Joakim von Kistowski + * + */ +public class ConstantKeyProvider implements IKeyProvider { + + /** + * {@inheritDoc} + */ + @Override + public String getKey(SessionBlob blob) { + return "thebestsecretkey"; + } + +} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java new file mode 100644 index 00000000..c78e0dd0 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java @@ -0,0 +1,23 @@ + +package util; + +/** + * Provides keys for the security provider. The key provider must ensure that + * keys accross replicated stores are consistent. + * + * @author Joakim von Kistowski + * + */ +public interface IKeyProvider { + + /** + * Returns a key for a session blob. Key must be the same, regardless of the + * store instance upon which this call is made. + * + * @param blob + * The blob to secure. + * @return The key. + */ + public String getKey(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java new file mode 100644 index 00000000..8d710001 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java @@ -0,0 +1,39 @@ +package util; + + +/** + * Utilities for securing (e.g. encrypting) session blobs. + * + * @author Joakim von Kistowski + * + */ +public interface ISecurityProvider { + + /** + * Get the key provider for this security provider. + * + * @return The key provider. + */ + public IKeyProvider getKeyProvider(); + + /** + * Secures a session blob. May encrypt or hash values within the blob. + * + * @param blob + * The blob to secure. + * @return A secure blob to be passed on to the web ui. + */ + public SessionBlob secure(SessionBlob blob); + + /** + * Validates a secured session blob. Returns a valid and readable (e.g. + * decrypted) blob. Returns null for invalid blobs. + * + * @param blob + * The blob to secure. + * @return The valid and readable (e.g. decrypted) blob. Returns null for + * invalid blobs. + */ + public SessionBlob validate(SessionBlob blob); + +} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java new file mode 100644 index 00000000..95434605 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java @@ -0,0 +1,281 @@ + +package util; + +/** + * Entity for orders. + * + * @author Joakim von Kistowski + * + */ +public class Order { + + private long id; + private long userId; + private String time; + + private long totalPriceInCents; + private String addressName; + private String address1; + private String address2; + + private String creditCardCompany; + private String creditCardNumber; + private String creditCardExpiryDate; + + /** + * Create a new and empty order. + */ + public Order() { + + } + + /** + * Every entity needs a copy constructor. + * + * @param order + * The order to copy. + */ + public Order(Order order) { + setId(order.getId()); + setUserId(order.getUserId()); + setTime(order.getTime()); + setTotalPriceInCents(order.getTotalPriceInCents()); + setAddressName(order.getAddressName()); + setAddress1(order.getAddress1()); + setAddress2(order.getAddress2()); + setCreditCardCompany(order.getCreditCardCompany()); + setCreditCardNumber(order.getCreditCardNumber()); + setCreditCardExpiryDate(order.getCreditCardExpiryDate()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * Get the User id. + * + * @return the userId. + */ + public long getUserId() { + return userId; + } + + /** + * Set the User Id. + * + * @param userId + * the userId to set. + */ + public void setUserId(long userId) { + this.userId = userId; + } + + /** + * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @return the time. + */ + public String getTime() { + return time; + } + + /** + * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. + * + * @param time + * the time to set. + */ + public void setTime(String time) { + this.time = time; + } + + /** + * Get the total price in cents. + * + * @return the totalPriceInCents. + */ + public long getTotalPriceInCents() { + return totalPriceInCents; + } + + /** + * Set the total price in cents. + * + * @param totalPriceInCents + * the totalPriceInCents to set. + */ + public void setTotalPriceInCents(long totalPriceInCents) { + this.totalPriceInCents = totalPriceInCents; + } + + /** + * Get the name for the address. + * + * @return the addressName. + */ + public String getAddressName() { + return addressName; + } + + /** + * Set the name for the address. + * + * @param addressName + * the addressName to set. + */ + public void setAddressName(String addressName) { + this.addressName = addressName; + } + + /** + * Get address line 1. + * + * @return the address1. + */ + public String getAddress1() { + return address1; + } + + /** + * Set address line 1. + * + * @param address1 + * the address1 to set. + */ + public void setAddress1(String address1) { + this.address1 = address1; + } + + /** + * Get address line 2. + * + * @return the address2. + */ + public String getAddress2() { + return address2; + } + + /** + * Set address line 2. + * + * @param address2 + * the address2 to set. + */ + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * Get the name of the credit card company. + * + * @return the creditCardCompany. + */ + public String getCreditCardCompany() { + return creditCardCompany; + } + + /** + * Set the name of the credit card company. + * + * @param creditCardCompany + * the creditCardCompany to set. + */ + public void setCreditCardCompany(String creditCardCompany) { + this.creditCardCompany = creditCardCompany; + } + + /** + * Get the credit card number. + * + * @return the creditCardNumber. + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Set the credit card number. + * + * @param creditCardNumber + * the creditCardNumber to set. + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @return the creditCardExpiryDate. + */ + public String getCreditCardExpiryDate() { + return creditCardExpiryDate; + } + + /** + * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. + * + * @param creditCardExpiryDate + * the creditCardExpiryDate to set. + */ + public void setCreditCardExpiryDate(String creditCardExpiryDate) { + this.creditCardExpiryDate = creditCardExpiryDate; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (userId ^ (userId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Order other = (Order) obj; + if (id != other.id) { + return false; + } + if (userId != other.userId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java new file mode 100644 index 00000000..f0c01fe9 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java @@ -0,0 +1,179 @@ + +package util; + +/** + * Entity Class for OrderItems (item with quantity in shopping cart or order). + * + * @author Joakim von Kistowski + * + */ +public class OrderItem { + + private long id; + private long productId; + private long orderId; + private int quantity; + private long unitPriceInCents; + + /** + * Create a new and empty OrderItem. + */ + public OrderItem() { + + } + + /** + * Every Entity needs a Copy-Constructor! + * + * @param orderItem + * The entity to Copy. + */ + public OrderItem(OrderItem orderItem) { + setId(orderItem.getId()); + setProductId(orderItem.getProductId()); + setOrderId(orderItem.getOrderId()); + setQuantity(orderItem.getQuantity()); + setUnitPriceInCents(orderItem.getUnitPriceInCents()); + } + + /** + * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). + * + * @return The id. + */ + public long getId() { + return id; + } + + /** + * For REST use only. Sets the ID. Ignored by persistence. + * + * @param id + * ID, as passed by the REST API. + */ + public void setId(long id) { + this.id = id; + } + + /** + * ID of the order item's product. + * + * @return Product Id; + */ + public long getProductId() { + return productId; + } + + /** + * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. + * + * @param productId + * The product ID to set. + */ + public void setProductId(long productId) { + this.productId = productId; + } + + /** + * Get the quantity (amount in shopping cart/order). + * + * @return The quantity. + */ + public int getQuantity() { + return quantity; + } + + /** + * Set the quantity (amount in shopping cart/order). + * + * @param quantity + * The quantity. + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * The price per single item in the order item. + * + * @return Price per single item. + */ + public long getUnitPriceInCents() { + return unitPriceInCents; + } + + /** + * Set the price per single item in the order item. + * + * @param unitPriceInCents + * Price per single item. + */ + public void setUnitPriceInCents(long unitPriceInCents) { + this.unitPriceInCents = unitPriceInCents; + } + + /** + * Gets the ID of the order item's order. + * + * @return The order ID. + */ + public long getOrderId() { + return orderId; + } + + /** + * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For + * persistence the order must already exist in database. + * + * @param orderId + * The order ID to set. + */ + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + (int) (orderId ^ (orderId >>> 32)); + result = prime * result + (int) (productId ^ (productId >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + OrderItem other = (OrderItem) obj; + if (id != other.id) { + return false; + } + if (orderId != other.orderId) { + return false; + } + if (productId != other.productId) { + return false; + } + return true; + } + +} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java new file mode 100644 index 00000000..6875efa4 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java @@ -0,0 +1,133 @@ +package util; + +import java.util.LinkedList; +import java.util.List; + +/** + * Blob containing all information about the user session. + * @author Simon + */ +public class SessionBlob { + + private Long uid; + private String sid; + private String token; + private Order order; + private List orderItems = new LinkedList(); + private String message; + + /** + * Constructor, creates an empty order. + */ + public SessionBlob() { + this.setOrder(new Order()); + } + + /** + * Getter for the userid. + * @return userid + */ + public Long getUID() { + return uid; + } + + /** + * Setter for the userid. + * @param uID userid + */ + public void setUID(Long uID) { + uid = uID; + } + + /** + * Getter for session id. + * @return session id + */ + public String getSID() { + return sid; + } + + /** + * Setter for session id. + * @param sID session id + */ + public void setSID(String sID) { + sid = sID; + } + + /** + * Getter for trust token. + * @return trust token + */ + public String getToken() { + return token; + } + + /** + * Setter for trust token. + * @param token trust token. + */ + public void setToken(String token) { + this.token = token; + } + + /** + * Setter for the message. + * @param message String + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Getter for the message. + * @return message + */ + public String getMessage() { + return message; + } + + /** + * Getter for order. + * @return order + */ + public Order getOrder() { + return order; + } + + /** + * Setter for order. + * @param order order + */ + public void setOrder(Order order) { + this.order = order; + } + + /** + * Getter for order items. + * @return order items. + */ + public List getOrderItems() { + return orderItems; + } + + /** + * Setter for order items. + * @param orderItems list of order items + */ + public void setOrderItems(List orderItems) { + this.orderItems = orderItems; + } + + @Override + public String toString() { + return "ClassName{" + + "uid=" + uid + + ", sid='" + sid + '\'' + + ", token='" + token + '\'' + + ", order=" + (order != null ? order.toString() : "null") + + ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java new file mode 100644 index 00000000..d9c88f90 --- /dev/null +++ b/benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java @@ -0,0 +1,79 @@ +package util; + +import java.io.UnsupportedEncodingException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. + * + * @author Simon + * + */ +public class ShaSecurityProvider implements ISecurityProvider { + + @Override + public IKeyProvider getKeyProvider() { + return new ConstantKeyProvider(); + } + + @Override + public SessionBlob secure(SessionBlob blob) { + if (blob.getUID() == null || blob.getSID() == null) { + return blob; + } + blob.setToken(null); + String blobString = blobToString(blob); + blob.setToken(getSha512(blobString)); + return blob; + } + + private String blobToString(SessionBlob blob) { + ObjectMapper o = new ObjectMapper(); + try { + return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); + } catch (JsonProcessingException | UnsupportedEncodingException e) + { + throw new IllegalStateException("Could not save blob!"); + } + } + + @Override + public SessionBlob validate(SessionBlob blob) { + if (blob.getToken() == null) { + return null; + } + + String token = blob.getToken(); + blob.setToken(null); + String blobString = blobToString(blob); + String validationToken = getSha512(blobString); + if (validationToken.equals(token)) { + return blob; + } + return null; + } + + private String getSha512(String passwordToHash) { + String generatedPassword = null; + try { + String salt = getKeyProvider().getKey(null); + MessageDigest md = MessageDigest.getInstance("SHA-512"); + md.update(salt.getBytes("UTF-8")); + byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + generatedPassword = sb.toString(); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + return generatedPassword; + } +} diff --git a/benchmarks/wrappers/openwhisk/java/Main.java b/benchmarks/wrappers/openwhisk/java/Main.java index b41e4405..e10d9e11 100644 --- a/benchmarks/wrappers/openwhisk/java/Main.java +++ b/benchmarks/wrappers/openwhisk/java/Main.java @@ -19,12 +19,17 @@ public static JsonObject main(JsonObject args) { Gson gson = new Gson(); App function = new App(); + long start_nano = System.nanoTime(); + Instant begin = Instant.now(); JsonObject result = function.handler(args); Instant end = Instant.now(); - long computeTime = Duration.between(begin, end).toNanos() / 1000; // Convert nanoseconds to microseconds + long end_nano = System.nanoTime(); + + // long computeTime = Duration.between(begin, end).toNanos() / 1000; // Convert nanoseconds to microseconds + long computeTime = end_nano - start_nano; boolean isCold = false; String fileName = "/cold_run"; @@ -47,7 +52,7 @@ public static JsonObject main(JsonObject args) { JsonObject jsonResult = new JsonObject(); jsonResult.addProperty("begin", formattedBegin); jsonResult.addProperty("end", formattedEnd); - jsonResult.addProperty("request_id", "requestId"); + jsonResult.addProperty("request_id", requestId); jsonResult.addProperty("compute_time", computeTime); jsonResult.addProperty("is_cold", isCold); jsonResult.addProperty("result", result.toString()); diff --git a/config/example2.json b/config/example-train.json similarity index 83% rename from config/example2.json rename to config/example-train.json index cc2d469e..b0c46ed9 100644 --- a/config/example2.json +++ b/config/example-train.json @@ -10,7 +10,7 @@ }, "type": "invocation-overhead", "perf-cost": { - "benchmark": "601.hello-world", + "benchmark": "603.train-recommender", "experiments": ["cold", "warm", "burst", "sequential"], "input-size": "test", "repetitions": 50, @@ -55,9 +55,9 @@ "storage": { "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", - "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", - "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", + "access_key": "4K_4r6_i10-WCXctJT7cjSVvr02yzHebpQHdHs96NcM", + "secret_key": "7f870971968d1cb7356876993fe61e4edc5977e3825b9617e796e8a333af0ad2", + "instance_id": "976374b8ec72f70dc1ac9d414d639f03bb86e1db77eb54291450c9b5ea5df689", "output_buckets": [], "input_buckets": [], "type": "minio" diff --git a/config/example.json b/config/example.json index 8180cab3..3e0ed74a 100644 --- a/config/example.json +++ b/config/example.json @@ -5,67 +5,11 @@ "update_storage": false, "download_results": false, "runtime": { - "language": "python", - "version": "3.7" - }, - "type": "invocation-overhead", - "perf-cost": { - "benchmark": "110.dynamic-html", - "experiments": ["cold", "warm", "burst", "sequential"], - "input-size": "test", - "repetitions": 50, - "concurrent-invocations": 50, - "memory-sizes": [128, 256] - }, - "network-ping-pong": { - "invocations": 50, - "repetitions": 1000, - "threads": 1 - }, - "invocation-overhead": { - "repetitions": 5, - "N": 20, - "type": "payload", - "payload_begin": 1024, - "payload_end": 6251000, - "payload_points": 20, - "code_begin": 1048576, - "code_end": 261619712, - "code_points": 20 - }, - "eviction-model": { - "invocations": 1, - "function_copy_idx": 0, - "repetitions": 5, - "sleep": 1 + "language": "java", + "version": "8" } }, "deployment": { - "name": "aws", - "aws": { - "region": "us-east-1", - "lambda-role": "" - }, - "azure": { - "region": "westeurope" - }, - "gcp": { - "region": "europe-west1", - "project_name": "", - "credentials": "" - }, - "local": { - "storage": { - "address": "", - "mapped_port": -1, - "access_key": "", - "secret_key": "", - "instance_id": "", - "input_buckets": [], - "output_buckets": [], - "type": "minio" - } - }, "openwhisk": { "shutdownStorage": false, "removeCluster": false, @@ -80,9 +24,9 @@ "storage": { "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", - "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", - "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", + "access_key": "yun7vF4uN_Qiay_H2O-7rnOKBYCQxuKCMqudDufjIJg", + "secret_key": "0f5ff6e9ee49adf19879cd6b7e351610eecb5d3d15a0056469b7707618630942", + "instance_id": "a5d66a9d5cb9e2348bdf399a4cdc77ea33400cf91b41a9c57114bfa9525e52ab", "output_buckets": [], "input_buckets": [], "type": "minio" diff --git a/config/login-checker-config.json b/config/login-checker-config.json new file mode 100644 index 00000000..e2a902f0 --- /dev/null +++ b/config/login-checker-config.json @@ -0,0 +1,38 @@ +{ + "experiments": { + "deployment": "openwhisk", + "update_code": false, + "update_storage": false, + "download_results": "true", + "runtime": { + "language": "java", + "version": "8" + } + }, + + "deployment": { + "openwhisk": { + "shutdownStorage": false, + "removeCluster": false, + "wskBypassSecurity": "true", + "wskExec": "wsk", + "experimentalManifest": false, + "docker_registry": { + "registry": "", + "username": "", + "password": "" + }, + "storage": { + "address": "172.20.10.3:9011", + "mapped_port": 9011, + "access_key": "yun7vF4uN_Qiay_H2O-7rnOKBYCQxuKCMqudDufjIJg", + "secret_key": "0f5ff6e9ee49adf19879cd6b7e351610eecb5d3d15a0056469b7707618630942", + "instance_id": "a5d66a9d5cb9e2348bdf399a4cdc77ea33400cf91b41a9c57114bfa9525e52ab", + "output_buckets": [], + "input_buckets": [], + "type": "minio" + } + } + } + } + \ No newline at end of file diff --git a/experiments.json b/experiments.json deleted file mode 100644 index 62b5271c..00000000 --- a/experiments.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "_invocations": { - "602.login-checker-java-8": { - "requestId": { - "billing": { - "_billed_time": null, - "_gb_seconds": 0, - "_memory": null - }, - "output": { - "begin": "1727290018.301000", - "compute_time": 26000, - "end": "1727290018.327000", - "is_cold": true, - "request_id": "requestId", - "result": "{\"Authorization-Status\":\"Unauthorized\"}" - }, - "provider_times": { - "execution": 0, - "initialization": 0 - }, - "request_id": "requestId", - "stats": { - "cold_start": true, - "failure": false, - "memory_used": null - }, - "times": { - "benchmark": 26000, - "client": 3975488, - "client_begin": "2024-09-25 22:16:54.373253", - "client_end": "2024-09-25 22:16:58.348741", - "http_first_byte_return": 3.975434, - "http_startup": 0.013632, - "initialization": 0 - } - } - } - }, - "_metrics": {}, - "begin_time": 1727290007.749544, - "config": { - "deployment": { - "credentials": {}, - "experimentalManifest": false, - "name": "openwhisk", - "removeCluster": false, - "resources": { - "benchmarks": "sebs-benchmarks-045723a0", - "docker_password": "", - "docker_registry": "", - "docker_username": "", - "resources_id": "045723a0", - "storage": { - "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", - "address": "172.20.10.3:9011", - "input_buckets": [], - "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", - "mapped_port": 9011, - "output_buckets": [], - "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", - "type": "minio" - } - }, - "shutdownStorage": false, - "wskBypassSecurity": "true", - "wskExec": "wsk" - }, - "experiments": { - "download_results": false, - "experiments": { - "eviction-model": { - "function_copy_idx": 0, - "invocations": 1, - "repetitions": 5, - "sleep": 1 - }, - "invocation-overhead": { - "N": 20, - "code_begin": 1048576, - "code_end": 261619712, - "code_points": 20, - "payload_begin": 1024, - "payload_end": 6251000, - "payload_points": 20, - "repetitions": 5, - "type": "payload" - }, - "network-ping-pong": { - "invocations": 50, - "repetitions": 1000, - "threads": 1 - }, - "perf-cost": { - "benchmark": "601.hello-world", - "concurrent-invocations": 50, - "experiments": [ - "cold", - "warm", - "burst", - "sequential" - ], - "input-size": "test", - "memory-sizes": [ - 128, - 256 - ], - "repetitions": 50 - } - }, - "flags": {}, - "runtime": { - "language": "java", - "version": "8" - }, - "update_code": false, - "update_storage": false - } - }, - "end_time": 1727290018.349986, - "result_bucket": null -} \ No newline at end of file diff --git a/out_storage.json b/out_storage.json index 02fd81f6..1efc2e05 100644 --- a/out_storage.json +++ b/out_storage.json @@ -1,9 +1,9 @@ { "address": "172.20.10.3:9011", "mapped_port": 9011, - "access_key": "ZAf_4KyKlhcp6QZqOvDACOiJ5sYsRufkvHKholssuc0", - "secret_key": "4b9ed3376593cf0cfd44514574db769eeeb95f7e25a8042c76d127932e17851b", - "instance_id": "fc0dfacb252dd804f3a58892b02df75fda69a6a8e195858052eb8de221f2282e", + "access_key": "yun7vF4uN_Qiay_H2O-7rnOKBYCQxuKCMqudDufjIJg", + "secret_key": "0f5ff6e9ee49adf19879cd6b7e351610eecb5d3d15a0056469b7707618630942", + "instance_id": "a5d66a9d5cb9e2348bdf399a4cdc77ea33400cf91b41a9c57114bfa9525e52ab", "output_buckets": [], "input_buckets": [], "type": "minio" From a6ec3f524642adf61951f1df5e5b3d93070d995a Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 26 Dec 2024 00:13:59 +0330 Subject: [PATCH 19/25] Remove .vscode folder from the repository and add it to .gitignore --- .vscode/launch.json | 33 --------------------------------- .vscode/settings.json | 3 --- 2 files changed, 36 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a7605f17..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,33 +0,0 @@ - -{ - "version": "0.2.0", - "configurations": [ - { - "type": "java", - "name": "Main", - "request": "launch", - "mainClass": "Main" - }, - { - "name": "Python: Debug sebs.py Command", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}/sebs.py", - "args": [ - "benchmark", - "invoke", - "602.login-checker", - "test", - "--config", - "config/login-checker-config.json", - "--deployment", - "openwhisk", - "--verbose" - ], - "console": "integratedTerminal", - "cwd": "${workspaceFolder}", - "justMyCode": false - } - ] - } - \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c5f3f6b9..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "interactive" -} \ No newline at end of file From fbc34a887691400adc01d68a7698d80a229208c2 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 26 Dec 2024 00:28:03 +0330 Subject: [PATCH 20/25] Removed out_storage.json --- .gitignore | 3 +++ out_storage.json | 10 ---------- 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 out_storage.json diff --git a/.gitignore b/.gitignore index b852a25a..6c268dee 100644 --- a/.gitignore +++ b/.gitignore @@ -182,3 +182,6 @@ cache # IntelliJ IDEA files .idea *.iml + +# Visual Studio Code files +.vscode/ \ No newline at end of file diff --git a/out_storage.json b/out_storage.json deleted file mode 100644 index 1efc2e05..00000000 --- a/out_storage.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "address": "172.20.10.3:9011", - "mapped_port": 9011, - "access_key": "yun7vF4uN_Qiay_H2O-7rnOKBYCQxuKCMqudDufjIJg", - "secret_key": "0f5ff6e9ee49adf19879cd6b7e351610eecb5d3d15a0056469b7707618630942", - "instance_id": "a5d66a9d5cb9e2348bdf399a4cdc77ea33400cf91b41a9c57114bfa9525e52ab", - "output_buckets": [], - "input_buckets": [], - "type": "minio" -} \ No newline at end of file From 29e35295e28fd3199c454890447aaf9cd37de135 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 26 Dec 2024 21:44:19 +0330 Subject: [PATCH 21/25] Refactored OpenWhisk run command handling for Java functions --- sebs/openwhisk/openwhisk.py | 47 +++++++++++-------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/sebs/openwhisk/openwhisk.py b/sebs/openwhisk/openwhisk.py index a83b5b8d..fff09971 100644 --- a/sebs/openwhisk/openwhisk.py +++ b/sebs/openwhisk/openwhisk.py @@ -284,34 +284,8 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "OpenWhisk code_package.language_name, code_package.language_version, ) - if code_package.language_name == 'java': - subprocess.run( - [ - *self.get_wsk_cmd(), - "action", - "create", - func_name, - "--web", - "true", - "--docker", - docker_image, - "--memory", - str(code_package.benchmark_config.memory), - "--timeout", - str(code_package.benchmark_config.timeout * 1000), - *self.storage_arguments(), - code_package.code_location, - "--main", - "Main" - ], - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, - check=True, - ) - - else: - subprocess.run( - [ + + run_arguments = [ *self.get_wsk_cmd(), "action", "create", @@ -326,11 +300,18 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "OpenWhisk str(code_package.benchmark_config.timeout * 1000), *self.storage_arguments(), code_package.code_location, - ], - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, - check=True, - ) + ] + if code_package.language_name == 'java': + run_arguments.extend(["--main", "Main"]) + + + subprocess.run( + run_arguments, + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + check=True, + ) + function_cfg.docker_image = docker_image res = OpenWhiskFunction( func_name, code_package.benchmark, code_package.hash, function_cfg From 1a1a64795d20c8cef96322fcede5955949e070aa Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 26 Dec 2024 21:52:00 +0330 Subject: [PATCH 22/25] Removed repo name from system.json file --- config/systems.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/systems.json b/config/systems.json index 30c6a7cc..d1ac1236 100644 --- a/config/systems.json +++ b/config/systems.json @@ -1,6 +1,6 @@ { "general": { - "docker_repository": "duckerhubformahla/serverless_benchmarks" + "docker_repository": "" }, "local": { "experiments": { From 4e997efdd716816b82ded418a7a4c688aa32e468 Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 26 Dec 2024 22:06:37 +0330 Subject: [PATCH 23/25] Removed config files mistakenly committed. --- config/example-train.json | 68 -------------------------------- config/login-checker-config.json | 38 ------------------ 2 files changed, 106 deletions(-) delete mode 100644 config/example-train.json delete mode 100644 config/login-checker-config.json diff --git a/config/example-train.json b/config/example-train.json deleted file mode 100644 index b0c46ed9..00000000 --- a/config/example-train.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "experiments": { - "deployment": "openwhisk", - "update_code": false, - "update_storage": false, - "download_results": false, - "runtime": { - "language": "java", - "version": "8" - }, - "type": "invocation-overhead", - "perf-cost": { - "benchmark": "603.train-recommender", - "experiments": ["cold", "warm", "burst", "sequential"], - "input-size": "test", - "repetitions": 50, - "concurrent-invocations": 50, - "memory-sizes": [128, 256] - }, - "network-ping-pong": { - "invocations": 50, - "repetitions": 1000, - "threads": 1 - }, - "invocation-overhead": { - "repetitions": 5, - "N": 20, - "type": "payload", - "payload_begin": 1024, - "payload_end": 6251000, - "payload_points": 20, - "code_begin": 1048576, - "code_end": 261619712, - "code_points": 20 - }, - "eviction-model": { - "invocations": 1, - "function_copy_idx": 0, - "repetitions": 5, - "sleep": 1 - } - }, - "deployment": { - "openwhisk": { - "shutdownStorage": false, - "removeCluster": false, - "wskBypassSecurity": "true", - "wskExec": "wsk", - "experimentalManifest": false, - "docker_registry": { - "registry": "", - "username": "", - "password": "" - }, - "storage": { - "address": "172.20.10.3:9011", - "mapped_port": 9011, - "access_key": "4K_4r6_i10-WCXctJT7cjSVvr02yzHebpQHdHs96NcM", - "secret_key": "7f870971968d1cb7356876993fe61e4edc5977e3825b9617e796e8a333af0ad2", - "instance_id": "976374b8ec72f70dc1ac9d414d639f03bb86e1db77eb54291450c9b5ea5df689", - "output_buckets": [], - "input_buckets": [], - "type": "minio" - } - } - } - } - \ No newline at end of file diff --git a/config/login-checker-config.json b/config/login-checker-config.json deleted file mode 100644 index e2a902f0..00000000 --- a/config/login-checker-config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "experiments": { - "deployment": "openwhisk", - "update_code": false, - "update_storage": false, - "download_results": "true", - "runtime": { - "language": "java", - "version": "8" - } - }, - - "deployment": { - "openwhisk": { - "shutdownStorage": false, - "removeCluster": false, - "wskBypassSecurity": "true", - "wskExec": "wsk", - "experimentalManifest": false, - "docker_registry": { - "registry": "", - "username": "", - "password": "" - }, - "storage": { - "address": "172.20.10.3:9011", - "mapped_port": 9011, - "access_key": "yun7vF4uN_Qiay_H2O-7rnOKBYCQxuKCMqudDufjIJg", - "secret_key": "0f5ff6e9ee49adf19879cd6b7e351610eecb5d3d15a0056469b7707618630942", - "instance_id": "a5d66a9d5cb9e2348bdf399a4cdc77ea33400cf91b41a9c57114bfa9525e52ab", - "output_buckets": [], - "input_buckets": [], - "type": "minio" - } - } - } - } - \ No newline at end of file From fbeaa8971736bda9fa9c0fba1c2df226f46aac4d Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Thu, 26 Dec 2024 22:10:26 +0330 Subject: [PATCH 24/25] Reverted config file to remove unintended changes. --- config/example.json | 78 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 10 deletions(-) diff --git a/config/example.json b/config/example.json index 3e0ed74a..d93effbf 100644 --- a/config/example.json +++ b/config/example.json @@ -1,15 +1,73 @@ { "experiments": { - "deployment": "openwhisk", + "deployment": "aws", "update_code": false, "update_storage": false, "download_results": false, + "architecture": "arm64", + "container_deployment": true, "runtime": { - "language": "java", - "version": "8" + "language": "python", + "version": "3.8" + }, + "type": "invocation-overhead", + "perf-cost": { + "benchmark": "110.dynamic-html", + "experiments": ["cold", "warm", "burst", "sequential"], + "input-size": "test", + "repetitions": 50, + "concurrent-invocations": 50, + "memory-sizes": [128, 256] + }, + "network-ping-pong": { + "invocations": 50, + "repetitions": 1000, + "threads": 1 + }, + "invocation-overhead": { + "repetitions": 5, + "N": 20, + "type": "payload", + "payload_begin": 1024, + "payload_end": 6251000, + "payload_points": 20, + "code_begin": 1048576, + "code_end": 261619712, + "code_points": 20 + }, + "eviction-model": { + "invocations": 1, + "function_copy_idx": 0, + "repetitions": 5, + "sleep": 1 } }, "deployment": { + "name": "aws", + "aws": { + "region": "us-east-1", + "lambda-role": "" + }, + "azure": { + "region": "westeurope" + }, + "gcp": { + "region": "europe-west1", + "project_name": "", + "credentials": "" + }, + "local": { + "storage": { + "address": "", + "mapped_port": -1, + "access_key": "", + "secret_key": "", + "instance_id": "", + "input_buckets": [], + "output_buckets": [], + "type": "minio" + } + }, "openwhisk": { "shutdownStorage": false, "removeCluster": false, @@ -22,15 +80,15 @@ "password": "" }, "storage": { - "address": "172.20.10.3:9011", - "mapped_port": 9011, - "access_key": "yun7vF4uN_Qiay_H2O-7rnOKBYCQxuKCMqudDufjIJg", - "secret_key": "0f5ff6e9ee49adf19879cd6b7e351610eecb5d3d15a0056469b7707618630942", - "instance_id": "a5d66a9d5cb9e2348bdf399a4cdc77ea33400cf91b41a9c57114bfa9525e52ab", - "output_buckets": [], + "address": "", + "mapped_port": -1, + "access_key": "", + "secret_key": "", + "instance_id": "", "input_buckets": [], + "output_buckets": [], "type": "minio" } } } -} +} \ No newline at end of file From 28b4e92f009f300619f0d0b7ce04a05d167d088d Mon Sep 17 00:00:00 2001 From: mahlashrifi Date: Tue, 4 Feb 2025 11:37:04 +0330 Subject: [PATCH 25/25] Remove redundant benchmarks --- benchmarks/600.java/benchmark2/config.json | 6 - benchmarks/600.java/benchmark2/input.py | 5 - benchmarks/600.java/benchmark2/java/pom.xml | 64 ---- .../java/src/main/java/faas/App.java | 26 -- .../main/java/util/ConstantKeyProvider.java | 21 -- .../java/src/main/java/util/IKeyProvider.java | 23 -- .../src/main/java/util/ISecurityProvider.java | 39 --- .../java/src/main/java/util/Order.java | 281 ------------------ .../java/src/main/java/util/OrderItem.java | 179 ----------- .../java/src/main/java/util/SessionBlob.java | 133 --------- .../main/java/util/ShaSecurityProvider.java | 79 ----- benchmarks/600.java/benchmark3/config.json | 6 - benchmarks/600.java/benchmark3/input.py | 5 - benchmarks/600.java/benchmark3/java/pom.xml | 63 ---- .../java/src/main/java/faas/App.java | 26 -- .../main/java/util/ConstantKeyProvider.java | 21 -- .../java/src/main/java/util/IKeyProvider.java | 23 -- .../src/main/java/util/ISecurityProvider.java | 39 --- .../java/src/main/java/util/Order.java | 281 ------------------ .../java/src/main/java/util/OrderItem.java | 179 ----------- .../java/src/main/java/util/SessionBlob.java | 133 --------- .../main/java/util/ShaSecurityProvider.java | 79 ----- benchmarks/600.java/benchmark4/config.json | 6 - benchmarks/600.java/benchmark4/input.py | 5 - benchmarks/600.java/benchmark4/java/pom.xml | 63 ---- .../java/src/main/java/faas/App.java | 26 -- .../main/java/util/ConstantKeyProvider.java | 21 -- .../java/src/main/java/util/IKeyProvider.java | 23 -- .../src/main/java/util/ISecurityProvider.java | 39 --- .../java/src/main/java/util/Order.java | 281 ------------------ .../java/src/main/java/util/OrderItem.java | 179 ----------- .../java/src/main/java/util/SessionBlob.java | 133 --------- .../main/java/util/ShaSecurityProvider.java | 79 ----- benchmarks/600.java/benchmark5/config.json | 6 - benchmarks/600.java/benchmark5/input.py | 5 - benchmarks/600.java/benchmark5/java/pom.xml | 63 ---- .../java/src/main/java/faas/App.java | 26 -- .../main/java/util/ConstantKeyProvider.java | 21 -- .../java/src/main/java/util/IKeyProvider.java | 23 -- .../src/main/java/util/ISecurityProvider.java | 39 --- .../java/src/main/java/util/Order.java | 281 ------------------ .../java/src/main/java/util/OrderItem.java | 179 ----------- .../java/src/main/java/util/SessionBlob.java | 133 --------- .../main/java/util/ShaSecurityProvider.java | 79 ----- benchmarks/600.java/benchmark6/config.json | 6 - benchmarks/600.java/benchmark6/input.py | 5 - benchmarks/600.java/benchmark6/java/pom.xml | 68 ----- .../java/src/main/java/faas/App.java | 26 -- .../main/java/util/ConstantKeyProvider.java | 21 -- .../java/src/main/java/util/IKeyProvider.java | 23 -- .../src/main/java/util/ISecurityProvider.java | 39 --- .../java/src/main/java/util/Order.java | 281 ------------------ .../java/src/main/java/util/OrderItem.java | 179 ----------- .../java/src/main/java/util/SessionBlob.java | 133 --------- .../main/java/util/ShaSecurityProvider.java | 79 ----- benchmarks/600.java/benchmark7/config.json | 6 - benchmarks/600.java/benchmark7/input.py | 5 - benchmarks/600.java/benchmark7/java/pom.xml | 73 ----- .../java/src/main/java/faas/App.java | 26 -- .../main/java/util/ConstantKeyProvider.java | 21 -- .../java/src/main/java/util/IKeyProvider.java | 23 -- .../src/main/java/util/ISecurityProvider.java | 39 --- .../java/src/main/java/util/Order.java | 281 ------------------ .../java/src/main/java/util/OrderItem.java | 179 ----------- .../java/src/main/java/util/SessionBlob.java | 133 --------- .../main/java/util/ShaSecurityProvider.java | 79 ----- 66 files changed, 5146 deletions(-) delete mode 100644 benchmarks/600.java/benchmark2/config.json delete mode 100644 benchmarks/600.java/benchmark2/input.py delete mode 100644 benchmarks/600.java/benchmark2/java/pom.xml delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java delete mode 100644 benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark3/config.json delete mode 100644 benchmarks/600.java/benchmark3/input.py delete mode 100644 benchmarks/600.java/benchmark3/java/pom.xml delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java delete mode 100644 benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark4/config.json delete mode 100644 benchmarks/600.java/benchmark4/input.py delete mode 100644 benchmarks/600.java/benchmark4/java/pom.xml delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java delete mode 100644 benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark5/config.json delete mode 100644 benchmarks/600.java/benchmark5/input.py delete mode 100644 benchmarks/600.java/benchmark5/java/pom.xml delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java delete mode 100644 benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark6/config.json delete mode 100644 benchmarks/600.java/benchmark6/input.py delete mode 100644 benchmarks/600.java/benchmark6/java/pom.xml delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java delete mode 100644 benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark7/config.json delete mode 100644 benchmarks/600.java/benchmark7/input.py delete mode 100644 benchmarks/600.java/benchmark7/java/pom.xml delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java delete mode 100644 benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java diff --git a/benchmarks/600.java/benchmark2/config.json b/benchmarks/600.java/benchmark2/config.json deleted file mode 100644 index 11be1ace..00000000 --- a/benchmarks/600.java/benchmark2/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "timeout": 60, - "memory": 512, - "languages": ["java"] -} - \ No newline at end of file diff --git a/benchmarks/600.java/benchmark2/input.py b/benchmarks/600.java/benchmark2/input.py deleted file mode 100644 index 136f8bc5..00000000 --- a/benchmarks/600.java/benchmark2/input.py +++ /dev/null @@ -1,5 +0,0 @@ -def buckets_count(): - return (0, 0) - -def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): - return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark2/java/pom.xml b/benchmarks/600.java/benchmark2/java/pom.xml deleted file mode 100644 index 5851f090..00000000 --- a/benchmarks/600.java/benchmark2/java/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - faas - benchmark - 1 - - - 8 - 8 - UTF-8 - - - - - - com.google.code.gson - gson - 2.11.0 - - - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.2 - - - org.apache.commons - commons-lang3 - 3.12.0 - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java deleted file mode 100644 index ff55cef8..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/faas/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package faas; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import util.SessionBlob; -import util.ShaSecurityProvider; - -//import jakarta.ws.rs.core.Response; - - -public class App { - public JsonObject handler(JsonObject args) { - Gson gson = new Gson(); - SessionBlob blob = gson.fromJson(args, SessionBlob.class); - - ShaSecurityProvider securityProvider = new ShaSecurityProvider(); - SessionBlob validatedBlob = securityProvider.validate(blob); - - JsonObject jsonResult = new JsonObject(); - if (validatedBlob != null) - jsonResult.addProperty("Authorization-Status", "Authorized"); - else - jsonResult.addProperty("Authorization-Status", "Unauthorized"); - return jsonResult; - } -} - diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java deleted file mode 100644 index ed377e1f..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/ConstantKeyProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - - -/** - * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL - * PRODUCTION WORKLOAD! - * - * @author Joakim von Kistowski - * - */ -public class ConstantKeyProvider implements IKeyProvider { - - /** - * {@inheritDoc} - */ - @Override - public String getKey(SessionBlob blob) { - return "thebestsecretkey"; - } - -} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java deleted file mode 100644 index c78e0dd0..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/IKeyProvider.java +++ /dev/null @@ -1,23 +0,0 @@ - -package util; - -/** - * Provides keys for the security provider. The key provider must ensure that - * keys accross replicated stores are consistent. - * - * @author Joakim von Kistowski - * - */ -public interface IKeyProvider { - - /** - * Returns a key for a session blob. Key must be the same, regardless of the - * store instance upon which this call is made. - * - * @param blob - * The blob to secure. - * @return The key. - */ - public String getKey(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java deleted file mode 100644 index 8d710001..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/ISecurityProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package util; - - -/** - * Utilities for securing (e.g. encrypting) session blobs. - * - * @author Joakim von Kistowski - * - */ -public interface ISecurityProvider { - - /** - * Get the key provider for this security provider. - * - * @return The key provider. - */ - public IKeyProvider getKeyProvider(); - - /** - * Secures a session blob. May encrypt or hash values within the blob. - * - * @param blob - * The blob to secure. - * @return A secure blob to be passed on to the web ui. - */ - public SessionBlob secure(SessionBlob blob); - - /** - * Validates a secured session blob. Returns a valid and readable (e.g. - * decrypted) blob. Returns null for invalid blobs. - * - * @param blob - * The blob to secure. - * @return The valid and readable (e.g. decrypted) blob. Returns null for - * invalid blobs. - */ - public SessionBlob validate(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java deleted file mode 100644 index 95434605..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/Order.java +++ /dev/null @@ -1,281 +0,0 @@ - -package util; - -/** - * Entity for orders. - * - * @author Joakim von Kistowski - * - */ -public class Order { - - private long id; - private long userId; - private String time; - - private long totalPriceInCents; - private String addressName; - private String address1; - private String address2; - - private String creditCardCompany; - private String creditCardNumber; - private String creditCardExpiryDate; - - /** - * Create a new and empty order. - */ - public Order() { - - } - - /** - * Every entity needs a copy constructor. - * - * @param order - * The order to copy. - */ - public Order(Order order) { - setId(order.getId()); - setUserId(order.getUserId()); - setTime(order.getTime()); - setTotalPriceInCents(order.getTotalPriceInCents()); - setAddressName(order.getAddressName()); - setAddress1(order.getAddress1()); - setAddress2(order.getAddress2()); - setCreditCardCompany(order.getCreditCardCompany()); - setCreditCardNumber(order.getCreditCardNumber()); - setCreditCardExpiryDate(order.getCreditCardExpiryDate()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * Get the User id. - * - * @return the userId. - */ - public long getUserId() { - return userId; - } - - /** - * Set the User Id. - * - * @param userId - * the userId to set. - */ - public void setUserId(long userId) { - this.userId = userId; - } - - /** - * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @return the time. - */ - public String getTime() { - return time; - } - - /** - * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @param time - * the time to set. - */ - public void setTime(String time) { - this.time = time; - } - - /** - * Get the total price in cents. - * - * @return the totalPriceInCents. - */ - public long getTotalPriceInCents() { - return totalPriceInCents; - } - - /** - * Set the total price in cents. - * - * @param totalPriceInCents - * the totalPriceInCents to set. - */ - public void setTotalPriceInCents(long totalPriceInCents) { - this.totalPriceInCents = totalPriceInCents; - } - - /** - * Get the name for the address. - * - * @return the addressName. - */ - public String getAddressName() { - return addressName; - } - - /** - * Set the name for the address. - * - * @param addressName - * the addressName to set. - */ - public void setAddressName(String addressName) { - this.addressName = addressName; - } - - /** - * Get address line 1. - * - * @return the address1. - */ - public String getAddress1() { - return address1; - } - - /** - * Set address line 1. - * - * @param address1 - * the address1 to set. - */ - public void setAddress1(String address1) { - this.address1 = address1; - } - - /** - * Get address line 2. - * - * @return the address2. - */ - public String getAddress2() { - return address2; - } - - /** - * Set address line 2. - * - * @param address2 - * the address2 to set. - */ - public void setAddress2(String address2) { - this.address2 = address2; - } - - /** - * Get the name of the credit card company. - * - * @return the creditCardCompany. - */ - public String getCreditCardCompany() { - return creditCardCompany; - } - - /** - * Set the name of the credit card company. - * - * @param creditCardCompany - * the creditCardCompany to set. - */ - public void setCreditCardCompany(String creditCardCompany) { - this.creditCardCompany = creditCardCompany; - } - - /** - * Get the credit card number. - * - * @return the creditCardNumber. - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Set the credit card number. - * - * @param creditCardNumber - * the creditCardNumber to set. - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @return the creditCardExpiryDate. - */ - public String getCreditCardExpiryDate() { - return creditCardExpiryDate; - } - - /** - * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @param creditCardExpiryDate - * the creditCardExpiryDate to set. - */ - public void setCreditCardExpiryDate(String creditCardExpiryDate) { - this.creditCardExpiryDate = creditCardExpiryDate; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (userId ^ (userId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Order other = (Order) obj; - if (id != other.id) { - return false; - } - if (userId != other.userId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java deleted file mode 100644 index f0c01fe9..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/OrderItem.java +++ /dev/null @@ -1,179 +0,0 @@ - -package util; - -/** - * Entity Class for OrderItems (item with quantity in shopping cart or order). - * - * @author Joakim von Kistowski - * - */ -public class OrderItem { - - private long id; - private long productId; - private long orderId; - private int quantity; - private long unitPriceInCents; - - /** - * Create a new and empty OrderItem. - */ - public OrderItem() { - - } - - /** - * Every Entity needs a Copy-Constructor! - * - * @param orderItem - * The entity to Copy. - */ - public OrderItem(OrderItem orderItem) { - setId(orderItem.getId()); - setProductId(orderItem.getProductId()); - setOrderId(orderItem.getOrderId()); - setQuantity(orderItem.getQuantity()); - setUnitPriceInCents(orderItem.getUnitPriceInCents()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * ID of the order item's product. - * - * @return Product Id; - */ - public long getProductId() { - return productId; - } - - /** - * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. - * - * @param productId - * The product ID to set. - */ - public void setProductId(long productId) { - this.productId = productId; - } - - /** - * Get the quantity (amount in shopping cart/order). - * - * @return The quantity. - */ - public int getQuantity() { - return quantity; - } - - /** - * Set the quantity (amount in shopping cart/order). - * - * @param quantity - * The quantity. - */ - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * The price per single item in the order item. - * - * @return Price per single item. - */ - public long getUnitPriceInCents() { - return unitPriceInCents; - } - - /** - * Set the price per single item in the order item. - * - * @param unitPriceInCents - * Price per single item. - */ - public void setUnitPriceInCents(long unitPriceInCents) { - this.unitPriceInCents = unitPriceInCents; - } - - /** - * Gets the ID of the order item's order. - * - * @return The order ID. - */ - public long getOrderId() { - return orderId; - } - - /** - * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For - * persistence the order must already exist in database. - * - * @param orderId - * The order ID to set. - */ - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (orderId ^ (orderId >>> 32)); - result = prime * result + (int) (productId ^ (productId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OrderItem other = (OrderItem) obj; - if (id != other.id) { - return false; - } - if (orderId != other.orderId) { - return false; - } - if (productId != other.productId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java deleted file mode 100644 index 6875efa4..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/SessionBlob.java +++ /dev/null @@ -1,133 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -/** - * Blob containing all information about the user session. - * @author Simon - */ -public class SessionBlob { - - private Long uid; - private String sid; - private String token; - private Order order; - private List orderItems = new LinkedList(); - private String message; - - /** - * Constructor, creates an empty order. - */ - public SessionBlob() { - this.setOrder(new Order()); - } - - /** - * Getter for the userid. - * @return userid - */ - public Long getUID() { - return uid; - } - - /** - * Setter for the userid. - * @param uID userid - */ - public void setUID(Long uID) { - uid = uID; - } - - /** - * Getter for session id. - * @return session id - */ - public String getSID() { - return sid; - } - - /** - * Setter for session id. - * @param sID session id - */ - public void setSID(String sID) { - sid = sID; - } - - /** - * Getter for trust token. - * @return trust token - */ - public String getToken() { - return token; - } - - /** - * Setter for trust token. - * @param token trust token. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Setter for the message. - * @param message String - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Getter for the message. - * @return message - */ - public String getMessage() { - return message; - } - - /** - * Getter for order. - * @return order - */ - public Order getOrder() { - return order; - } - - /** - * Setter for order. - * @param order order - */ - public void setOrder(Order order) { - this.order = order; - } - - /** - * Getter for order items. - * @return order items. - */ - public List getOrderItems() { - return orderItems; - } - - /** - * Setter for order items. - * @param orderItems list of order items - */ - public void setOrderItems(List orderItems) { - this.orderItems = orderItems; - } - - @Override - public String toString() { - return "ClassName{" + - "uid=" + uid + - ", sid='" + sid + '\'' + - ", token='" + token + '\'' + - ", order=" + (order != null ? order.toString() : "null") + - ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java deleted file mode 100644 index d9c88f90..00000000 --- a/benchmarks/600.java/benchmark2/java/src/main/java/util/ShaSecurityProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package util; - -import java.io.UnsupportedEncodingException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. - * - * @author Simon - * - */ -public class ShaSecurityProvider implements ISecurityProvider { - - @Override - public IKeyProvider getKeyProvider() { - return new ConstantKeyProvider(); - } - - @Override - public SessionBlob secure(SessionBlob blob) { - if (blob.getUID() == null || blob.getSID() == null) { - return blob; - } - blob.setToken(null); - String blobString = blobToString(blob); - blob.setToken(getSha512(blobString)); - return blob; - } - - private String blobToString(SessionBlob blob) { - ObjectMapper o = new ObjectMapper(); - try { - return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); - } catch (JsonProcessingException | UnsupportedEncodingException e) - { - throw new IllegalStateException("Could not save blob!"); - } - } - - @Override - public SessionBlob validate(SessionBlob blob) { - if (blob.getToken() == null) { - return null; - } - - String token = blob.getToken(); - blob.setToken(null); - String blobString = blobToString(blob); - String validationToken = getSha512(blobString); - if (validationToken.equals(token)) { - return blob; - } - return null; - } - - private String getSha512(String passwordToHash) { - String generatedPassword = null; - try { - String salt = getKeyProvider().getKey(null); - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(salt.getBytes("UTF-8")); - byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - generatedPassword = sb.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - e.printStackTrace(); - } - return generatedPassword; - } -} diff --git a/benchmarks/600.java/benchmark3/config.json b/benchmarks/600.java/benchmark3/config.json deleted file mode 100644 index 11be1ace..00000000 --- a/benchmarks/600.java/benchmark3/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "timeout": 60, - "memory": 512, - "languages": ["java"] -} - \ No newline at end of file diff --git a/benchmarks/600.java/benchmark3/input.py b/benchmarks/600.java/benchmark3/input.py deleted file mode 100644 index 136f8bc5..00000000 --- a/benchmarks/600.java/benchmark3/input.py +++ /dev/null @@ -1,5 +0,0 @@ -def buckets_count(): - return (0, 0) - -def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): - return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark3/java/pom.xml b/benchmarks/600.java/benchmark3/java/pom.xml deleted file mode 100644 index 37bd1c84..00000000 --- a/benchmarks/600.java/benchmark3/java/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - - faas - benchmark - 1 - - - 8 - 8 - UTF-8 - - - - - - com.google.code.gson - gson - 2.11.0 - - - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.2 - - - commons-io - commons-io - 2.11.0 - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java deleted file mode 100644 index ff55cef8..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/faas/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package faas; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import util.SessionBlob; -import util.ShaSecurityProvider; - -//import jakarta.ws.rs.core.Response; - - -public class App { - public JsonObject handler(JsonObject args) { - Gson gson = new Gson(); - SessionBlob blob = gson.fromJson(args, SessionBlob.class); - - ShaSecurityProvider securityProvider = new ShaSecurityProvider(); - SessionBlob validatedBlob = securityProvider.validate(blob); - - JsonObject jsonResult = new JsonObject(); - if (validatedBlob != null) - jsonResult.addProperty("Authorization-Status", "Authorized"); - else - jsonResult.addProperty("Authorization-Status", "Unauthorized"); - return jsonResult; - } -} - diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java deleted file mode 100644 index ed377e1f..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/ConstantKeyProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - - -/** - * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL - * PRODUCTION WORKLOAD! - * - * @author Joakim von Kistowski - * - */ -public class ConstantKeyProvider implements IKeyProvider { - - /** - * {@inheritDoc} - */ - @Override - public String getKey(SessionBlob blob) { - return "thebestsecretkey"; - } - -} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java deleted file mode 100644 index c78e0dd0..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/IKeyProvider.java +++ /dev/null @@ -1,23 +0,0 @@ - -package util; - -/** - * Provides keys for the security provider. The key provider must ensure that - * keys accross replicated stores are consistent. - * - * @author Joakim von Kistowski - * - */ -public interface IKeyProvider { - - /** - * Returns a key for a session blob. Key must be the same, regardless of the - * store instance upon which this call is made. - * - * @param blob - * The blob to secure. - * @return The key. - */ - public String getKey(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java deleted file mode 100644 index 8d710001..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/ISecurityProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package util; - - -/** - * Utilities for securing (e.g. encrypting) session blobs. - * - * @author Joakim von Kistowski - * - */ -public interface ISecurityProvider { - - /** - * Get the key provider for this security provider. - * - * @return The key provider. - */ - public IKeyProvider getKeyProvider(); - - /** - * Secures a session blob. May encrypt or hash values within the blob. - * - * @param blob - * The blob to secure. - * @return A secure blob to be passed on to the web ui. - */ - public SessionBlob secure(SessionBlob blob); - - /** - * Validates a secured session blob. Returns a valid and readable (e.g. - * decrypted) blob. Returns null for invalid blobs. - * - * @param blob - * The blob to secure. - * @return The valid and readable (e.g. decrypted) blob. Returns null for - * invalid blobs. - */ - public SessionBlob validate(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java deleted file mode 100644 index 95434605..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/Order.java +++ /dev/null @@ -1,281 +0,0 @@ - -package util; - -/** - * Entity for orders. - * - * @author Joakim von Kistowski - * - */ -public class Order { - - private long id; - private long userId; - private String time; - - private long totalPriceInCents; - private String addressName; - private String address1; - private String address2; - - private String creditCardCompany; - private String creditCardNumber; - private String creditCardExpiryDate; - - /** - * Create a new and empty order. - */ - public Order() { - - } - - /** - * Every entity needs a copy constructor. - * - * @param order - * The order to copy. - */ - public Order(Order order) { - setId(order.getId()); - setUserId(order.getUserId()); - setTime(order.getTime()); - setTotalPriceInCents(order.getTotalPriceInCents()); - setAddressName(order.getAddressName()); - setAddress1(order.getAddress1()); - setAddress2(order.getAddress2()); - setCreditCardCompany(order.getCreditCardCompany()); - setCreditCardNumber(order.getCreditCardNumber()); - setCreditCardExpiryDate(order.getCreditCardExpiryDate()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * Get the User id. - * - * @return the userId. - */ - public long getUserId() { - return userId; - } - - /** - * Set the User Id. - * - * @param userId - * the userId to set. - */ - public void setUserId(long userId) { - this.userId = userId; - } - - /** - * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @return the time. - */ - public String getTime() { - return time; - } - - /** - * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @param time - * the time to set. - */ - public void setTime(String time) { - this.time = time; - } - - /** - * Get the total price in cents. - * - * @return the totalPriceInCents. - */ - public long getTotalPriceInCents() { - return totalPriceInCents; - } - - /** - * Set the total price in cents. - * - * @param totalPriceInCents - * the totalPriceInCents to set. - */ - public void setTotalPriceInCents(long totalPriceInCents) { - this.totalPriceInCents = totalPriceInCents; - } - - /** - * Get the name for the address. - * - * @return the addressName. - */ - public String getAddressName() { - return addressName; - } - - /** - * Set the name for the address. - * - * @param addressName - * the addressName to set. - */ - public void setAddressName(String addressName) { - this.addressName = addressName; - } - - /** - * Get address line 1. - * - * @return the address1. - */ - public String getAddress1() { - return address1; - } - - /** - * Set address line 1. - * - * @param address1 - * the address1 to set. - */ - public void setAddress1(String address1) { - this.address1 = address1; - } - - /** - * Get address line 2. - * - * @return the address2. - */ - public String getAddress2() { - return address2; - } - - /** - * Set address line 2. - * - * @param address2 - * the address2 to set. - */ - public void setAddress2(String address2) { - this.address2 = address2; - } - - /** - * Get the name of the credit card company. - * - * @return the creditCardCompany. - */ - public String getCreditCardCompany() { - return creditCardCompany; - } - - /** - * Set the name of the credit card company. - * - * @param creditCardCompany - * the creditCardCompany to set. - */ - public void setCreditCardCompany(String creditCardCompany) { - this.creditCardCompany = creditCardCompany; - } - - /** - * Get the credit card number. - * - * @return the creditCardNumber. - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Set the credit card number. - * - * @param creditCardNumber - * the creditCardNumber to set. - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @return the creditCardExpiryDate. - */ - public String getCreditCardExpiryDate() { - return creditCardExpiryDate; - } - - /** - * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @param creditCardExpiryDate - * the creditCardExpiryDate to set. - */ - public void setCreditCardExpiryDate(String creditCardExpiryDate) { - this.creditCardExpiryDate = creditCardExpiryDate; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (userId ^ (userId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Order other = (Order) obj; - if (id != other.id) { - return false; - } - if (userId != other.userId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java deleted file mode 100644 index f0c01fe9..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/OrderItem.java +++ /dev/null @@ -1,179 +0,0 @@ - -package util; - -/** - * Entity Class for OrderItems (item with quantity in shopping cart or order). - * - * @author Joakim von Kistowski - * - */ -public class OrderItem { - - private long id; - private long productId; - private long orderId; - private int quantity; - private long unitPriceInCents; - - /** - * Create a new and empty OrderItem. - */ - public OrderItem() { - - } - - /** - * Every Entity needs a Copy-Constructor! - * - * @param orderItem - * The entity to Copy. - */ - public OrderItem(OrderItem orderItem) { - setId(orderItem.getId()); - setProductId(orderItem.getProductId()); - setOrderId(orderItem.getOrderId()); - setQuantity(orderItem.getQuantity()); - setUnitPriceInCents(orderItem.getUnitPriceInCents()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * ID of the order item's product. - * - * @return Product Id; - */ - public long getProductId() { - return productId; - } - - /** - * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. - * - * @param productId - * The product ID to set. - */ - public void setProductId(long productId) { - this.productId = productId; - } - - /** - * Get the quantity (amount in shopping cart/order). - * - * @return The quantity. - */ - public int getQuantity() { - return quantity; - } - - /** - * Set the quantity (amount in shopping cart/order). - * - * @param quantity - * The quantity. - */ - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * The price per single item in the order item. - * - * @return Price per single item. - */ - public long getUnitPriceInCents() { - return unitPriceInCents; - } - - /** - * Set the price per single item in the order item. - * - * @param unitPriceInCents - * Price per single item. - */ - public void setUnitPriceInCents(long unitPriceInCents) { - this.unitPriceInCents = unitPriceInCents; - } - - /** - * Gets the ID of the order item's order. - * - * @return The order ID. - */ - public long getOrderId() { - return orderId; - } - - /** - * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For - * persistence the order must already exist in database. - * - * @param orderId - * The order ID to set. - */ - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (orderId ^ (orderId >>> 32)); - result = prime * result + (int) (productId ^ (productId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OrderItem other = (OrderItem) obj; - if (id != other.id) { - return false; - } - if (orderId != other.orderId) { - return false; - } - if (productId != other.productId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java deleted file mode 100644 index 6875efa4..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/SessionBlob.java +++ /dev/null @@ -1,133 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -/** - * Blob containing all information about the user session. - * @author Simon - */ -public class SessionBlob { - - private Long uid; - private String sid; - private String token; - private Order order; - private List orderItems = new LinkedList(); - private String message; - - /** - * Constructor, creates an empty order. - */ - public SessionBlob() { - this.setOrder(new Order()); - } - - /** - * Getter for the userid. - * @return userid - */ - public Long getUID() { - return uid; - } - - /** - * Setter for the userid. - * @param uID userid - */ - public void setUID(Long uID) { - uid = uID; - } - - /** - * Getter for session id. - * @return session id - */ - public String getSID() { - return sid; - } - - /** - * Setter for session id. - * @param sID session id - */ - public void setSID(String sID) { - sid = sID; - } - - /** - * Getter for trust token. - * @return trust token - */ - public String getToken() { - return token; - } - - /** - * Setter for trust token. - * @param token trust token. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Setter for the message. - * @param message String - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Getter for the message. - * @return message - */ - public String getMessage() { - return message; - } - - /** - * Getter for order. - * @return order - */ - public Order getOrder() { - return order; - } - - /** - * Setter for order. - * @param order order - */ - public void setOrder(Order order) { - this.order = order; - } - - /** - * Getter for order items. - * @return order items. - */ - public List getOrderItems() { - return orderItems; - } - - /** - * Setter for order items. - * @param orderItems list of order items - */ - public void setOrderItems(List orderItems) { - this.orderItems = orderItems; - } - - @Override - public String toString() { - return "ClassName{" + - "uid=" + uid + - ", sid='" + sid + '\'' + - ", token='" + token + '\'' + - ", order=" + (order != null ? order.toString() : "null") + - ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java deleted file mode 100644 index d9c88f90..00000000 --- a/benchmarks/600.java/benchmark3/java/src/main/java/util/ShaSecurityProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package util; - -import java.io.UnsupportedEncodingException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. - * - * @author Simon - * - */ -public class ShaSecurityProvider implements ISecurityProvider { - - @Override - public IKeyProvider getKeyProvider() { - return new ConstantKeyProvider(); - } - - @Override - public SessionBlob secure(SessionBlob blob) { - if (blob.getUID() == null || blob.getSID() == null) { - return blob; - } - blob.setToken(null); - String blobString = blobToString(blob); - blob.setToken(getSha512(blobString)); - return blob; - } - - private String blobToString(SessionBlob blob) { - ObjectMapper o = new ObjectMapper(); - try { - return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); - } catch (JsonProcessingException | UnsupportedEncodingException e) - { - throw new IllegalStateException("Could not save blob!"); - } - } - - @Override - public SessionBlob validate(SessionBlob blob) { - if (blob.getToken() == null) { - return null; - } - - String token = blob.getToken(); - blob.setToken(null); - String blobString = blobToString(blob); - String validationToken = getSha512(blobString); - if (validationToken.equals(token)) { - return blob; - } - return null; - } - - private String getSha512(String passwordToHash) { - String generatedPassword = null; - try { - String salt = getKeyProvider().getKey(null); - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(salt.getBytes("UTF-8")); - byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - generatedPassword = sb.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - e.printStackTrace(); - } - return generatedPassword; - } -} diff --git a/benchmarks/600.java/benchmark4/config.json b/benchmarks/600.java/benchmark4/config.json deleted file mode 100644 index 11be1ace..00000000 --- a/benchmarks/600.java/benchmark4/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "timeout": 60, - "memory": 512, - "languages": ["java"] -} - \ No newline at end of file diff --git a/benchmarks/600.java/benchmark4/input.py b/benchmarks/600.java/benchmark4/input.py deleted file mode 100644 index 136f8bc5..00000000 --- a/benchmarks/600.java/benchmark4/input.py +++ /dev/null @@ -1,5 +0,0 @@ -def buckets_count(): - return (0, 0) - -def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): - return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark4/java/pom.xml b/benchmarks/600.java/benchmark4/java/pom.xml deleted file mode 100644 index dacfe9bf..00000000 --- a/benchmarks/600.java/benchmark4/java/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - - faas - benchmark - 1 - - - 8 - 8 - UTF-8 - - - - - - com.google.code.gson - gson - 2.11.0 - - - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.2 - - - org.apache.poi - poi-ooxml - 5.2.3 - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java deleted file mode 100644 index ff55cef8..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/faas/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package faas; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import util.SessionBlob; -import util.ShaSecurityProvider; - -//import jakarta.ws.rs.core.Response; - - -public class App { - public JsonObject handler(JsonObject args) { - Gson gson = new Gson(); - SessionBlob blob = gson.fromJson(args, SessionBlob.class); - - ShaSecurityProvider securityProvider = new ShaSecurityProvider(); - SessionBlob validatedBlob = securityProvider.validate(blob); - - JsonObject jsonResult = new JsonObject(); - if (validatedBlob != null) - jsonResult.addProperty("Authorization-Status", "Authorized"); - else - jsonResult.addProperty("Authorization-Status", "Unauthorized"); - return jsonResult; - } -} - diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java deleted file mode 100644 index ed377e1f..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/ConstantKeyProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - - -/** - * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL - * PRODUCTION WORKLOAD! - * - * @author Joakim von Kistowski - * - */ -public class ConstantKeyProvider implements IKeyProvider { - - /** - * {@inheritDoc} - */ - @Override - public String getKey(SessionBlob blob) { - return "thebestsecretkey"; - } - -} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java deleted file mode 100644 index c78e0dd0..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/IKeyProvider.java +++ /dev/null @@ -1,23 +0,0 @@ - -package util; - -/** - * Provides keys for the security provider. The key provider must ensure that - * keys accross replicated stores are consistent. - * - * @author Joakim von Kistowski - * - */ -public interface IKeyProvider { - - /** - * Returns a key for a session blob. Key must be the same, regardless of the - * store instance upon which this call is made. - * - * @param blob - * The blob to secure. - * @return The key. - */ - public String getKey(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java deleted file mode 100644 index 8d710001..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/ISecurityProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package util; - - -/** - * Utilities for securing (e.g. encrypting) session blobs. - * - * @author Joakim von Kistowski - * - */ -public interface ISecurityProvider { - - /** - * Get the key provider for this security provider. - * - * @return The key provider. - */ - public IKeyProvider getKeyProvider(); - - /** - * Secures a session blob. May encrypt or hash values within the blob. - * - * @param blob - * The blob to secure. - * @return A secure blob to be passed on to the web ui. - */ - public SessionBlob secure(SessionBlob blob); - - /** - * Validates a secured session blob. Returns a valid and readable (e.g. - * decrypted) blob. Returns null for invalid blobs. - * - * @param blob - * The blob to secure. - * @return The valid and readable (e.g. decrypted) blob. Returns null for - * invalid blobs. - */ - public SessionBlob validate(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java deleted file mode 100644 index 95434605..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/Order.java +++ /dev/null @@ -1,281 +0,0 @@ - -package util; - -/** - * Entity for orders. - * - * @author Joakim von Kistowski - * - */ -public class Order { - - private long id; - private long userId; - private String time; - - private long totalPriceInCents; - private String addressName; - private String address1; - private String address2; - - private String creditCardCompany; - private String creditCardNumber; - private String creditCardExpiryDate; - - /** - * Create a new and empty order. - */ - public Order() { - - } - - /** - * Every entity needs a copy constructor. - * - * @param order - * The order to copy. - */ - public Order(Order order) { - setId(order.getId()); - setUserId(order.getUserId()); - setTime(order.getTime()); - setTotalPriceInCents(order.getTotalPriceInCents()); - setAddressName(order.getAddressName()); - setAddress1(order.getAddress1()); - setAddress2(order.getAddress2()); - setCreditCardCompany(order.getCreditCardCompany()); - setCreditCardNumber(order.getCreditCardNumber()); - setCreditCardExpiryDate(order.getCreditCardExpiryDate()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * Get the User id. - * - * @return the userId. - */ - public long getUserId() { - return userId; - } - - /** - * Set the User Id. - * - * @param userId - * the userId to set. - */ - public void setUserId(long userId) { - this.userId = userId; - } - - /** - * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @return the time. - */ - public String getTime() { - return time; - } - - /** - * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @param time - * the time to set. - */ - public void setTime(String time) { - this.time = time; - } - - /** - * Get the total price in cents. - * - * @return the totalPriceInCents. - */ - public long getTotalPriceInCents() { - return totalPriceInCents; - } - - /** - * Set the total price in cents. - * - * @param totalPriceInCents - * the totalPriceInCents to set. - */ - public void setTotalPriceInCents(long totalPriceInCents) { - this.totalPriceInCents = totalPriceInCents; - } - - /** - * Get the name for the address. - * - * @return the addressName. - */ - public String getAddressName() { - return addressName; - } - - /** - * Set the name for the address. - * - * @param addressName - * the addressName to set. - */ - public void setAddressName(String addressName) { - this.addressName = addressName; - } - - /** - * Get address line 1. - * - * @return the address1. - */ - public String getAddress1() { - return address1; - } - - /** - * Set address line 1. - * - * @param address1 - * the address1 to set. - */ - public void setAddress1(String address1) { - this.address1 = address1; - } - - /** - * Get address line 2. - * - * @return the address2. - */ - public String getAddress2() { - return address2; - } - - /** - * Set address line 2. - * - * @param address2 - * the address2 to set. - */ - public void setAddress2(String address2) { - this.address2 = address2; - } - - /** - * Get the name of the credit card company. - * - * @return the creditCardCompany. - */ - public String getCreditCardCompany() { - return creditCardCompany; - } - - /** - * Set the name of the credit card company. - * - * @param creditCardCompany - * the creditCardCompany to set. - */ - public void setCreditCardCompany(String creditCardCompany) { - this.creditCardCompany = creditCardCompany; - } - - /** - * Get the credit card number. - * - * @return the creditCardNumber. - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Set the credit card number. - * - * @param creditCardNumber - * the creditCardNumber to set. - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @return the creditCardExpiryDate. - */ - public String getCreditCardExpiryDate() { - return creditCardExpiryDate; - } - - /** - * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @param creditCardExpiryDate - * the creditCardExpiryDate to set. - */ - public void setCreditCardExpiryDate(String creditCardExpiryDate) { - this.creditCardExpiryDate = creditCardExpiryDate; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (userId ^ (userId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Order other = (Order) obj; - if (id != other.id) { - return false; - } - if (userId != other.userId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java deleted file mode 100644 index f0c01fe9..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/OrderItem.java +++ /dev/null @@ -1,179 +0,0 @@ - -package util; - -/** - * Entity Class for OrderItems (item with quantity in shopping cart or order). - * - * @author Joakim von Kistowski - * - */ -public class OrderItem { - - private long id; - private long productId; - private long orderId; - private int quantity; - private long unitPriceInCents; - - /** - * Create a new and empty OrderItem. - */ - public OrderItem() { - - } - - /** - * Every Entity needs a Copy-Constructor! - * - * @param orderItem - * The entity to Copy. - */ - public OrderItem(OrderItem orderItem) { - setId(orderItem.getId()); - setProductId(orderItem.getProductId()); - setOrderId(orderItem.getOrderId()); - setQuantity(orderItem.getQuantity()); - setUnitPriceInCents(orderItem.getUnitPriceInCents()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * ID of the order item's product. - * - * @return Product Id; - */ - public long getProductId() { - return productId; - } - - /** - * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. - * - * @param productId - * The product ID to set. - */ - public void setProductId(long productId) { - this.productId = productId; - } - - /** - * Get the quantity (amount in shopping cart/order). - * - * @return The quantity. - */ - public int getQuantity() { - return quantity; - } - - /** - * Set the quantity (amount in shopping cart/order). - * - * @param quantity - * The quantity. - */ - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * The price per single item in the order item. - * - * @return Price per single item. - */ - public long getUnitPriceInCents() { - return unitPriceInCents; - } - - /** - * Set the price per single item in the order item. - * - * @param unitPriceInCents - * Price per single item. - */ - public void setUnitPriceInCents(long unitPriceInCents) { - this.unitPriceInCents = unitPriceInCents; - } - - /** - * Gets the ID of the order item's order. - * - * @return The order ID. - */ - public long getOrderId() { - return orderId; - } - - /** - * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For - * persistence the order must already exist in database. - * - * @param orderId - * The order ID to set. - */ - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (orderId ^ (orderId >>> 32)); - result = prime * result + (int) (productId ^ (productId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OrderItem other = (OrderItem) obj; - if (id != other.id) { - return false; - } - if (orderId != other.orderId) { - return false; - } - if (productId != other.productId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java deleted file mode 100644 index 6875efa4..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/SessionBlob.java +++ /dev/null @@ -1,133 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -/** - * Blob containing all information about the user session. - * @author Simon - */ -public class SessionBlob { - - private Long uid; - private String sid; - private String token; - private Order order; - private List orderItems = new LinkedList(); - private String message; - - /** - * Constructor, creates an empty order. - */ - public SessionBlob() { - this.setOrder(new Order()); - } - - /** - * Getter for the userid. - * @return userid - */ - public Long getUID() { - return uid; - } - - /** - * Setter for the userid. - * @param uID userid - */ - public void setUID(Long uID) { - uid = uID; - } - - /** - * Getter for session id. - * @return session id - */ - public String getSID() { - return sid; - } - - /** - * Setter for session id. - * @param sID session id - */ - public void setSID(String sID) { - sid = sID; - } - - /** - * Getter for trust token. - * @return trust token - */ - public String getToken() { - return token; - } - - /** - * Setter for trust token. - * @param token trust token. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Setter for the message. - * @param message String - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Getter for the message. - * @return message - */ - public String getMessage() { - return message; - } - - /** - * Getter for order. - * @return order - */ - public Order getOrder() { - return order; - } - - /** - * Setter for order. - * @param order order - */ - public void setOrder(Order order) { - this.order = order; - } - - /** - * Getter for order items. - * @return order items. - */ - public List getOrderItems() { - return orderItems; - } - - /** - * Setter for order items. - * @param orderItems list of order items - */ - public void setOrderItems(List orderItems) { - this.orderItems = orderItems; - } - - @Override - public String toString() { - return "ClassName{" + - "uid=" + uid + - ", sid='" + sid + '\'' + - ", token='" + token + '\'' + - ", order=" + (order != null ? order.toString() : "null") + - ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java deleted file mode 100644 index d9c88f90..00000000 --- a/benchmarks/600.java/benchmark4/java/src/main/java/util/ShaSecurityProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package util; - -import java.io.UnsupportedEncodingException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. - * - * @author Simon - * - */ -public class ShaSecurityProvider implements ISecurityProvider { - - @Override - public IKeyProvider getKeyProvider() { - return new ConstantKeyProvider(); - } - - @Override - public SessionBlob secure(SessionBlob blob) { - if (blob.getUID() == null || blob.getSID() == null) { - return blob; - } - blob.setToken(null); - String blobString = blobToString(blob); - blob.setToken(getSha512(blobString)); - return blob; - } - - private String blobToString(SessionBlob blob) { - ObjectMapper o = new ObjectMapper(); - try { - return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); - } catch (JsonProcessingException | UnsupportedEncodingException e) - { - throw new IllegalStateException("Could not save blob!"); - } - } - - @Override - public SessionBlob validate(SessionBlob blob) { - if (blob.getToken() == null) { - return null; - } - - String token = blob.getToken(); - blob.setToken(null); - String blobString = blobToString(blob); - String validationToken = getSha512(blobString); - if (validationToken.equals(token)) { - return blob; - } - return null; - } - - private String getSha512(String passwordToHash) { - String generatedPassword = null; - try { - String salt = getKeyProvider().getKey(null); - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(salt.getBytes("UTF-8")); - byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - generatedPassword = sb.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - e.printStackTrace(); - } - return generatedPassword; - } -} diff --git a/benchmarks/600.java/benchmark5/config.json b/benchmarks/600.java/benchmark5/config.json deleted file mode 100644 index 11be1ace..00000000 --- a/benchmarks/600.java/benchmark5/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "timeout": 60, - "memory": 512, - "languages": ["java"] -} - \ No newline at end of file diff --git a/benchmarks/600.java/benchmark5/input.py b/benchmarks/600.java/benchmark5/input.py deleted file mode 100644 index 136f8bc5..00000000 --- a/benchmarks/600.java/benchmark5/input.py +++ /dev/null @@ -1,5 +0,0 @@ -def buckets_count(): - return (0, 0) - -def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): - return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark5/java/pom.xml b/benchmarks/600.java/benchmark5/java/pom.xml deleted file mode 100644 index 32025ca0..00000000 --- a/benchmarks/600.java/benchmark5/java/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - - faas - benchmark - 1 - - - 8 - 8 - UTF-8 - - - - - - com.google.code.gson - gson - 2.11.0 - - - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.2 - - - io.netty - netty-all - 4.1.65.Final - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java deleted file mode 100644 index ff55cef8..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/faas/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package faas; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import util.SessionBlob; -import util.ShaSecurityProvider; - -//import jakarta.ws.rs.core.Response; - - -public class App { - public JsonObject handler(JsonObject args) { - Gson gson = new Gson(); - SessionBlob blob = gson.fromJson(args, SessionBlob.class); - - ShaSecurityProvider securityProvider = new ShaSecurityProvider(); - SessionBlob validatedBlob = securityProvider.validate(blob); - - JsonObject jsonResult = new JsonObject(); - if (validatedBlob != null) - jsonResult.addProperty("Authorization-Status", "Authorized"); - else - jsonResult.addProperty("Authorization-Status", "Unauthorized"); - return jsonResult; - } -} - diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java deleted file mode 100644 index ed377e1f..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/ConstantKeyProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - - -/** - * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL - * PRODUCTION WORKLOAD! - * - * @author Joakim von Kistowski - * - */ -public class ConstantKeyProvider implements IKeyProvider { - - /** - * {@inheritDoc} - */ - @Override - public String getKey(SessionBlob blob) { - return "thebestsecretkey"; - } - -} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java deleted file mode 100644 index c78e0dd0..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/IKeyProvider.java +++ /dev/null @@ -1,23 +0,0 @@ - -package util; - -/** - * Provides keys for the security provider. The key provider must ensure that - * keys accross replicated stores are consistent. - * - * @author Joakim von Kistowski - * - */ -public interface IKeyProvider { - - /** - * Returns a key for a session blob. Key must be the same, regardless of the - * store instance upon which this call is made. - * - * @param blob - * The blob to secure. - * @return The key. - */ - public String getKey(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java deleted file mode 100644 index 8d710001..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/ISecurityProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package util; - - -/** - * Utilities for securing (e.g. encrypting) session blobs. - * - * @author Joakim von Kistowski - * - */ -public interface ISecurityProvider { - - /** - * Get the key provider for this security provider. - * - * @return The key provider. - */ - public IKeyProvider getKeyProvider(); - - /** - * Secures a session blob. May encrypt or hash values within the blob. - * - * @param blob - * The blob to secure. - * @return A secure blob to be passed on to the web ui. - */ - public SessionBlob secure(SessionBlob blob); - - /** - * Validates a secured session blob. Returns a valid and readable (e.g. - * decrypted) blob. Returns null for invalid blobs. - * - * @param blob - * The blob to secure. - * @return The valid and readable (e.g. decrypted) blob. Returns null for - * invalid blobs. - */ - public SessionBlob validate(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java deleted file mode 100644 index 95434605..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/Order.java +++ /dev/null @@ -1,281 +0,0 @@ - -package util; - -/** - * Entity for orders. - * - * @author Joakim von Kistowski - * - */ -public class Order { - - private long id; - private long userId; - private String time; - - private long totalPriceInCents; - private String addressName; - private String address1; - private String address2; - - private String creditCardCompany; - private String creditCardNumber; - private String creditCardExpiryDate; - - /** - * Create a new and empty order. - */ - public Order() { - - } - - /** - * Every entity needs a copy constructor. - * - * @param order - * The order to copy. - */ - public Order(Order order) { - setId(order.getId()); - setUserId(order.getUserId()); - setTime(order.getTime()); - setTotalPriceInCents(order.getTotalPriceInCents()); - setAddressName(order.getAddressName()); - setAddress1(order.getAddress1()); - setAddress2(order.getAddress2()); - setCreditCardCompany(order.getCreditCardCompany()); - setCreditCardNumber(order.getCreditCardNumber()); - setCreditCardExpiryDate(order.getCreditCardExpiryDate()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * Get the User id. - * - * @return the userId. - */ - public long getUserId() { - return userId; - } - - /** - * Set the User Id. - * - * @param userId - * the userId to set. - */ - public void setUserId(long userId) { - this.userId = userId; - } - - /** - * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @return the time. - */ - public String getTime() { - return time; - } - - /** - * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @param time - * the time to set. - */ - public void setTime(String time) { - this.time = time; - } - - /** - * Get the total price in cents. - * - * @return the totalPriceInCents. - */ - public long getTotalPriceInCents() { - return totalPriceInCents; - } - - /** - * Set the total price in cents. - * - * @param totalPriceInCents - * the totalPriceInCents to set. - */ - public void setTotalPriceInCents(long totalPriceInCents) { - this.totalPriceInCents = totalPriceInCents; - } - - /** - * Get the name for the address. - * - * @return the addressName. - */ - public String getAddressName() { - return addressName; - } - - /** - * Set the name for the address. - * - * @param addressName - * the addressName to set. - */ - public void setAddressName(String addressName) { - this.addressName = addressName; - } - - /** - * Get address line 1. - * - * @return the address1. - */ - public String getAddress1() { - return address1; - } - - /** - * Set address line 1. - * - * @param address1 - * the address1 to set. - */ - public void setAddress1(String address1) { - this.address1 = address1; - } - - /** - * Get address line 2. - * - * @return the address2. - */ - public String getAddress2() { - return address2; - } - - /** - * Set address line 2. - * - * @param address2 - * the address2 to set. - */ - public void setAddress2(String address2) { - this.address2 = address2; - } - - /** - * Get the name of the credit card company. - * - * @return the creditCardCompany. - */ - public String getCreditCardCompany() { - return creditCardCompany; - } - - /** - * Set the name of the credit card company. - * - * @param creditCardCompany - * the creditCardCompany to set. - */ - public void setCreditCardCompany(String creditCardCompany) { - this.creditCardCompany = creditCardCompany; - } - - /** - * Get the credit card number. - * - * @return the creditCardNumber. - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Set the credit card number. - * - * @param creditCardNumber - * the creditCardNumber to set. - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @return the creditCardExpiryDate. - */ - public String getCreditCardExpiryDate() { - return creditCardExpiryDate; - } - - /** - * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @param creditCardExpiryDate - * the creditCardExpiryDate to set. - */ - public void setCreditCardExpiryDate(String creditCardExpiryDate) { - this.creditCardExpiryDate = creditCardExpiryDate; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (userId ^ (userId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Order other = (Order) obj; - if (id != other.id) { - return false; - } - if (userId != other.userId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java deleted file mode 100644 index f0c01fe9..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/OrderItem.java +++ /dev/null @@ -1,179 +0,0 @@ - -package util; - -/** - * Entity Class for OrderItems (item with quantity in shopping cart or order). - * - * @author Joakim von Kistowski - * - */ -public class OrderItem { - - private long id; - private long productId; - private long orderId; - private int quantity; - private long unitPriceInCents; - - /** - * Create a new and empty OrderItem. - */ - public OrderItem() { - - } - - /** - * Every Entity needs a Copy-Constructor! - * - * @param orderItem - * The entity to Copy. - */ - public OrderItem(OrderItem orderItem) { - setId(orderItem.getId()); - setProductId(orderItem.getProductId()); - setOrderId(orderItem.getOrderId()); - setQuantity(orderItem.getQuantity()); - setUnitPriceInCents(orderItem.getUnitPriceInCents()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * ID of the order item's product. - * - * @return Product Id; - */ - public long getProductId() { - return productId; - } - - /** - * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. - * - * @param productId - * The product ID to set. - */ - public void setProductId(long productId) { - this.productId = productId; - } - - /** - * Get the quantity (amount in shopping cart/order). - * - * @return The quantity. - */ - public int getQuantity() { - return quantity; - } - - /** - * Set the quantity (amount in shopping cart/order). - * - * @param quantity - * The quantity. - */ - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * The price per single item in the order item. - * - * @return Price per single item. - */ - public long getUnitPriceInCents() { - return unitPriceInCents; - } - - /** - * Set the price per single item in the order item. - * - * @param unitPriceInCents - * Price per single item. - */ - public void setUnitPriceInCents(long unitPriceInCents) { - this.unitPriceInCents = unitPriceInCents; - } - - /** - * Gets the ID of the order item's order. - * - * @return The order ID. - */ - public long getOrderId() { - return orderId; - } - - /** - * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For - * persistence the order must already exist in database. - * - * @param orderId - * The order ID to set. - */ - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (orderId ^ (orderId >>> 32)); - result = prime * result + (int) (productId ^ (productId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OrderItem other = (OrderItem) obj; - if (id != other.id) { - return false; - } - if (orderId != other.orderId) { - return false; - } - if (productId != other.productId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java deleted file mode 100644 index 6875efa4..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/SessionBlob.java +++ /dev/null @@ -1,133 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -/** - * Blob containing all information about the user session. - * @author Simon - */ -public class SessionBlob { - - private Long uid; - private String sid; - private String token; - private Order order; - private List orderItems = new LinkedList(); - private String message; - - /** - * Constructor, creates an empty order. - */ - public SessionBlob() { - this.setOrder(new Order()); - } - - /** - * Getter for the userid. - * @return userid - */ - public Long getUID() { - return uid; - } - - /** - * Setter for the userid. - * @param uID userid - */ - public void setUID(Long uID) { - uid = uID; - } - - /** - * Getter for session id. - * @return session id - */ - public String getSID() { - return sid; - } - - /** - * Setter for session id. - * @param sID session id - */ - public void setSID(String sID) { - sid = sID; - } - - /** - * Getter for trust token. - * @return trust token - */ - public String getToken() { - return token; - } - - /** - * Setter for trust token. - * @param token trust token. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Setter for the message. - * @param message String - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Getter for the message. - * @return message - */ - public String getMessage() { - return message; - } - - /** - * Getter for order. - * @return order - */ - public Order getOrder() { - return order; - } - - /** - * Setter for order. - * @param order order - */ - public void setOrder(Order order) { - this.order = order; - } - - /** - * Getter for order items. - * @return order items. - */ - public List getOrderItems() { - return orderItems; - } - - /** - * Setter for order items. - * @param orderItems list of order items - */ - public void setOrderItems(List orderItems) { - this.orderItems = orderItems; - } - - @Override - public String toString() { - return "ClassName{" + - "uid=" + uid + - ", sid='" + sid + '\'' + - ", token='" + token + '\'' + - ", order=" + (order != null ? order.toString() : "null") + - ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java deleted file mode 100644 index d9c88f90..00000000 --- a/benchmarks/600.java/benchmark5/java/src/main/java/util/ShaSecurityProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package util; - -import java.io.UnsupportedEncodingException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. - * - * @author Simon - * - */ -public class ShaSecurityProvider implements ISecurityProvider { - - @Override - public IKeyProvider getKeyProvider() { - return new ConstantKeyProvider(); - } - - @Override - public SessionBlob secure(SessionBlob blob) { - if (blob.getUID() == null || blob.getSID() == null) { - return blob; - } - blob.setToken(null); - String blobString = blobToString(blob); - blob.setToken(getSha512(blobString)); - return blob; - } - - private String blobToString(SessionBlob blob) { - ObjectMapper o = new ObjectMapper(); - try { - return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); - } catch (JsonProcessingException | UnsupportedEncodingException e) - { - throw new IllegalStateException("Could not save blob!"); - } - } - - @Override - public SessionBlob validate(SessionBlob blob) { - if (blob.getToken() == null) { - return null; - } - - String token = blob.getToken(); - blob.setToken(null); - String blobString = blobToString(blob); - String validationToken = getSha512(blobString); - if (validationToken.equals(token)) { - return blob; - } - return null; - } - - private String getSha512(String passwordToHash) { - String generatedPassword = null; - try { - String salt = getKeyProvider().getKey(null); - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(salt.getBytes("UTF-8")); - byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - generatedPassword = sb.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - e.printStackTrace(); - } - return generatedPassword; - } -} diff --git a/benchmarks/600.java/benchmark6/config.json b/benchmarks/600.java/benchmark6/config.json deleted file mode 100644 index 11be1ace..00000000 --- a/benchmarks/600.java/benchmark6/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "timeout": 60, - "memory": 512, - "languages": ["java"] -} - \ No newline at end of file diff --git a/benchmarks/600.java/benchmark6/input.py b/benchmarks/600.java/benchmark6/input.py deleted file mode 100644 index 136f8bc5..00000000 --- a/benchmarks/600.java/benchmark6/input.py +++ /dev/null @@ -1,5 +0,0 @@ -def buckets_count(): - return (0, 0) - -def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): - return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark6/java/pom.xml b/benchmarks/600.java/benchmark6/java/pom.xml deleted file mode 100644 index e159f1f8..00000000 --- a/benchmarks/600.java/benchmark6/java/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - - faas - benchmark - 1 - - - 8 - 8 - UTF-8 - - - - - - com.google.code.gson - gson - 2.11.0 - - - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.2 - - - io.netty - netty-all - 4.1.65.Final - - - org.apache.pdfbox - pdfbox - 2.0.24 - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java deleted file mode 100644 index ff55cef8..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/faas/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package faas; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import util.SessionBlob; -import util.ShaSecurityProvider; - -//import jakarta.ws.rs.core.Response; - - -public class App { - public JsonObject handler(JsonObject args) { - Gson gson = new Gson(); - SessionBlob blob = gson.fromJson(args, SessionBlob.class); - - ShaSecurityProvider securityProvider = new ShaSecurityProvider(); - SessionBlob validatedBlob = securityProvider.validate(blob); - - JsonObject jsonResult = new JsonObject(); - if (validatedBlob != null) - jsonResult.addProperty("Authorization-Status", "Authorized"); - else - jsonResult.addProperty("Authorization-Status", "Unauthorized"); - return jsonResult; - } -} - diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java deleted file mode 100644 index ed377e1f..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/ConstantKeyProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - - -/** - * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL - * PRODUCTION WORKLOAD! - * - * @author Joakim von Kistowski - * - */ -public class ConstantKeyProvider implements IKeyProvider { - - /** - * {@inheritDoc} - */ - @Override - public String getKey(SessionBlob blob) { - return "thebestsecretkey"; - } - -} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java deleted file mode 100644 index c78e0dd0..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/IKeyProvider.java +++ /dev/null @@ -1,23 +0,0 @@ - -package util; - -/** - * Provides keys for the security provider. The key provider must ensure that - * keys accross replicated stores are consistent. - * - * @author Joakim von Kistowski - * - */ -public interface IKeyProvider { - - /** - * Returns a key for a session blob. Key must be the same, regardless of the - * store instance upon which this call is made. - * - * @param blob - * The blob to secure. - * @return The key. - */ - public String getKey(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java deleted file mode 100644 index 8d710001..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/ISecurityProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package util; - - -/** - * Utilities for securing (e.g. encrypting) session blobs. - * - * @author Joakim von Kistowski - * - */ -public interface ISecurityProvider { - - /** - * Get the key provider for this security provider. - * - * @return The key provider. - */ - public IKeyProvider getKeyProvider(); - - /** - * Secures a session blob. May encrypt or hash values within the blob. - * - * @param blob - * The blob to secure. - * @return A secure blob to be passed on to the web ui. - */ - public SessionBlob secure(SessionBlob blob); - - /** - * Validates a secured session blob. Returns a valid and readable (e.g. - * decrypted) blob. Returns null for invalid blobs. - * - * @param blob - * The blob to secure. - * @return The valid and readable (e.g. decrypted) blob. Returns null for - * invalid blobs. - */ - public SessionBlob validate(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java deleted file mode 100644 index 95434605..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/Order.java +++ /dev/null @@ -1,281 +0,0 @@ - -package util; - -/** - * Entity for orders. - * - * @author Joakim von Kistowski - * - */ -public class Order { - - private long id; - private long userId; - private String time; - - private long totalPriceInCents; - private String addressName; - private String address1; - private String address2; - - private String creditCardCompany; - private String creditCardNumber; - private String creditCardExpiryDate; - - /** - * Create a new and empty order. - */ - public Order() { - - } - - /** - * Every entity needs a copy constructor. - * - * @param order - * The order to copy. - */ - public Order(Order order) { - setId(order.getId()); - setUserId(order.getUserId()); - setTime(order.getTime()); - setTotalPriceInCents(order.getTotalPriceInCents()); - setAddressName(order.getAddressName()); - setAddress1(order.getAddress1()); - setAddress2(order.getAddress2()); - setCreditCardCompany(order.getCreditCardCompany()); - setCreditCardNumber(order.getCreditCardNumber()); - setCreditCardExpiryDate(order.getCreditCardExpiryDate()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * Get the User id. - * - * @return the userId. - */ - public long getUserId() { - return userId; - } - - /** - * Set the User Id. - * - * @param userId - * the userId to set. - */ - public void setUserId(long userId) { - this.userId = userId; - } - - /** - * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @return the time. - */ - public String getTime() { - return time; - } - - /** - * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @param time - * the time to set. - */ - public void setTime(String time) { - this.time = time; - } - - /** - * Get the total price in cents. - * - * @return the totalPriceInCents. - */ - public long getTotalPriceInCents() { - return totalPriceInCents; - } - - /** - * Set the total price in cents. - * - * @param totalPriceInCents - * the totalPriceInCents to set. - */ - public void setTotalPriceInCents(long totalPriceInCents) { - this.totalPriceInCents = totalPriceInCents; - } - - /** - * Get the name for the address. - * - * @return the addressName. - */ - public String getAddressName() { - return addressName; - } - - /** - * Set the name for the address. - * - * @param addressName - * the addressName to set. - */ - public void setAddressName(String addressName) { - this.addressName = addressName; - } - - /** - * Get address line 1. - * - * @return the address1. - */ - public String getAddress1() { - return address1; - } - - /** - * Set address line 1. - * - * @param address1 - * the address1 to set. - */ - public void setAddress1(String address1) { - this.address1 = address1; - } - - /** - * Get address line 2. - * - * @return the address2. - */ - public String getAddress2() { - return address2; - } - - /** - * Set address line 2. - * - * @param address2 - * the address2 to set. - */ - public void setAddress2(String address2) { - this.address2 = address2; - } - - /** - * Get the name of the credit card company. - * - * @return the creditCardCompany. - */ - public String getCreditCardCompany() { - return creditCardCompany; - } - - /** - * Set the name of the credit card company. - * - * @param creditCardCompany - * the creditCardCompany to set. - */ - public void setCreditCardCompany(String creditCardCompany) { - this.creditCardCompany = creditCardCompany; - } - - /** - * Get the credit card number. - * - * @return the creditCardNumber. - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Set the credit card number. - * - * @param creditCardNumber - * the creditCardNumber to set. - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @return the creditCardExpiryDate. - */ - public String getCreditCardExpiryDate() { - return creditCardExpiryDate; - } - - /** - * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @param creditCardExpiryDate - * the creditCardExpiryDate to set. - */ - public void setCreditCardExpiryDate(String creditCardExpiryDate) { - this.creditCardExpiryDate = creditCardExpiryDate; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (userId ^ (userId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Order other = (Order) obj; - if (id != other.id) { - return false; - } - if (userId != other.userId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java deleted file mode 100644 index f0c01fe9..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/OrderItem.java +++ /dev/null @@ -1,179 +0,0 @@ - -package util; - -/** - * Entity Class for OrderItems (item with quantity in shopping cart or order). - * - * @author Joakim von Kistowski - * - */ -public class OrderItem { - - private long id; - private long productId; - private long orderId; - private int quantity; - private long unitPriceInCents; - - /** - * Create a new and empty OrderItem. - */ - public OrderItem() { - - } - - /** - * Every Entity needs a Copy-Constructor! - * - * @param orderItem - * The entity to Copy. - */ - public OrderItem(OrderItem orderItem) { - setId(orderItem.getId()); - setProductId(orderItem.getProductId()); - setOrderId(orderItem.getOrderId()); - setQuantity(orderItem.getQuantity()); - setUnitPriceInCents(orderItem.getUnitPriceInCents()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * ID of the order item's product. - * - * @return Product Id; - */ - public long getProductId() { - return productId; - } - - /** - * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. - * - * @param productId - * The product ID to set. - */ - public void setProductId(long productId) { - this.productId = productId; - } - - /** - * Get the quantity (amount in shopping cart/order). - * - * @return The quantity. - */ - public int getQuantity() { - return quantity; - } - - /** - * Set the quantity (amount in shopping cart/order). - * - * @param quantity - * The quantity. - */ - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * The price per single item in the order item. - * - * @return Price per single item. - */ - public long getUnitPriceInCents() { - return unitPriceInCents; - } - - /** - * Set the price per single item in the order item. - * - * @param unitPriceInCents - * Price per single item. - */ - public void setUnitPriceInCents(long unitPriceInCents) { - this.unitPriceInCents = unitPriceInCents; - } - - /** - * Gets the ID of the order item's order. - * - * @return The order ID. - */ - public long getOrderId() { - return orderId; - } - - /** - * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For - * persistence the order must already exist in database. - * - * @param orderId - * The order ID to set. - */ - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (orderId ^ (orderId >>> 32)); - result = prime * result + (int) (productId ^ (productId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OrderItem other = (OrderItem) obj; - if (id != other.id) { - return false; - } - if (orderId != other.orderId) { - return false; - } - if (productId != other.productId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java deleted file mode 100644 index 6875efa4..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/SessionBlob.java +++ /dev/null @@ -1,133 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -/** - * Blob containing all information about the user session. - * @author Simon - */ -public class SessionBlob { - - private Long uid; - private String sid; - private String token; - private Order order; - private List orderItems = new LinkedList(); - private String message; - - /** - * Constructor, creates an empty order. - */ - public SessionBlob() { - this.setOrder(new Order()); - } - - /** - * Getter for the userid. - * @return userid - */ - public Long getUID() { - return uid; - } - - /** - * Setter for the userid. - * @param uID userid - */ - public void setUID(Long uID) { - uid = uID; - } - - /** - * Getter for session id. - * @return session id - */ - public String getSID() { - return sid; - } - - /** - * Setter for session id. - * @param sID session id - */ - public void setSID(String sID) { - sid = sID; - } - - /** - * Getter for trust token. - * @return trust token - */ - public String getToken() { - return token; - } - - /** - * Setter for trust token. - * @param token trust token. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Setter for the message. - * @param message String - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Getter for the message. - * @return message - */ - public String getMessage() { - return message; - } - - /** - * Getter for order. - * @return order - */ - public Order getOrder() { - return order; - } - - /** - * Setter for order. - * @param order order - */ - public void setOrder(Order order) { - this.order = order; - } - - /** - * Getter for order items. - * @return order items. - */ - public List getOrderItems() { - return orderItems; - } - - /** - * Setter for order items. - * @param orderItems list of order items - */ - public void setOrderItems(List orderItems) { - this.orderItems = orderItems; - } - - @Override - public String toString() { - return "ClassName{" + - "uid=" + uid + - ", sid='" + sid + '\'' + - ", token='" + token + '\'' + - ", order=" + (order != null ? order.toString() : "null") + - ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java deleted file mode 100644 index d9c88f90..00000000 --- a/benchmarks/600.java/benchmark6/java/src/main/java/util/ShaSecurityProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package util; - -import java.io.UnsupportedEncodingException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. - * - * @author Simon - * - */ -public class ShaSecurityProvider implements ISecurityProvider { - - @Override - public IKeyProvider getKeyProvider() { - return new ConstantKeyProvider(); - } - - @Override - public SessionBlob secure(SessionBlob blob) { - if (blob.getUID() == null || blob.getSID() == null) { - return blob; - } - blob.setToken(null); - String blobString = blobToString(blob); - blob.setToken(getSha512(blobString)); - return blob; - } - - private String blobToString(SessionBlob blob) { - ObjectMapper o = new ObjectMapper(); - try { - return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); - } catch (JsonProcessingException | UnsupportedEncodingException e) - { - throw new IllegalStateException("Could not save blob!"); - } - } - - @Override - public SessionBlob validate(SessionBlob blob) { - if (blob.getToken() == null) { - return null; - } - - String token = blob.getToken(); - blob.setToken(null); - String blobString = blobToString(blob); - String validationToken = getSha512(blobString); - if (validationToken.equals(token)) { - return blob; - } - return null; - } - - private String getSha512(String passwordToHash) { - String generatedPassword = null; - try { - String salt = getKeyProvider().getKey(null); - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(salt.getBytes("UTF-8")); - byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - generatedPassword = sb.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - e.printStackTrace(); - } - return generatedPassword; - } -} diff --git a/benchmarks/600.java/benchmark7/config.json b/benchmarks/600.java/benchmark7/config.json deleted file mode 100644 index 11be1ace..00000000 --- a/benchmarks/600.java/benchmark7/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "timeout": 60, - "memory": 512, - "languages": ["java"] -} - \ No newline at end of file diff --git a/benchmarks/600.java/benchmark7/input.py b/benchmarks/600.java/benchmark7/input.py deleted file mode 100644 index 136f8bc5..00000000 --- a/benchmarks/600.java/benchmark7/input.py +++ /dev/null @@ -1,5 +0,0 @@ -def buckets_count(): - return (0, 0) - -def generate_input(data_dir, size, benchmarks_bucket, input_paths, output_paths, upload_func): - return { } \ No newline at end of file diff --git a/benchmarks/600.java/benchmark7/java/pom.xml b/benchmarks/600.java/benchmark7/java/pom.xml deleted file mode 100644 index f3a97c70..00000000 --- a/benchmarks/600.java/benchmark7/java/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - - faas - benchmark - 1 - - - 8 - 8 - UTF-8 - - - - - - com.google.code.gson - gson - 2.11.0 - - - - com.fasterxml.jackson.core - jackson-databind - 2.17.2 - - - - com.fasterxml.jackson.core - jackson-core - 2.17.2 - - - io.netty - netty-all - 4.1.65.Final - - - org.apache.pdfbox - pdfbox - 2.0.24 - - - org.apache.poi - poi-ooxml - 5.2.3 - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java b/benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java deleted file mode 100644 index ff55cef8..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/faas/App.java +++ /dev/null @@ -1,26 +0,0 @@ -package faas; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import util.SessionBlob; -import util.ShaSecurityProvider; - -//import jakarta.ws.rs.core.Response; - - -public class App { - public JsonObject handler(JsonObject args) { - Gson gson = new Gson(); - SessionBlob blob = gson.fromJson(args, SessionBlob.class); - - ShaSecurityProvider securityProvider = new ShaSecurityProvider(); - SessionBlob validatedBlob = securityProvider.validate(blob); - - JsonObject jsonResult = new JsonObject(); - if (validatedBlob != null) - jsonResult.addProperty("Authorization-Status", "Authorized"); - else - jsonResult.addProperty("Authorization-Status", "Unauthorized"); - return jsonResult; - } -} - diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java deleted file mode 100644 index ed377e1f..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/ConstantKeyProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - - -/** - * Class for testing. Provides a constant key. DO NOT ADOPT THIS FOR ANY REAL - * PRODUCTION WORKLOAD! - * - * @author Joakim von Kistowski - * - */ -public class ConstantKeyProvider implements IKeyProvider { - - /** - * {@inheritDoc} - */ - @Override - public String getKey(SessionBlob blob) { - return "thebestsecretkey"; - } - -} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java deleted file mode 100644 index c78e0dd0..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/IKeyProvider.java +++ /dev/null @@ -1,23 +0,0 @@ - -package util; - -/** - * Provides keys for the security provider. The key provider must ensure that - * keys accross replicated stores are consistent. - * - * @author Joakim von Kistowski - * - */ -public interface IKeyProvider { - - /** - * Returns a key for a session blob. Key must be the same, regardless of the - * store instance upon which this call is made. - * - * @param blob - * The blob to secure. - * @return The key. - */ - public String getKey(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java deleted file mode 100644 index 8d710001..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/ISecurityProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package util; - - -/** - * Utilities for securing (e.g. encrypting) session blobs. - * - * @author Joakim von Kistowski - * - */ -public interface ISecurityProvider { - - /** - * Get the key provider for this security provider. - * - * @return The key provider. - */ - public IKeyProvider getKeyProvider(); - - /** - * Secures a session blob. May encrypt or hash values within the blob. - * - * @param blob - * The blob to secure. - * @return A secure blob to be passed on to the web ui. - */ - public SessionBlob secure(SessionBlob blob); - - /** - * Validates a secured session blob. Returns a valid and readable (e.g. - * decrypted) blob. Returns null for invalid blobs. - * - * @param blob - * The blob to secure. - * @return The valid and readable (e.g. decrypted) blob. Returns null for - * invalid blobs. - */ - public SessionBlob validate(SessionBlob blob); - -} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java deleted file mode 100644 index 95434605..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/Order.java +++ /dev/null @@ -1,281 +0,0 @@ - -package util; - -/** - * Entity for orders. - * - * @author Joakim von Kistowski - * - */ -public class Order { - - private long id; - private long userId; - private String time; - - private long totalPriceInCents; - private String addressName; - private String address1; - private String address2; - - private String creditCardCompany; - private String creditCardNumber; - private String creditCardExpiryDate; - - /** - * Create a new and empty order. - */ - public Order() { - - } - - /** - * Every entity needs a copy constructor. - * - * @param order - * The order to copy. - */ - public Order(Order order) { - setId(order.getId()); - setUserId(order.getUserId()); - setTime(order.getTime()); - setTotalPriceInCents(order.getTotalPriceInCents()); - setAddressName(order.getAddressName()); - setAddress1(order.getAddress1()); - setAddress2(order.getAddress2()); - setCreditCardCompany(order.getCreditCardCompany()); - setCreditCardNumber(order.getCreditCardNumber()); - setCreditCardExpiryDate(order.getCreditCardExpiryDate()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * Get the User id. - * - * @return the userId. - */ - public long getUserId() { - return userId; - } - - /** - * Set the User Id. - * - * @param userId - * the userId to set. - */ - public void setUserId(long userId) { - this.userId = userId; - } - - /** - * Get the time of order (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @return the time. - */ - public String getTime() { - return time; - } - - /** - * Set the time of order (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE_TIME}. - * - * @param time - * the time to set. - */ - public void setTime(String time) { - this.time = time; - } - - /** - * Get the total price in cents. - * - * @return the totalPriceInCents. - */ - public long getTotalPriceInCents() { - return totalPriceInCents; - } - - /** - * Set the total price in cents. - * - * @param totalPriceInCents - * the totalPriceInCents to set. - */ - public void setTotalPriceInCents(long totalPriceInCents) { - this.totalPriceInCents = totalPriceInCents; - } - - /** - * Get the name for the address. - * - * @return the addressName. - */ - public String getAddressName() { - return addressName; - } - - /** - * Set the name for the address. - * - * @param addressName - * the addressName to set. - */ - public void setAddressName(String addressName) { - this.addressName = addressName; - } - - /** - * Get address line 1. - * - * @return the address1. - */ - public String getAddress1() { - return address1; - } - - /** - * Set address line 1. - * - * @param address1 - * the address1 to set. - */ - public void setAddress1(String address1) { - this.address1 = address1; - } - - /** - * Get address line 2. - * - * @return the address2. - */ - public String getAddress2() { - return address2; - } - - /** - * Set address line 2. - * - * @param address2 - * the address2 to set. - */ - public void setAddress2(String address2) { - this.address2 = address2; - } - - /** - * Get the name of the credit card company. - * - * @return the creditCardCompany. - */ - public String getCreditCardCompany() { - return creditCardCompany; - } - - /** - * Set the name of the credit card company. - * - * @param creditCardCompany - * the creditCardCompany to set. - */ - public void setCreditCardCompany(String creditCardCompany) { - this.creditCardCompany = creditCardCompany; - } - - /** - * Get the credit card number. - * - * @return the creditCardNumber. - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Set the credit card number. - * - * @param creditCardNumber - * the creditCardNumber to set. - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Get the credit card expiry date (ISO formatted). Formatted using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @return the creditCardExpiryDate. - */ - public String getCreditCardExpiryDate() { - return creditCardExpiryDate; - } - - /** - * Set the credit card expiry date (ISO formatted). Format using {@link DateTimeFormatter.ISO_LOCAL_DATE}. - * - * @param creditCardExpiryDate - * the creditCardExpiryDate to set. - */ - public void setCreditCardExpiryDate(String creditCardExpiryDate) { - this.creditCardExpiryDate = creditCardExpiryDate; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (userId ^ (userId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Order other = (Order) obj; - if (id != other.id) { - return false; - } - if (userId != other.userId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java deleted file mode 100644 index f0c01fe9..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/OrderItem.java +++ /dev/null @@ -1,179 +0,0 @@ - -package util; - -/** - * Entity Class for OrderItems (item with quantity in shopping cart or order). - * - * @author Joakim von Kistowski - * - */ -public class OrderItem { - - private long id; - private long productId; - private long orderId; - private int quantity; - private long unitPriceInCents; - - /** - * Create a new and empty OrderItem. - */ - public OrderItem() { - - } - - /** - * Every Entity needs a Copy-Constructor! - * - * @param orderItem - * The entity to Copy. - */ - public OrderItem(OrderItem orderItem) { - setId(orderItem.getId()); - setProductId(orderItem.getProductId()); - setOrderId(orderItem.getOrderId()); - setQuantity(orderItem.getQuantity()); - setUnitPriceInCents(orderItem.getUnitPriceInCents()); - } - - /** - * Get the id (remember that this ID may be incorrect, especially if a separate id was passed). - * - * @return The id. - */ - public long getId() { - return id; - } - - /** - * For REST use only. Sets the ID. Ignored by persistence. - * - * @param id - * ID, as passed by the REST API. - */ - public void setId(long id) { - this.id = id; - } - - /** - * ID of the order item's product. - * - * @return Product Id; - */ - public long getProductId() { - return productId; - } - - /** - * Sets the ID of the order item's product. Every order Item MUST have a valid product ID. - * - * @param productId - * The product ID to set. - */ - public void setProductId(long productId) { - this.productId = productId; - } - - /** - * Get the quantity (amount in shopping cart/order). - * - * @return The quantity. - */ - public int getQuantity() { - return quantity; - } - - /** - * Set the quantity (amount in shopping cart/order). - * - * @param quantity - * The quantity. - */ - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * The price per single item in the order item. - * - * @return Price per single item. - */ - public long getUnitPriceInCents() { - return unitPriceInCents; - } - - /** - * Set the price per single item in the order item. - * - * @param unitPriceInCents - * Price per single item. - */ - public void setUnitPriceInCents(long unitPriceInCents) { - this.unitPriceInCents = unitPriceInCents; - } - - /** - * Gets the ID of the order item's order. - * - * @return The order ID. - */ - public long getOrderId() { - return orderId; - } - - /** - * Sets the ID of the order item's order. Persistence requires that every order item MUST have a valid order ID. For - * persistence the order must already exist in database. - * - * @param orderId - * The order ID to set. - */ - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (orderId ^ (orderId >>> 32)); - result = prime * result + (int) (productId ^ (productId >>> 32)); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OrderItem other = (OrderItem) obj; - if (id != other.id) { - return false; - } - if (orderId != other.orderId) { - return false; - } - if (productId != other.productId) { - return false; - } - return true; - } - -} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java deleted file mode 100644 index 6875efa4..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/SessionBlob.java +++ /dev/null @@ -1,133 +0,0 @@ -package util; - -import java.util.LinkedList; -import java.util.List; - -/** - * Blob containing all information about the user session. - * @author Simon - */ -public class SessionBlob { - - private Long uid; - private String sid; - private String token; - private Order order; - private List orderItems = new LinkedList(); - private String message; - - /** - * Constructor, creates an empty order. - */ - public SessionBlob() { - this.setOrder(new Order()); - } - - /** - * Getter for the userid. - * @return userid - */ - public Long getUID() { - return uid; - } - - /** - * Setter for the userid. - * @param uID userid - */ - public void setUID(Long uID) { - uid = uID; - } - - /** - * Getter for session id. - * @return session id - */ - public String getSID() { - return sid; - } - - /** - * Setter for session id. - * @param sID session id - */ - public void setSID(String sID) { - sid = sID; - } - - /** - * Getter for trust token. - * @return trust token - */ - public String getToken() { - return token; - } - - /** - * Setter for trust token. - * @param token trust token. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Setter for the message. - * @param message String - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Getter for the message. - * @return message - */ - public String getMessage() { - return message; - } - - /** - * Getter for order. - * @return order - */ - public Order getOrder() { - return order; - } - - /** - * Setter for order. - * @param order order - */ - public void setOrder(Order order) { - this.order = order; - } - - /** - * Getter for order items. - * @return order items. - */ - public List getOrderItems() { - return orderItems; - } - - /** - * Setter for order items. - * @param orderItems list of order items - */ - public void setOrderItems(List orderItems) { - this.orderItems = orderItems; - } - - @Override - public String toString() { - return "ClassName{" + - "uid=" + uid + - ", sid='" + sid + '\'' + - ", token='" + token + '\'' + - ", order=" + (order != null ? order.toString() : "null") + - ", orderItems=" + (orderItems != null ? orderItems.toString() : "null") + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java b/benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java deleted file mode 100644 index d9c88f90..00000000 --- a/benchmarks/600.java/benchmark7/java/src/main/java/util/ShaSecurityProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -package util; - -import java.io.UnsupportedEncodingException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * Secruity provider uscom.fasterxml.jackson.databind.Objecting AES. - * - * @author Simon - * - */ -public class ShaSecurityProvider implements ISecurityProvider { - - @Override - public IKeyProvider getKeyProvider() { - return new ConstantKeyProvider(); - } - - @Override - public SessionBlob secure(SessionBlob blob) { - if (blob.getUID() == null || blob.getSID() == null) { - return blob; - } - blob.setToken(null); - String blobString = blobToString(blob); - blob.setToken(getSha512(blobString)); - return blob; - } - - private String blobToString(SessionBlob blob) { - ObjectMapper o = new ObjectMapper(); - try { - return URLEncoder.encode(o.writeValueAsString(blob), "UTF-8"); - } catch (JsonProcessingException | UnsupportedEncodingException e) - { - throw new IllegalStateException("Could not save blob!"); - } - } - - @Override - public SessionBlob validate(SessionBlob blob) { - if (blob.getToken() == null) { - return null; - } - - String token = blob.getToken(); - blob.setToken(null); - String blobString = blobToString(blob); - String validationToken = getSha512(blobString); - if (validationToken.equals(token)) { - return blob; - } - return null; - } - - private String getSha512(String passwordToHash) { - String generatedPassword = null; - try { - String salt = getKeyProvider().getKey(null); - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.update(salt.getBytes("UTF-8")); - byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - generatedPassword = sb.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - e.printStackTrace(); - } - return generatedPassword; - } -}