diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..18e60bf
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..fdc392f
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml
new file mode 100644
index 0000000..af0a083
--- /dev/null
+++ b/.idea/material_theme_project_new.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 31e1ebc..55a6b78 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,10 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4bb49fb..0c3dd1a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,18 +1,72 @@
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ {
+ "associatedIndex": 1
+}
@@ -20,14 +74,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SecurityDemo/build.gradle b/SecurityDemo/build.gradle
index 18a8753..7325400 100644
--- a/SecurityDemo/build.gradle
+++ b/SecurityDemo/build.gradle
@@ -23,6 +23,19 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+ implementation 'org.springframework:spring-test'
+
+ implementation 'com.amazonaws:aws-lambda-java-core:1.2.1'
+ implementation 'com.amazonaws:aws-lambda-java-events:3.11.2'
+ implementation 'org.springframework.cloud:spring-cloud-function-adapter-aws:3.2.2'
+ implementation 'org.springframework.cloud:spring-cloud-function-web:3.2.2'
+
+ implementation 'com.fasterxml.jackson.core:jackson-databind'
+
+ implementation 'ch.qos.logback:logback-classic'
+
+ runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'
+
}
tasks.named('test') {
diff --git a/SecurityDemo/src/main/java/com/securitydemo/LambdaHandler.java b/SecurityDemo/src/main/java/com/securitydemo/LambdaHandler.java
new file mode 100644
index 0000000..c07522b
--- /dev/null
+++ b/SecurityDemo/src/main/java/com/securitydemo/LambdaHandler.java
@@ -0,0 +1,43 @@
+package com.securitydemo;
+
+import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.RequestHandler;
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
+import org.springframework.boot.SpringApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class LambdaHandler implements RequestHandler {
+ private static ConfigurableApplicationContext applicationContext;
+ private static SpringApiGatewayRequestHandler requestHandler;
+
+ @Override
+ public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
+ try {
+ // Initialize Spring context if not already done
+ if (applicationContext == null) {
+ applicationContext = SpringApplication.run(SecurityDemoApplication.class);
+ requestHandler = new SpringApiGatewayRequestHandler(applicationContext);
+ }
+
+ // Process the request through Spring
+ return requestHandler.handle(input);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ APIGatewayProxyResponseEvent errorResponse = new APIGatewayProxyResponseEvent();
+ errorResponse.setStatusCode(500);
+ errorResponse.setBody("{\"error\":\"" + e.getMessage() + "\"}");
+
+ // Add only Content-Type header without CORS
+ Map headers = new HashMap<>();
+ headers.put("Content-Type", "application/json");
+ errorResponse.setHeaders(headers);
+
+ return errorResponse;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SecurityDemo/src/main/java/com/securitydemo/SecurityDemoApplication.java b/SecurityDemo/src/main/java/com/securitydemo/SecurityDemoApplication.java
index b6095ab..3c1642c 100644
--- a/SecurityDemo/src/main/java/com/securitydemo/SecurityDemoApplication.java
+++ b/SecurityDemo/src/main/java/com/securitydemo/SecurityDemoApplication.java
@@ -14,6 +14,7 @@
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
@SpringBootApplication
@EnableMethodSecurity
public class SecurityDemoApplication {
diff --git a/SecurityDemo/src/main/java/com/securitydemo/SpringApiGatewayRequestHandler.java b/SecurityDemo/src/main/java/com/securitydemo/SpringApiGatewayRequestHandler.java
new file mode 100644
index 0000000..28cc40d
--- /dev/null
+++ b/SecurityDemo/src/main/java/com/securitydemo/SpringApiGatewayRequestHandler.java
@@ -0,0 +1,108 @@
+package com.securitydemo;
+
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.web.servlet.DispatcherServlet;
+
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SpringApiGatewayRequestHandler {
+ private final DispatcherServlet dispatcherServlet;
+
+ public SpringApiGatewayRequestHandler(ConfigurableApplicationContext applicationContext) {
+ this.dispatcherServlet = applicationContext.getBean(DispatcherServlet.class);
+ }
+
+ public APIGatewayProxyResponseEvent handle(APIGatewayProxyRequestEvent requestEvent) {
+ try {
+ // Convert API Gateway request to Spring request
+ MockHttpServletRequest request = createSpringRequest(requestEvent);
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ // Process the request
+ dispatcherServlet.service(request, response);
+
+ // Convert Spring response to API Gateway response
+ return createApiGatewayResponse(response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return createErrorResponse(e);
+ }
+ }
+
+ private MockHttpServletRequest createSpringRequest(APIGatewayProxyRequestEvent requestEvent) {
+ String path = requestEvent.getPath();
+ String httpMethod = requestEvent.getHttpMethod();
+
+ // Create a new Spring mock request
+ MockHttpServletRequest request = new MockHttpServletRequest(httpMethod, path);
+
+ // Handle query parameters
+ Map queryParams = requestEvent.getQueryStringParameters();
+ if (queryParams != null) {
+ queryParams.forEach(request::addParameter);
+ }
+
+ // Set headers
+ Map headers = requestEvent.getHeaders();
+ if (headers != null) {
+ headers.forEach(request::addHeader);
+ }
+
+ // Set body
+ String body = requestEvent.getBody();
+ if (body != null) {
+ request.setContent(body.getBytes());
+ }
+
+ // Set context path for proper Spring MVC URL handling
+ request.setContextPath("");
+ request.setServletPath(path);
+
+ return request;
+ }
+
+ private APIGatewayProxyResponseEvent createApiGatewayResponse(MockHttpServletResponse response) throws UnsupportedEncodingException {
+ APIGatewayProxyResponseEvent apiGatewayResponse = new APIGatewayProxyResponseEvent();
+
+ // Set status code
+ apiGatewayResponse.setStatusCode(response.getStatus());
+
+ // Set response body
+ String body = response.getContentAsString();
+ apiGatewayResponse.setBody(body);
+
+ // Set headers without CORS
+ Map responseHeaders = new HashMap<>();
+
+ // Add content type
+ responseHeaders.put("Content-Type", response.getContentType());
+
+ // Copy other headers
+ for (String headerName : response.getHeaderNames()) {
+ responseHeaders.put(headerName, response.getHeader(headerName));
+ }
+
+ apiGatewayResponse.setHeaders(responseHeaders);
+
+ return apiGatewayResponse;
+ }
+
+ private APIGatewayProxyResponseEvent createErrorResponse(Exception e) {
+ APIGatewayProxyResponseEvent errorResponse = new APIGatewayProxyResponseEvent();
+ errorResponse.setStatusCode(500);
+ errorResponse.setBody("{\"error\":\"" + e.getMessage() + "\"}");
+
+ // Add only Content-Type header
+ Map headers = new HashMap<>();
+ headers.put("Content-Type", "application/json");
+ errorResponse.setHeaders(headers);
+
+ return errorResponse;
+ }
+}
\ No newline at end of file