Commit 4ec1a670 authored by ReemyHasan's avatar ReemyHasan

Register in Eureka Server

parent d8960710
<component name="libraryTable">
<library name="Maven: org.apache.httpcomponents.core5:httpcore5:5.2.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5/5.2.1/httpcore5-5.2.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5/5.2.1/httpcore5-5.2.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5/5.2.1/httpcore5-5.2.1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.apache.httpcomponents.core5:httpcore5-h2:5.2.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5-h2/5.2.1/httpcore5-h2-5.2.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5-h2/5.2.1/httpcore5-h2-5.2.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/core5/httpcore5-h2/5.2.1/httpcore5-h2-5.2.1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.json:json:20090211">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20090211/json-20090211.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20090211/json-20090211-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20090211/json-20090211-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.mockito:mockito-core:5.3.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/5.3.1/mockito-core-5.3.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/5.3.1/mockito-core-5.3.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/5.3.1/mockito-core-5.3.1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.mockito:mockito-junit-jupiter:5.3.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.3.1/mockito-junit-jupiter-5.3.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.3.1/mockito-junit-jupiter-5.3.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-junit-jupiter/5.3.1/mockito-junit-jupiter-5.3.1-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.objenesis:objenesis:3.3">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/3.3/objenesis-3.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/3.3/objenesis-3.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/3.3/objenesis-3.3-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.springframework.boot:spring-boot-starter-cache:3.1.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-cache/3.1.0/spring-boot-starter-cache-3.1.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-cache/3.1.0/spring-boot-starter-cache-3.1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-cache/3.1.0/spring-boot-starter-cache-3.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.springframework.security:spring-security-crypto:6.1.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/security/spring-security-crypto/6.1.0/spring-security-crypto-6.1.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/security/spring-security-crypto/6.1.0/spring-security-crypto-6.1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/security/spring-security-crypto/6.1.0/spring-security-crypto-6.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.springframework:spring-context-support:6.0.9">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-support/6.0.9/spring-context-support-6.0.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-support/6.0.9/spring-context-support-6.0.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-support/6.0.9/spring-context-support-6.0.9-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<description>Processing service to process SNMP traps </description> <description>Processing service to process SNMP traps </description>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>
<spring-cloud.version>2022.0.3</spring-cloud.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -68,8 +69,22 @@ ...@@ -68,8 +69,22 @@
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.8.9</version> <version>2.8.9</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
...@@ -9,6 +9,7 @@ import jakarta.annotation.PostConstruct; ...@@ -9,6 +9,7 @@ import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.KafkaListener;
import java.util.List; import java.util.List;
...@@ -16,6 +17,7 @@ import java.util.Timer; ...@@ -16,6 +17,7 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient
public class ProcessingApplication { public class ProcessingApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -5,3 +5,6 @@ spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.Str ...@@ -5,3 +5,6 @@ spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.Str
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
server.port = 0 server.port = 0
workingPath = ./Processing/src/main/resources/utils workingPath = ./Processing/src/main/resources/utils
spring.application.name=TRAP-STREAM-SERVICE
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.33" level="project" /> <orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.33" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:3.0.4" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:3.0.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.14.2" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.2" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.2" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.2" level="project" />
...@@ -84,5 +82,55 @@ ...@@ -84,5 +82,55 @@
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:6.0.6" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-jcl:6.0.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:6.0.6" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:6.0.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.9.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:4.0.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:6.0.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcutil-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-eureka-client:4.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents.client5:httpclient5:5.1.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents.core5:httpcore5:5.1.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents.core5:httpcore5-h2:5.1.5" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
<orderEntry type="library" name="Maven: com.netflix.eureka:eureka-client:2.0.0" level="project" />
<orderEntry type="library" name="Maven: com.netflix.netflix-commons:netflix-eventbus:0.3.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-infix:0.3.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: commons-jxpath:commons-jxpath:1.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: joda-time:joda-time:2.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.antlr:antlr-runtime:3.4" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.google.code.gson:gson:2.9.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.commons:commons-math:2.2" level="project" />
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.19" level="project" />
<orderEntry type="library" name="Maven: io.github.x-stream:mxparser:1.2.2" level="project" />
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
<orderEntry type="library" name="Maven: jakarta.ws.rs:jakarta.ws.rs-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: jakarta.inject:jakarta.inject-api:2.0.1" level="project" />
<orderEntry type="library" name="Maven: com.netflix.servo:servo-core:0.12.21" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.16" level="project" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.14.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.14.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.jettison:jettison:1.4.0" level="project" />
<orderEntry type="library" name="Maven: com.netflix.eureka:eureka-core:2.0.0" level="project" />
<orderEntry type="library" name="Maven: jakarta.servlet:jakarta.servlet-api:6.0.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.woodstox:woodstox-core:6.2.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:4.2.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-loadbalancer:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-loadbalancer:4.0.3" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.5.3" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.4" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor.addons:reactor-extra:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:3.0.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:6.0.6" level="project" />
<orderEntry type="library" name="Maven: com.stoyanr:evictor:1.0.0" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>
<spring-cloud.version>2022.0.3</spring-cloud.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -45,8 +46,22 @@ ...@@ -45,8 +46,22 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
...@@ -4,8 +4,10 @@ import com.example.SnmpReciever.component.SnmpListener; ...@@ -4,8 +4,10 @@ import com.example.SnmpReciever.component.SnmpListener;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient
public class SnmpReceiverApplication implements CommandLineRunner { public class SnmpReceiverApplication implements CommandLineRunner {
private final SnmpListener trapReceiver; private final SnmpListener trapReceiver;
......
...@@ -2,6 +2,9 @@ server.port = 0 ...@@ -2,6 +2,9 @@ server.port = 0
spring.kafka.bootstrap-servers=http://172.29.3.220:9092 spring.kafka.bootstrap-servers=http://172.29.3.220:9092
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.listener.address=192.168.26.20/1625 spring.listener.address=localhost/1625
spring.listener.threads=20 spring.listener.threads=20
spring.listener.community=public spring.listener.community=public
spring.application.name=TRAP-LISTENER-SERVICE
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
...@@ -2,6 +2,9 @@ server.port = 0 ...@@ -2,6 +2,9 @@ server.port = 0
spring.kafka.bootstrap-servers=http://172.29.3.220:9092 spring.kafka.bootstrap-servers=http://172.29.3.220:9092
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.listener.address=192.168.26.20/1625 spring.listener.address=localhost/1625
spring.listener.threads=20 spring.listener.threads=20
spring.listener.community=public spring.listener.community=public
spring.application.name=TRAP-LISTENER-SERVICE
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
...@@ -77,6 +77,11 @@ ...@@ -77,6 +77,11 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
......
...@@ -72,4 +72,10 @@ public class SettingController { ...@@ -72,4 +72,10 @@ public class SettingController {
return ResponseEntity.ok(false); return ResponseEntity.ok(false);
} }
} }
@PostMapping("/translate")
public ResponseEntity<String> translateText(@RequestBody String request) {
// String translatedText = settingService.translateText(request.getSourceText(), request.getTargetLanguage());
return ResponseEntity.ok(request);
}
} }
...@@ -49,8 +49,8 @@ public class AuthenticationFilter extends AbstractGatewayFilterFactory<Authentic ...@@ -49,8 +49,8 @@ public class AuthenticationFilter extends AbstractGatewayFilterFactory<Authentic
return chain.filter(exchange); return chain.filter(exchange);
}); });
} }
public static class Config { public static class Config {
} }
} }
...@@ -10,7 +10,6 @@ import java.util.function.Predicate; ...@@ -10,7 +10,6 @@ import java.util.function.Predicate;
public class RouteValidator { public class RouteValidator {
public static final List<String> openApiEndpoints = List.of( public static final List<String> openApiEndpoints = List.of(
"/auth/register",
"/auth/token", "/auth/token",
"/eureka" "/eureka"
); );
......
...@@ -12,9 +12,12 @@ spring.cloud.gateway.routes[1].uri=lb://BACKEND-SERVICE ...@@ -12,9 +12,12 @@ spring.cloud.gateway.routes[1].uri=lb://BACKEND-SERVICE
spring.cloud.gateway.routes[1].predicates[0]=Path=/api/** spring.cloud.gateway.routes[1].predicates[0]=Path=/api/**
spring.cloud.gateway.routes[1].filters[0]=AuthenticationFilter spring.cloud.gateway.routes[1].filters[0]=AuthenticationFilter
spring.cloud.gateway.routes[2].id=user-service spring.cloud.gateway.routes[2].id=user-service
spring.cloud.gateway.routes[2].uri=lb://USER-SERVICE spring.cloud.gateway.routes[2].uri=lb://USER-SERVICE
spring.cloud.gateway.routes[2].predicates[0]=Path=/users/** spring.cloud.gateway.routes[2].predicates[0]=Path=/users/**
spring.cloud.gateway.routes[2].filters[0]=AuthenticationFilter spring.cloud.gateway.routes[2].filters[0]=AuthenticationFilter
spring.cloud.gateway.routes[3].id=user-service
spring.cloud.gateway.routes[3].uri=lb://USER-SERVICE
spring.cloud.gateway.routes[3].predicates[0]=Path=/users/**
spring.cloud.gateway.routes[3].filters[0]=AuthenticationFilter
\ No newline at end of file
...@@ -12,9 +12,12 @@ spring.cloud.gateway.routes[1].uri=lb://BACKEND-SERVICE ...@@ -12,9 +12,12 @@ spring.cloud.gateway.routes[1].uri=lb://BACKEND-SERVICE
spring.cloud.gateway.routes[1].predicates[0]=Path=/api/** spring.cloud.gateway.routes[1].predicates[0]=Path=/api/**
spring.cloud.gateway.routes[1].filters[0]=AuthenticationFilter spring.cloud.gateway.routes[1].filters[0]=AuthenticationFilter
spring.cloud.gateway.routes[2].id=user-service spring.cloud.gateway.routes[2].id=user-service
spring.cloud.gateway.routes[2].uri=lb://USER-SERVICE spring.cloud.gateway.routes[2].uri=lb://USER-SERVICE
spring.cloud.gateway.routes[2].predicates[0]=Path=/users/** spring.cloud.gateway.routes[2].predicates[0]=Path=/users/**
spring.cloud.gateway.routes[2].filters[0]=AuthenticationFilter spring.cloud.gateway.routes[2].filters[0]=AuthenticationFilter
spring.cloud.gateway.routes[3].id=user-service
spring.cloud.gateway.routes[3].uri=lb://USER-SERVICE
spring.cloud.gateway.routes[3].predicates[0]=Path=/users/**
spring.cloud.gateway.routes[3].filters[0]=AuthenticationFilter
\ No newline at end of file
...@@ -6,10 +6,10 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; ...@@ -6,10 +6,10 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
public class UserManagementServiceApplication { public class IdentityServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(UserManagementServiceApplication.class, args); SpringApplication.run(IdentityServiceApplication.class, args);
} }
} }
...@@ -27,7 +27,7 @@ public class AuthConfig { ...@@ -27,7 +27,7 @@ public class AuthConfig {
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http.csrf().disable() return http.csrf().disable()
.authorizeHttpRequests() .authorizeHttpRequests()
.requestMatchers("/auth/register", "/auth/token", "/auth/validate").permitAll() .requestMatchers( "/auth/token", "/auth/validate").permitAll()
.and() .and()
.build(); .build();
} }
......
...@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component; ...@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.Optional; import java.util.Optional;
@Component @Component
public class CustomUserDetailsService implements UserDetailsService { public class CustomUserDetailsService implements UserDetailsService{
@Autowired @Autowired
private UserCredentialRepository repository; private UserCredentialRepository repository;
......
...@@ -21,21 +21,29 @@ public class AuthController { ...@@ -21,21 +21,29 @@ public class AuthController {
@Autowired @Autowired
private AuthenticationManager authenticationManager; private AuthenticationManager authenticationManager;
@PostMapping("/register")
public Optional<UserCredential> addNewUser(@RequestBody UserCredential user) {
return service.saveUser(user);
}
@PostMapping("/token") @PostMapping("/token")
public String getToken(@RequestBody AuthRequest authRequest) { public String getToken(@RequestBody AuthRequest authRequest) {
System.out.println("Hi"+ authRequest); System.out.println("Hi" + authRequest);
Authentication authenticate = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authRequest.getUsername(), authRequest.getPassword())); try {
Authentication authenticate = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authRequest.getUsername(), authRequest.getPassword()));
if (authenticate.isAuthenticated()) { System.out.println("HEY");
return service.generateToken(authRequest.getUsername()); if (authenticate.isAuthenticated()) {
} else { return service.generateToken(authRequest.getUsername());
throw new RuntimeException("invalid access"); }
} catch (Exception e) {
e.printStackTrace();
return "Invalid Access";
} }
// Authentication authenticate = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authRequest.getUsername(), authRequest.getPassword()));
// System.out.println("HEY");
// if (authenticate.isAuthenticated()) {
// return service.generateToken(authRequest.getUsername());
// } else {
// System.out.println("invalid access");
// throw new RuntimeException("invalid access");
// }
return null;
} }
@GetMapping("/validate") @GetMapping("/validate")
......
package com.example.service;
import com.example.entity.UserCredential;
import com.example.repository.UserCredentialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class UserService {
@Autowired
private UserCredentialRepository repository;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private JwtService jwtService;
public Optional<UserCredential> getUserByID(int id){
return repository.findById(id);
}
public Optional<UserCredential> getUserByUsername(String username){
return repository.findByUsername(username);
}
public boolean deleteUserByID(int id){
try {
repository.deleteById(id);
return true;
}
catch (Exception e){
System.out.println("error in deleting user");
return false;
}
}
}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.ddl-auto=update #spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://172.29.3.220:3306/USER_APP spring.datasource.url=jdbc:mysql://172.29.3.220:3306/USER_APP
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=password spring.datasource.password=password
......
...@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; ...@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest
class UserManagementServiceApplicationTests { class IdentityServiceApplicationTests {
@Test @Test
void contextLoads() { void contextLoads() {
......
...@@ -69,10 +69,10 @@ ...@@ -69,10 +69,10 @@
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.9.3" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.9.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.9.3" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.9.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.9.3" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.9.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:5.3.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:4.8.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.14.4" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.14.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:3.3" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:3.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:5.3.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:4.8.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:6.0.9" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-core:6.0.9" level="project" />
...@@ -109,5 +109,47 @@ ...@@ -109,5 +109,47 @@
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" /> <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:3.1.0" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-websocket:6.0.9" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-websocket:6.0.9" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:4.0.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:6.1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcutil-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-eureka-client:4.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents.client5:httpclient5:5.2.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents.core5:httpcore5:5.2.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents.core5:httpcore5-h2:5.2.1" level="project" />
<orderEntry type="library" name="Maven: com.netflix.eureka:eureka-client:2.0.0" level="project" />
<orderEntry type="library" name="Maven: com.netflix.netflix-commons:netflix-eventbus:0.3.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-infix:0.3.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: commons-jxpath:commons-jxpath:1.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: joda-time:joda-time:2.3" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.antlr:antlr-runtime:3.4" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.commons:commons-math:2.2" level="project" />
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.19" level="project" />
<orderEntry type="library" name="Maven: io.github.x-stream:mxparser:1.2.2" level="project" />
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
<orderEntry type="library" name="Maven: jakarta.ws.rs:jakarta.ws.rs-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: jakarta.inject:jakarta.inject-api:2.0.1" level="project" />
<orderEntry type="library" name="Maven: com.netflix.servo:servo-core:0.12.21" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.jettison:jettison:1.4.0" level="project" />
<orderEntry type="library" name="Maven: com.netflix.eureka:eureka-core:2.0.0" level="project" />
<orderEntry type="library" name="Maven: jakarta.servlet:jakarta.servlet-api:6.0.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.woodstox:woodstox-core:6.2.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:4.2.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-loadbalancer:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-loadbalancer:4.0.3" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor.addons:reactor-extra:3.5.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:6.0.9" level="project" />
<orderEntry type="library" name="Maven: com.stoyanr:evictor:1.0.0" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>
<spring-cloud.version>2022.0.3</spring-cloud.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -83,9 +85,22 @@ ...@@ -83,9 +85,22 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
...@@ -9,10 +9,12 @@ import lombok.AllArgsConstructor; ...@@ -9,10 +9,12 @@ import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.KafkaListener;
@SpringBootApplication @SpringBootApplication
@AllArgsConstructor @AllArgsConstructor
@EnableDiscoveryClient
public class KafkaConsumerSnmpApplication { public class KafkaConsumerSnmpApplication {
private final Sender sender; private final Sender sender;
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -13,3 +13,7 @@ rethinkdb.host = 172.29.3.220 ...@@ -13,3 +13,7 @@ rethinkdb.host = 172.29.3.220
rethinkdb.port = 28015 rethinkdb.port = 28015
rethinkDBName = Traps rethinkDBName = Traps
rethinkDBTableName = Raw-Traps rethinkDBTableName = Raw-Traps
spring.application.name=TRAP-CONSUMER-SERVICE
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
...@@ -13,3 +13,7 @@ rethinkdb.host = 172.29.3.220 ...@@ -13,3 +13,7 @@ rethinkdb.host = 172.29.3.220
rethinkdb.port = 28015 rethinkdb.port = 28015
rethinkDBName = Traps rethinkDBName = Traps
rethinkDBTableName = Raw-Traps rethinkDBTableName = Raw-Traps
spring.application.name=TRAP-CONSUMER-SERVICE
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
server.port = 8761 server.port = 8761
eureka.client.registerWithEureka=false #eureka.client.registerWithEureka=false
eureka.client.register-with-eureka=false
eureka.client.fetchRegistry=false eureka.client.fetchRegistry=false
spring.application.name=DISCOVERY_SERVICE spring.application.name=DISCOVERY_SERVICE
\ No newline at end of file
server.port = 8761 server.port = 8761
eureka.client.registerWithEureka=false #eureka.client.registerWithEureka=false
eureka.client.register-with-eureka=false
eureka.client.fetchRegistry=false eureka.client.fetchRegistry=false
spring.application.name=DISCOVERY_SERVICE spring.application.name=DISCOVERY_SERVICE
\ No newline at end of file
...@@ -36,6 +36,10 @@ public class UserController { ...@@ -36,6 +36,10 @@ public class UserController {
return false; return false;
} }
} }
@PostMapping("/register")
public Optional<UserCredential> addNewUser(@RequestBody UserCredential user) {
return userService.saveUser(user);
}
@GetMapping("/getAllUsers") @GetMapping("/getAllUsers")
public Iterable<UserCredential> getAllUsers() { public Iterable<UserCredential> getAllUsers() {
......
...@@ -23,6 +23,19 @@ public class UserService { ...@@ -23,6 +23,19 @@ public class UserService {
public Optional<UserCredential> getUserByUsername(String username){ public Optional<UserCredential> getUserByUsername(String username){
return repository.findByUsername(username); return repository.findByUsername(username);
} }
public Optional<UserCredential> saveUser(UserCredential credential) {
// System.out.println("dskmdelkwmelkamdk "+credential);
credential.setPassword(passwordEncoder.encode(credential.getPassword()));
try {
repository.save(credential);
return repository.findByUsername(credential.getUsername());
}
catch (Exception e){
System.out.println(e);
return Optional.of(credential);
}
}
public boolean deleteUserByID(int id){ public boolean deleteUserByID(int id){
try { try {
repository.deleteById(id); repository.deleteById(id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment