diff --git a/.env b/.env
new file mode 100644
index 0000000..311fbca
--- /dev/null
+++ b/.env
@@ -0,0 +1,4 @@
+SECRET_ACCESS_TOKEN_KEY=AuthSecretKey
+SECRET_REFRESH_TOKEN_KEY=RefreshTokenKey
+RATE_LIMIT_PER_SECOND=10
+RESOURCE_LIMIT_PER_DAY=60
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 9886518..86a2001 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,6 +8,14 @@
+
+
diff --git a/.vscode/README.md b/.vscode/README.md
deleted file mode 100644
index e577411..0000000
--- a/.vscode/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# For VS Code users
-
-This directory contains the configuration files and related contents for Visual Studio Code.
-
-## How to develop USE with Visual Studio Code
-
-1. Install Visual Studio Code from [https://code.visualstudio.com/](https://code.visualstudio.com/).
- - [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack) is recommended for Java development.
-
-2. Clone the USE repository from [https://github.com/useocl/use](https://github.com/useocl/use).
- - Currently USE is using JDK version 21. Install if you don't have it.
- - From the USE repository root, open the command prompt and run `mvn package` to generate the `target\generated-sources\antlr3` directory (which use-core depends on), and the `.jar` files.
-
-3. Open the USE repository in Visual Studio Code and start developing!
diff --git a/pom.xml b/pom.xml
index 01f5f2d..9140a31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
use-core
use-gui
use-assembly
- use-api
+ secure-use-api
diff --git a/secure-use-api/.DS_Store b/secure-use-api/.DS_Store
new file mode 100644
index 0000000..4263771
Binary files /dev/null and b/secure-use-api/.DS_Store differ
diff --git a/use-api/Dockerfile b/secure-use-api/Dockerfile
similarity index 100%
rename from use-api/Dockerfile
rename to secure-use-api/Dockerfile
diff --git a/use-api/docker-compose.yml b/secure-use-api/docker-compose.yml
similarity index 100%
rename from use-api/docker-compose.yml
rename to secure-use-api/docker-compose.yml
diff --git a/use-api/pom.xml b/secure-use-api/pom.xml
similarity index 77%
rename from use-api/pom.xml
rename to secure-use-api/pom.xml
index 17b6807..504b433 100644
--- a/use-api/pom.xml
+++ b/secure-use-api/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
use
org.tzi.use
@@ -9,8 +9,7 @@
4.0.0
- use-api
-
+ secure-use-api
21
@@ -23,7 +22,7 @@
org.springframework.boot
spring-boot-dependencies
- 3.1.5
+ 3.5.5
pom
import
@@ -84,7 +83,7 @@
org.springdoc
springdoc-openapi-starter-webmvc-ui
- 2.5.0
+ 2.8.14
org.springframework.boot
@@ -131,11 +130,93 @@
7.1.1
compile
-
org.springframework.boot
spring-boot-starter-data-mongodb
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
+
+ de.mkammerer
+ argon2-jvm
+ 2.7
+
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ jakarta.persistence
+ jakarta.persistence-api
+ 3.1.0
+
+
+
+
+ com.google.guava
+ guava
+ 32.1.3-jre
+
+
+
+
+ com.auth0
+ java-jwt
+ 4.2.1
+
+
+
+
+ io.github.cdimascio
+ dotenv-java
+ 2.0.0
+
+
+
+
+ com.google.code.gson
+ gson
+ 2.13.2
+
@@ -181,6 +262,9 @@
-Amapstruct.defaultComponentModel=spring
+
+ -parameters
+
@@ -251,4 +335,5 @@
+
\ No newline at end of file
diff --git a/secure-use-api/src/.DS_Store b/secure-use-api/src/.DS_Store
new file mode 100644
index 0000000..59eccef
Binary files /dev/null and b/secure-use-api/src/.DS_Store differ
diff --git a/secure-use-api/src/main/.DS_Store b/secure-use-api/src/main/.DS_Store
new file mode 100644
index 0000000..ad59c1c
Binary files /dev/null and b/secure-use-api/src/main/.DS_Store differ
diff --git a/secure-use-api/src/main/java/.DS_Store b/secure-use-api/src/main/java/.DS_Store
new file mode 100644
index 0000000..2120347
Binary files /dev/null and b/secure-use-api/src/main/java/.DS_Store differ
diff --git a/use-api/src/main/java/org/tzi/use/UseWebAPIApplication.java b/secure-use-api/src/main/java/org/tzi/use/SecureUseApi.java
similarity index 51%
rename from use-api/src/main/java/org/tzi/use/UseWebAPIApplication.java
rename to secure-use-api/src/main/java/org/tzi/use/SecureUseApi.java
index 0ba75b8..f8636e7 100644
--- a/use-api/src/main/java/org/tzi/use/UseWebAPIApplication.java
+++ b/secure-use-api/src/main/java/org/tzi/use/SecureUseApi.java
@@ -4,8 +4,8 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
-public class UseWebAPIApplication {
- public static void main(String[] args) {
- SpringApplication.run(UseWebAPIApplication.class, args);
- }
-}
+public class SecureUseApi {
+ public static void main(String[] args) {
+ SpringApplication.run(SecureUseApi.class, args);
+ }
+}
\ No newline at end of file
diff --git a/secure-use-api/src/main/java/org/tzi/use/api_security/exceptions/CustomAuthenticationEntryPoint.java b/secure-use-api/src/main/java/org/tzi/use/api_security/exceptions/CustomAuthenticationEntryPoint.java
new file mode 100644
index 0000000..657f575
--- /dev/null
+++ b/secure-use-api/src/main/java/org/tzi/use/api_security/exceptions/CustomAuthenticationEntryPoint.java
@@ -0,0 +1,22 @@
+package org.tzi.use.api_security.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Component
+public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
+ @Override
+ public void commence(HttpServletRequest request, HttpServletResponse response,
+ AuthenticationException authException) throws IOException {
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse(HttpStatus.UNAUTHORIZED, null, "");
+
+ exceptionResponse.writeToResponse(response, request);
+ }
+}
\ No newline at end of file
diff --git a/secure-use-api/src/main/java/org/tzi/use/api_security/exceptions/CustomExceptionHandler.java b/secure-use-api/src/main/java/org/tzi/use/api_security/exceptions/CustomExceptionHandler.java
new file mode 100644
index 0000000..3324c94
--- /dev/null
+++ b/secure-use-api/src/main/java/org/tzi/use/api_security/exceptions/CustomExceptionHandler.java
@@ -0,0 +1,62 @@
+package org.tzi.use.api_security.exceptions;
+
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.HttpStatusCode;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@ControllerAdvice
+public class CustomExceptionHandler extends ResponseEntityExceptionHandler {
+
+ @Override
+ protected ResponseEntity