diff --git a/.gitignore b/.gitignore index 792c2ee..59abfc9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,10 +23,10 @@ ### VS Code ### .vscode/ wrapper -/client-skeleton-provider/target -/client-skeleton-consumer/target -/client-skeleton-publisher/target -/client-skeleton-subscriber/target +/application-skeleton-provider/target +/application-skeleton-consumer/target +/application-skeleton-publisher/target +/application-skeleton-subscriber/target /mvnw /mvnw.cmd /.settings diff --git a/.project b/.project index f84cc55..303cf47 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - client + application-skeleton diff --git a/README.md b/README.md index 163d91b..93c2eeb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Arrowhead Client Skeletons (Java Spring-Boot) -##### The project provides client skeletons for the Arrowhead Framework 4.1.3 +# Arrowhead Application Skeletons (Java Spring-Boot) +##### The project provides application skeletons for the Arrowhead Framework -### How to use client skeletons? +### How to use application skeletons? Fork this repo and extend the skeletons with your own application code. ([check the best practice recommendations](https://github.com/arrowhead-f/client-skeleton-java-spring/blob/master/README.md#best-practices-to-start-with-the-skeletons)) @@ -10,7 +10,6 @@ Fork this repo and extend the skeletons with your own application code. ([check The project has the following dependencies: * JRE/JDK 11 [Download from here](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html) * Maven 3.5+ [Download from here](http://maven.apache.org/download.cgi) | [Install guide](https://www.baeldung.com/install-maven-on-windows-linux-mac) -* GitHub Packages [Configuring Maven for GitHub Packages](https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-apache-maven-for-use-with-github-packages) | [Example](https://github.com/arrowhead-f/client-library-java-spring/blob/master/docs/example_mvn_settings.xml) ### Project structure @@ -18,26 +17,26 @@ This is a multi-module maven project relying on the [parent `pom.xml`](https://g ##### Modules: -* **client-skeleton-consumer**: client skeleton module with the purpose of initiating an orchestration request and consume the service from the chosen provider. This consumer project also contains a simple example of how to orchestrate and consume the service afterward. +* **application-skeleton-consumer**: application skeleton module with the purpose of initiating an orchestration request and consume the service from the chosen provider. This consumer project also contains a simple example of how to orchestrate and consume the service afterward. -* **client-skeleton-provider**: client skeleton module with the purpose of registering a specific service into the Service Registry and running a web server where the service is available. +* **application-skeleton-provider**: application skeleton module with the purpose of registering a specific service into the Service Registry and running a web server where the service is available. -* **client-skeleton-subscriber**: client skeleton module with the purpose of registering subscriptions into the Event Handler and running a web server where it waits for notifications. +* **application-skeleton-subscriber**: application skeleton module with the purpose of registering subscriptions into the Event Handler and running a web server where it waits for notifications. -* **client-skeleton-publisher**: client publisher module with the purpose of publishing events into the Event Handler. +* **application-skeleton-publisher**: application publisher module with the purpose of publishing events into the Event Handler. -Skeletons are built on the [`Arrowhead Client Library`](https://github.com/arrowhead-f/client-library-java-spring) which is also imported to this project as a Maven dependency. The client library provides the `ArrowheadService.class` which is a singleton spring managed bean and designed with the purpose of interacting with Arrowhead Framework. Use its methods by [autowiring](https://www.baeldung.com/spring-autowire) into your spring managed custom classes or use `ArrowheadBeans.getArrowheadService()` if your custom class is not spring managed. *(**Look for the java docs** attached for each method within this class.)* +Skeletons are built on the [`Arrowhead Application Library`](https://github.com/arrowhead-f/application-library-java-spring) which is also imported to this project as a Maven dependency. The application library provides the `ArrowheadService.class` which is a singleton spring managed bean and designed with the purpose of interacting with Arrowhead Framework. Use its methods by [autowiring](https://www.baeldung.com/spring-autowire) into your spring managed custom classes or use `ArrowheadBeans.getArrowheadService()` if your custom class is not spring managed. *(**Look for the java docs** attached for each method within this class.)* -Each client skeleton has a default 'ApplicationInitListener' and a default 'SecurityConfig' what you can change or extend. The essential configuration has to be managed by customizing the `application.properties` file, located in `src/main/resources` folder. +Each application skeleton has a default 'ApplicationInitListener' and a default 'SecurityConfig' what you can change or extend. The essential configuration has to be managed by customizing the `application.properties` file, located in `src/main/resources` folder. ### Best practices to start with the skeletons ##### (1st) application.properties Location: `src/main/resources` -* * Decide the required security level and set the `server.ssl.enabled` and `token.security.filter.enabled` properties accordingly. -* * If `token.security.filter.enabled` is true, `server.ssl.enabled` also has to be true !!! +* Decide the required security level and set the `server.ssl.enabled` and `token.security.filter.enabled` properties accordingly. +* If `token.security.filter.enabled` is true, `server.ssl.enabled` also has to be true !!! * [Create](https://github.com/arrowhead-f/core-java-spring#certificates) your own client certificate (or for demo purpose use the provided one) and update the further `server.ssl...` properties accordingly. *(**Note** that `server.ssl.key-store-password` and `server.ssl.key-password` must be the same.)* -* Change the `client_system_name` property to your system name. *(**Note** that it should be in line with your certificate common name e.g.: when your certificate common name is `my_awesome_client.my_cloud.my_company.arrowhed.eu`, then your system name is  `my_awesome_client`)* +* Change the `application_system_name` property to your system name. *(**Note** that it should be in line with your certificate common name e.g.: when your certificate common name is `my-awesome-client.my-cloud.my-company.arrowhed.eu`, then your system name is  `my-awesome-client`)* * Adjust the Service Registry Core System location by the `sr_address` and `sr_port` properties. * In case of a provider you have to set its web-server parameters by the `server.address` and `server.port` properties. * In case of a consumer decide whether it should act as a web-server or not. If yes, then set the `spring.main.web-application-type` to 'servlet' and set further server parameters like in the provider case. If not, just leave these properties unchanged. @@ -52,9 +51,9 @@ All the provided skeleton classes are located in the child packages of the `eu.a * You can create your own packages like `com.my_company.my_awesome_project` to organize the skeleton and the application code separated. In the latter case if you wish to use Spring Beans at your custom packages, then you have to let the Spring Framework to known about your base package(s). This can be managed by adding the base package name(s) as a string value(s) in the `@ComponentScan` annotation of the application's `Main.class` *(**Look for the 'TODO' mark** within the main class)*. ##### (3rd) security configuration -The skeletons provide a built-in arrowhed framework compatible security configuration located in `eu.arrowhead.client.skeleton.consumer|provider.security` package. -* The `ConsumerSecurityConfig.class`, the `ProviderSecurityConfig.class`, the `SubscriberSecurityConfig.class` and the `PublisherSecurityConfig.class` extends the `DefaultSecurityConfig.class` which is imported by the client-library dependency and responsible for setting the `server.ssl.enabled` property declared in the `application.properties`. *(**Note:** The `ConsumerSecurityConfig.class` is became effective only when your consumer is a web-server.)* -* The `ConsumerAccessControlFilter.class` the `ProviderSecurityConfig.class`, the `SubscriberSecurityConfig.class` and the `PublisherSecurityConfig.class` extends the `AccessControlFilter.class` which is imported by the client-library dependency and responsible for setting the security level based on the `application.properties`. +The skeletons provide a built-in arrowhed framework compatible security configuration located in `eu.arrowhead.application.skeleton.consumer|provider.security` package. +* The `ConsumerSecurityConfig.class`, the `ProviderSecurityConfig.class`, the `SubscriberSecurityConfig.class` and the `PublisherSecurityConfig.class` extends the `DefaultSecurityConfig.class` which is imported by the application-library dependency and responsible for setting the `server.ssl.enabled` property declared in the `application.properties`. *(**Note:** The `ConsumerSecurityConfig.class` is became effective only when your consumer is a web-server.)* +* The `ConsumerAccessControlFilter.class` the `ProviderSecurityConfig.class`, the `SubscriberSecurityConfig.class` and the `PublisherSecurityConfig.class` extends the `AccessControlFilter.class` which is imported by the application-library dependency and responsible for setting the security level based on the `application.properties`.   -  `ConsumerAccessControlFilter.class` is effective only when your consumer is a web-server and `server.ssl.enabled` property is set to true. This filter is responsible for validating whether the received HTTPS request is coming from one of the local cloud's clients based on its certificate. *(**Look for the 'TODO' mark** within this class if you want to implement additional access rules.)*   -  `ProviderAccessControlFilter.class` is doing the same as described in the consumer case, but is effective only when `server.ssl.enabled` property is set to true and `token.security.filter.enabled` property is set to false. When `token.security.filter.enabled` property is set to true, then `ProviderTokenSecurityFilter.class` is effective which is validating whether a token is received within the HTTPS request and whether it is a valid one ore not. *(**Note** that the token is created by the Authorization Core System during the orchestration process and the consumer have to put it into its HTTPS request as a query parameter.)*   -  `PublisherAccessControlFilter.class` is doing the same as described in the provider case, but when `token.security.filter.enabled` property is set to true, then `PublisherTokenSecurityFilter.class` is effective and is doing the same as described in the provider case. @@ -63,7 +62,7 @@ The skeletons provide a built-in arrowhed framework compatible security configur * The `SubscriberNotificationAccessControlFilter.class` is checking the requested target URI and if it is registered in the application.properties as notification URI then validating whether the requester is an allowed Core System. If the requester is not allowed, it throws an AuthExeption with `" is unauthorized to access "` text in the message body. *(**Note:** By default only the `EVENT HANDLER CORE SYSTEM` is allowed.)* ##### (4th) start-up & shutdown configuration -The skeletons provide a built-in application start-up and shutdown configuration located in `eu.arrowhead.client.skeleton.consumer|provider` package. +The skeletons provide a built-in application start-up and shutdown configuration located in `eu.arrowhead.application.skeleton.consumer|provider` package. The `ConsumerApplicationInitListener.class`, the `ProviderApplicationInitListener.class`, `PublisherApplicationInitListener.class` and the `SubscriberApplicationInitListener.class` contains the `customInit()` method which is executed automatically right after the application start-up and also the `customDestroy()` method which is executed automatically right after triggering the application shutdown, but still before the final stop. *(**Look for the 'TODO' marks** within these classes if you want to implement additional logic.)* ###### Already implemented Consumer start-up logic: @@ -109,4 +108,4 @@ The `ConsumerApplicationInitListener.class`, the `ProviderApplicationInitListene ###### Already implemented Subscriber shutdown logics: * Unsubscribing from the event types defined in apllication.properties. -##### Check [`sos-examples-spring`](https://github.com/arrowhead-f/sos-examples-spring) repository for full demo client implementations. +##### Check [`sos-examples-spring`](https://github.com/arrowhead-f/sos-examples-spring) repository for full demo application implementations. diff --git a/client-skeleton-consumer/.classpath b/application-skeleton-consumer/.classpath similarity index 77% rename from client-skeleton-consumer/.classpath rename to application-skeleton-consumer/.classpath index fb22b95..cd04a79 100644 --- a/client-skeleton-consumer/.classpath +++ b/application-skeleton-consumer/.classpath @@ -21,17 +21,6 @@ - - - - - - - - - - - diff --git a/client-skeleton-consumer/.project b/application-skeleton-consumer/.project similarity index 94% rename from client-skeleton-consumer/.project rename to application-skeleton-consumer/.project index 71da5d4..b381f95 100644 --- a/client-skeleton-consumer/.project +++ b/application-skeleton-consumer/.project @@ -1,6 +1,6 @@ - client-skeleton-consumer + arrowhead-application-skeleton-consumer diff --git a/client-skeleton-consumer/pom.xml b/application-skeleton-consumer/pom.xml similarity index 88% rename from client-skeleton-consumer/pom.xml rename to application-skeleton-consumer/pom.xml index 5385160..8330ed1 100644 --- a/client-skeleton-consumer/pom.xml +++ b/application-skeleton-consumer/pom.xml @@ -2,12 +2,12 @@ 4.0.0 - eu.arrowhead - client-skeleton - 4.1.3.3 + eu.arrowhead + application-skeleton-java-spring + 4.4.0.0 - arrowhead-client-skeleton-consumer + arrowhead-application-skeleton-consumer Arrowhead Consumer Skeleton diff --git a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/ConsumerApplicationInitListener.java b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerApplicationInitListener.java similarity index 85% rename from client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/ConsumerApplicationInitListener.java rename to application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerApplicationInitListener.java index 74158b6..c2ac821 100644 --- a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/ConsumerApplicationInitListener.java +++ b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerApplicationInitListener.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.consumer; +package eu.arrowhead.application.skeleton.consumer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -6,8 +6,8 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.config.ApplicationInitListener; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.config.ApplicationInitListener; import eu.arrowhead.common.core.CoreSystem; @Component @@ -29,7 +29,7 @@ public class ConsumerApplicationInitListener extends ApplicationInitListener { protected void customInit(final ContextRefreshedEvent event) { //Checking the availability of necessary core systems - checkCoreSystemReachability(CoreSystem.SERVICE_REGISTRY); + checkCoreSystemReachability(CoreSystem.SERVICEREGISTRY); checkCoreSystemReachability(CoreSystem.ORCHESTRATOR); diff --git a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/ConsumerMain.java b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerMain.java similarity index 95% rename from client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/ConsumerMain.java rename to application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerMain.java index a1caa1b..4623955 100644 --- a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/ConsumerMain.java +++ b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerMain.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.consumer; +package eu.arrowhead.application.skeleton.consumer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,7 +10,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.http.HttpMethod; -import eu.arrowhead.client.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.ArrowheadService; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.dto.shared.OrchestrationFlags.Flag; import eu.arrowhead.common.dto.shared.OrchestrationFormRequestDTO; @@ -21,7 +21,7 @@ import eu.arrowhead.common.exception.ArrowheadException; @SpringBootApplication -@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE}) //TODO: add custom packages if any +@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE, "ai.aitia"}) //TODO: add custom packages if any public class ConsumerMain implements ApplicationRunner { //================================================================================================= diff --git a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/security/ConsumerAccessControlFilter.java b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerAccessControlFilter.java similarity index 93% rename from client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/security/ConsumerAccessControlFilter.java rename to application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerAccessControlFilter.java index b96a761..f06b1ef 100644 --- a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/security/ConsumerAccessControlFilter.java +++ b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerAccessControlFilter.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.consumer.security; +package eu.arrowhead.application.skeleton.consumer.security; import java.util.Map; diff --git a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/security/ConsumerSecurityConfig.java b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerSecurityConfig.java similarity index 73% rename from client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/security/ConsumerSecurityConfig.java rename to application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerSecurityConfig.java index 2618e39..14f791a 100644 --- a/client-skeleton-consumer/src/main/java/eu/arrowhead/client/skeleton/consumer/security/ConsumerSecurityConfig.java +++ b/application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerSecurityConfig.java @@ -1,10 +1,10 @@ -package eu.arrowhead.client.skeleton.consumer.security; +package eu.arrowhead.application.skeleton.consumer.security; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import eu.arrowhead.client.library.config.DefaultSecurityConfig; +import ai.aitia.arrowhead.application.library.config.DefaultSecurityConfig; @Configuration @ConditionalOnWebApplication diff --git a/client-skeleton-consumer/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/application-skeleton-consumer/src/main/resources/META-INF/additional-spring-configuration-metadata.json similarity index 100% rename from client-skeleton-consumer/src/main/resources/META-INF/additional-spring-configuration-metadata.json rename to application-skeleton-consumer/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/client-skeleton-consumer/src/main/resources/application.properties b/application-skeleton-consumer/src/main/resources/application.properties similarity index 91% rename from client-skeleton-consumer/src/main/resources/application.properties rename to application-skeleton-consumer/src/main/resources/application.properties index 014329d..7e740b1 100644 --- a/client-skeleton-consumer/src/main/resources/application.properties +++ b/application-skeleton-consumer/src/main/resources/application.properties @@ -3,7 +3,7 @@ ############################################ # Name of the client system -client_system_name=CONSUMER_SKELETON +application_system_name=CONSUMERSKELETON # Set the web application type to 'servlet' if your consumer client should act as a web-server # and fill the address and port propetries with valid values [Defaults, when not adjusted: localhost:8080] @@ -25,7 +25,7 @@ sr_port=8443 server.ssl.enabled=true server.ssl.key-store-type=PKCS12 -server.ssl.key-store=classpath:certificates/consumer_skeleton.p12 +server.ssl.key-store=classpath:certificates/consumerskeleton.p12 server.ssl.key-store-password=123456 server.ssl.key-alias=consumerskeleton server.ssl.key-password=123456 diff --git a/application-skeleton-consumer/src/main/resources/certificates/consumerskeleton.p12 b/application-skeleton-consumer/src/main/resources/certificates/consumerskeleton.p12 new file mode 100644 index 0000000..d171004 Binary files /dev/null and b/application-skeleton-consumer/src/main/resources/certificates/consumerskeleton.p12 differ diff --git a/client-skeleton-consumer/src/main/resources/certificates/truststore.p12 b/application-skeleton-consumer/src/main/resources/certificates/truststore.p12 similarity index 100% rename from client-skeleton-consumer/src/main/resources/certificates/truststore.p12 rename to application-skeleton-consumer/src/main/resources/certificates/truststore.p12 diff --git a/client-skeleton-publisher/.classpath b/application-skeleton-provider/.classpath similarity index 77% rename from client-skeleton-publisher/.classpath rename to application-skeleton-provider/.classpath index 8690355..cd04a79 100644 --- a/client-skeleton-publisher/.classpath +++ b/application-skeleton-provider/.classpath @@ -16,27 +16,16 @@ - - - - - - + - - + - - - - - - + diff --git a/client-skeleton-provider/.project b/application-skeleton-provider/.project similarity index 94% rename from client-skeleton-provider/.project rename to application-skeleton-provider/.project index 49f50fb..92578d0 100644 --- a/client-skeleton-provider/.project +++ b/application-skeleton-provider/.project @@ -1,6 +1,6 @@ - client-skeleton-provider + arrowhead-application-skeleton-provider diff --git a/client-skeleton-provider/.springBeans b/application-skeleton-provider/.springBeans similarity index 100% rename from client-skeleton-provider/.springBeans rename to application-skeleton-provider/.springBeans diff --git a/client-skeleton-provider/pom.xml b/application-skeleton-provider/pom.xml similarity index 88% rename from client-skeleton-provider/pom.xml rename to application-skeleton-provider/pom.xml index 04e5eec..bd3a507 100644 --- a/client-skeleton-provider/pom.xml +++ b/application-skeleton-provider/pom.xml @@ -2,12 +2,12 @@ 4.0.0 - eu.arrowhead - client-skeleton - 4.1.3.3 + eu.arrowhead + application-skeleton-java-spring + 4.4.0.0 - arrowhead-client-skeleton-provider + arrowhead-application-skeleton-provider Arrowhead Provider Skeleton diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/ProviderApplicationInitListener.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/ProviderApplicationInitListener.java similarity index 80% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/ProviderApplicationInitListener.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/ProviderApplicationInitListener.java index f92a44b..3ebf2d0 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/ProviderApplicationInitListener.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/ProviderApplicationInitListener.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider; +package eu.arrowhead.application.skeleton.provider; import java.io.IOException; import java.security.KeyStore; @@ -15,10 +15,10 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.config.ApplicationInitListener; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.client.skeleton.provider.security.ProviderSecurityConfig; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.config.ApplicationInitListener; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.application.skeleton.provider.security.ProviderSecurityConfig; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.core.CoreSystem; @@ -36,7 +36,7 @@ public class ProviderApplicationInitListener extends ApplicationInitListener { @Autowired private ProviderSecurityConfig providerSecurityConfig; - @Value(ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) + @Value(ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) private boolean tokenSecurityFilterEnabled; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) @@ -50,9 +50,10 @@ public class ProviderApplicationInitListener extends ApplicationInitListener { //------------------------------------------------------------------------------------------------- @Override protected void customInit(final ContextRefreshedEvent event) { - + checkConfiguration(); + //Checking the availability of necessary core systems - checkCoreSystemReachability(CoreSystem.SERVICE_REGISTRY); + checkCoreSystemReachability(CoreSystem.SERVICEREGISTRY); if (sslEnabled && tokenSecurityFilterEnabled) { checkCoreSystemReachability(CoreSystem.AUTHORIZATION); @@ -76,6 +77,14 @@ public void customDestroy() { //================================================================================================= // assistant methods + + //------------------------------------------------------------------------------------------------- + private void checkConfiguration() { + if (!sslEnabled && tokenSecurityFilterEnabled) { + logger.warn("Contradictory configuration:"); + logger.warn("token.security.filter.enabled=true while server.ssl.enabled=false"); + } + } //------------------------------------------------------------------------------------------------- private void setTokenSecurityFilter() { diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/ProviderMain.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/ProviderMain.java similarity index 78% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/ProviderMain.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/ProviderMain.java index e85cf60..5ef7484 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/ProviderMain.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/ProviderMain.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider; +package eu.arrowhead.application.skeleton.provider; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,7 +7,7 @@ import eu.arrowhead.common.CommonConstants; @SpringBootApplication -@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE}) //TODO: add custom packages if any +@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE, "ai.aitia"}) //TODO: add custom packages if any public class ProviderMain { //================================================================================================= diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ConfigConstants.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ConfigConstants.java similarity index 89% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ConfigConstants.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ConfigConstants.java index 38c70cd..ff1520b 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ConfigConstants.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ConfigConstants.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.configuration; +package eu.arrowhead.application.skeleton.provider.configuration; public class ConfigConstants { diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ContainerConfProperties.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ContainerConfProperties.java similarity index 94% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ContainerConfProperties.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ContainerConfProperties.java index ea57c14..8e87a74 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ContainerConfProperties.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ContainerConfProperties.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.configuration; +package eu.arrowhead.application.skeleton.provider.configuration; import javax.validation.constraints.Max; import javax.validation.constraints.Min; diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ContainerConfiguration.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ContainerConfiguration.java similarity index 90% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ContainerConfiguration.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ContainerConfiguration.java index 453f323..bd51cee 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ContainerConfiguration.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/configuration/ContainerConfiguration.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider.configuration; +package eu.arrowhead.application.skeleton.provider.configuration; import org.apache.coyote.http11.AbstractHttp11Protocol; import org.apache.logging.log4j.LogManager; @@ -23,6 +23,7 @@ public class ContainerConfiguration implements WebServerFactoryCustomizer { @@ -30,7 +31,6 @@ public void customize(TomcatServletWebServerFactory factory) { protocol.setMaxKeepAliveRequests(containerConfProperties.getMaxKeepAliveRequests()); - // log.info("####################################################################################"); log.info("#"); log.info("# TomcatCustomizer"); @@ -41,8 +41,7 @@ public void customize(TomcatServletWebServerFactory factory) { log.info("# connection timeout: {} ms", protocol.getConnectionTimeout()); log.info("# max connections: {}", protocol.getMaxConnections()); log.info("#"); - log.info( - "####################################################################################"); + log.info("####################################################################################"); }); } diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/controller/ProviderController.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/controller/ProviderController.java similarity index 93% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/controller/ProviderController.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/controller/ProviderController.java index 95c9a7a..bf0edb2 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/controller/ProviderController.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/controller/ProviderController.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider.controller; +package eu.arrowhead.application.skeleton.provider.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderAccessControlFilter.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderAccessControlFilter.java similarity index 77% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderAccessControlFilter.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderAccessControlFilter.java index e2395d2..28832f9 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderAccessControlFilter.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderAccessControlFilter.java @@ -1,16 +1,16 @@ -package eu.arrowhead.client.skeleton.provider.security; +package eu.arrowhead.application.skeleton.provider.security; import java.util.Map; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; -import eu.arrowhead.client.library.util.ClientCommonConstants; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.security.AccessControlFilter; @Component -@ConditionalOnExpression(CommonConstants.$SERVER_SSL_ENABLED_WD + " and !" + ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) +@ConditionalOnExpression(CommonConstants.$SERVER_SSL_ENABLED_WD + " and !" + ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) public class ProviderAccessControlFilter extends AccessControlFilter { @Override diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderSecurityConfig.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderSecurityConfig.java similarity index 82% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderSecurityConfig.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderSecurityConfig.java index 08cdca2..2ae8edb 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderSecurityConfig.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderSecurityConfig.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider.security; +package eu.arrowhead.application.skeleton.provider.security; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -6,9 +6,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter; -import eu.arrowhead.client.library.config.DefaultSecurityConfig; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.common.CommonConstants; +import ai.aitia.arrowhead.application.library.config.DefaultSecurityConfig; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; @Configuration @EnableWebSecurity @@ -17,7 +16,7 @@ public class ProviderSecurityConfig extends DefaultSecurityConfig { //================================================================================================= // members - @Value(ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) + @Value(ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) private boolean tokenSecurityFilterEnabled; private ProviderTokenSecurityFilter tokenSecurityFilter; diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderTokenSecurityFilter.java b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderTokenSecurityFilter.java similarity index 95% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderTokenSecurityFilter.java rename to application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderTokenSecurityFilter.java index 3dce009..316077b 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/security/ProviderTokenSecurityFilter.java +++ b/application-skeleton-provider/src/main/java/eu/arrowhead/application/skeleton/provider/security/ProviderTokenSecurityFilter.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider.security; +package eu.arrowhead.application.skeleton.provider.security; import java.security.PrivateKey; import java.security.PublicKey; diff --git a/client-skeleton-provider/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/application-skeleton-provider/src/main/resources/META-INF/additional-spring-configuration-metadata.json similarity index 100% rename from client-skeleton-provider/src/main/resources/META-INF/additional-spring-configuration-metadata.json rename to application-skeleton-provider/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/client-skeleton-provider/src/main/resources/application.properties b/application-skeleton-provider/src/main/resources/application.properties similarity index 90% rename from client-skeleton-provider/src/main/resources/application.properties rename to application-skeleton-provider/src/main/resources/application.properties index 7e8b8a9..e59a4e2 100644 --- a/client-skeleton-provider/src/main/resources/application.properties +++ b/application-skeleton-provider/src/main/resources/application.properties @@ -3,7 +3,7 @@ ############################################ # Name of the client system -client_system_name=PROVIDER_SKELETON +application_system_name=PROVIDERSKELETON # Client web-server parameters server.address=127.0.0.1 @@ -28,7 +28,7 @@ server.ssl.enabled=true token.security.filter.enabled=true server.ssl.key-store-type=PKCS12 -server.ssl.key-store=classpath:certificates/provider_skeleton.p12 +server.ssl.key-store=classpath:certificates/providerskeleton.p12 server.ssl.key-store-password=123456 server.ssl.key-alias=providerskeleton server.ssl.key-password=123456 diff --git a/application-skeleton-provider/src/main/resources/certificates/providerskeleton.p12 b/application-skeleton-provider/src/main/resources/certificates/providerskeleton.p12 new file mode 100644 index 0000000..c5b5799 Binary files /dev/null and b/application-skeleton-provider/src/main/resources/certificates/providerskeleton.p12 differ diff --git a/client-skeleton-provider/src/main/resources/certificates/truststore.p12 b/application-skeleton-provider/src/main/resources/certificates/truststore.p12 similarity index 100% rename from client-skeleton-provider/src/main/resources/certificates/truststore.p12 rename to application-skeleton-provider/src/main/resources/certificates/truststore.p12 diff --git a/client-skeleton-provider/.classpath b/application-skeleton-publisher/.classpath similarity index 77% rename from client-skeleton-provider/.classpath rename to application-skeleton-publisher/.classpath index fb22b95..920da3a 100644 --- a/client-skeleton-provider/.classpath +++ b/application-skeleton-publisher/.classpath @@ -16,27 +16,16 @@ - - - - - - - - - - - + - + + - + - - diff --git a/client-skeleton-publisher/.project b/application-skeleton-publisher/.project similarity index 95% rename from client-skeleton-publisher/.project rename to application-skeleton-publisher/.project index 26bd190..fca9ad2 100644 --- a/client-skeleton-publisher/.project +++ b/application-skeleton-publisher/.project @@ -1,6 +1,6 @@ - client-skeleton-provider + arrowhead-application-skeleton-publisher diff --git a/client-skeleton-publisher/.settings/org.eclipse.wst.common.project.facet.core.xml b/application-skeleton-publisher/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from client-skeleton-publisher/.settings/org.eclipse.wst.common.project.facet.core.xml rename to application-skeleton-publisher/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/client-skeleton-publisher/.springBeans b/application-skeleton-publisher/.springBeans similarity index 100% rename from client-skeleton-publisher/.springBeans rename to application-skeleton-publisher/.springBeans diff --git a/client-skeleton-publisher/pom.xml b/application-skeleton-publisher/pom.xml similarity index 88% rename from client-skeleton-publisher/pom.xml rename to application-skeleton-publisher/pom.xml index 49c69bf..5542c25 100644 --- a/client-skeleton-publisher/pom.xml +++ b/application-skeleton-publisher/pom.xml @@ -2,12 +2,12 @@ 4.0.0 - eu.arrowhead - client-skeleton - 4.1.3.3 + eu.arrowhead + application-skeleton-java-spring + 4.4.0.0 - arrowhead-client-skeleton-publisher + arrowhead-application-skeleton-publisher Arrowhead Publisher Skeleton diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/PublisherApplicationInitListener.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/PublisherApplicationInitListener.java similarity index 74% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/PublisherApplicationInitListener.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/PublisherApplicationInitListener.java index 807c971..e8b0de3 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/PublisherApplicationInitListener.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/PublisherApplicationInitListener.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher; +package eu.arrowhead.application.skeleton.publisher; import java.io.IOException; import java.security.KeyStore; @@ -18,12 +18,12 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.config.ApplicationInitListener; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.client.skeleton.publisher.constants.PublisherConstants; -import eu.arrowhead.client.skeleton.publisher.event.PresetEventType; -import eu.arrowhead.client.skeleton.publisher.security.PublisherSecurityConfig; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.config.ApplicationInitListener; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.application.skeleton.publisher.constants.PublisherConstants; +import eu.arrowhead.application.skeleton.publisher.event.PresetEventType; +import eu.arrowhead.application.skeleton.publisher.security.PublisherSecurityConfig; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.core.CoreSystem; @@ -43,20 +43,20 @@ public class PublisherApplicationInitListener extends ApplicationInitListener { @Autowired private PublisherSecurityConfig publisherSecurityConfig; - @Value(ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) + @Value(ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) private boolean tokenSecurityFilterEnabled; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) private boolean sslEnabled; - @Value(ClientCommonConstants.$CLIENT_SYSTEM_NAME) - private String clientSystemName; + @Value(ApplicationCommonConstants.$APPLICATION_SYSTEM_NAME) + private String applicationSystemName; - @Value(ClientCommonConstants.$CLIENT_SERVER_ADDRESS_WD) - private String clientSystemAddress; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_ADDRESS_WD) + private String applicationSystemAddress; - @Value(ClientCommonConstants.$CLIENT_SERVER_PORT_WD) - private int clientSystemPort; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_PORT_WD) + private int applicationSystemPort; private final Logger logger = LogManager.getLogger(PublisherApplicationInitListener.class); @@ -66,9 +66,10 @@ public class PublisherApplicationInitListener extends ApplicationInitListener { //------------------------------------------------------------------------------------------------- @Override protected void customInit(final ContextRefreshedEvent event) { - + checkConfiguration(); + //Checking the availability of necessary core systems - checkCoreSystemReachability(CoreSystem.SERVICE_REGISTRY); + checkCoreSystemReachability(CoreSystem.SERVICEREGISTRY); if (sslEnabled && tokenSecurityFilterEnabled) { checkCoreSystemReachability(CoreSystem.AUTHORIZATION); @@ -82,9 +83,8 @@ protected void customInit(final ContextRefreshedEvent event) { logger.info("TokenSecurityFilter in not active"); } - if ( arrowheadService.echoCoreSystem(CoreSystem.EVENT_HANDLER) ) { - - arrowheadService.updateCoreServiceURIs(CoreSystem.EVENT_HANDLER); + if (arrowheadService.echoCoreSystem(CoreSystem.EVENTHANDLER)) { + arrowheadService.updateCoreServiceURIs(CoreSystem.EVENTHANDLER); publishInitStartedEvent(); } @@ -100,6 +100,14 @@ public void customDestroy() { //================================================================================================= // assistant methods + + //------------------------------------------------------------------------------------------------- + private void checkConfiguration() { + if (!sslEnabled && tokenSecurityFilterEnabled) { + logger.warn("Contradictory configuration:"); + logger.warn("token.security.filter.enabled=true while server.ssl.enabled=false"); + } + } //------------------------------------------------------------------------------------------------- private void setTokenSecurityFilter() { @@ -130,9 +138,9 @@ private void publishInitStartedEvent() { final String eventType = PresetEventType.START_INIT.getEventTypeName(); final SystemRequestDTO source = new SystemRequestDTO(); - source.setSystemName(clientSystemName); - source.setAddress(clientSystemAddress); - source.setPort(clientSystemPort); + source.setSystemName(applicationSystemName); + source.setAddress(applicationSystemAddress); + source.setPort(applicationSystemPort); if (sslEnabled) { source.setAuthenticationInfo( Base64.getEncoder().encodeToString(arrowheadService.getMyPublicKey().getEncoded())); } diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/PublisherMain.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/PublisherMain.java similarity index 75% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/PublisherMain.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/PublisherMain.java index 8bbe034..836dd64 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/PublisherMain.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/PublisherMain.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher; +package eu.arrowhead.application.skeleton.publisher; import java.time.ZonedDateTime; import java.util.Base64; @@ -14,30 +14,30 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.client.skeleton.publisher.constants.PublisherConstants; -import eu.arrowhead.client.skeleton.publisher.event.PresetEventType; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.application.skeleton.publisher.constants.PublisherConstants; +import eu.arrowhead.application.skeleton.publisher.event.PresetEventType; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.dto.shared.EventPublishRequestDTO; import eu.arrowhead.common.dto.shared.SystemRequestDTO; @SpringBootApplication -@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE}) //TODO: add custom packages if any +@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE, "ai.aitia"}) //TODO: add custom packages if any public class PublisherMain implements ApplicationRunner { //================================================================================================= // members - @Value(ClientCommonConstants.$CLIENT_SYSTEM_NAME) - private String clientSystemName; + @Value(ApplicationCommonConstants.$APPLICATION_SYSTEM_NAME) + private String applicationSystemName; - @Value(ClientCommonConstants.$CLIENT_SERVER_ADDRESS_WD) - private String clientSystemAddress; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_ADDRESS_WD) + private String applicationSystemAddress; - @Value(ClientCommonConstants.$CLIENT_SERVER_PORT_WD) - private int clientSystemPort; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_PORT_WD) + private int applicationSystemPort; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) private boolean sslEnabled; @@ -72,9 +72,9 @@ private void publishRunStartedEvent() { final String eventType = PresetEventType.START_RUN.getEventTypeName(); final SystemRequestDTO source = new SystemRequestDTO(); - source.setSystemName(clientSystemName); - source.setAddress(clientSystemAddress); - source.setPort(clientSystemPort); + source.setSystemName(applicationSystemName); + source.setAddress(applicationSystemAddress); + source.setPort(applicationSystemPort); if (sslEnabled) { source.setAuthenticationInfo(Base64.getEncoder().encodeToString( arrowheadService.getMyPublicKey().getEncoded())); } diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ConfigConstants.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ConfigConstants.java similarity index 89% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ConfigConstants.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ConfigConstants.java index f70dbe7..bfdd82e 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ConfigConstants.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ConfigConstants.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider.configuration; +package eu.arrowhead.application.skeleton.publisher.configuration; public class ConfigConstants { diff --git a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ContainerConfProperties.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ContainerConfProperties.java similarity index 94% rename from client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ContainerConfProperties.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ContainerConfProperties.java index c4cbce8..4d0b73b 100644 --- a/client-skeleton-provider/src/main/java/eu/arrowhead/client/skeleton/provider/configuration/ContainerConfProperties.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ContainerConfProperties.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.provider.configuration; +package eu.arrowhead.application.skeleton.publisher.configuration; import javax.validation.constraints.Max; import javax.validation.constraints.Min; diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ContainerConfiguration.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ContainerConfiguration.java similarity index 87% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ContainerConfiguration.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ContainerConfiguration.java index 11abc83..4773f56 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ContainerConfiguration.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/configuration/ContainerConfiguration.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.configuration; +package eu.arrowhead.application.skeleton.publisher.configuration; import org.apache.coyote.http11.AbstractHttp11Protocol; import org.apache.logging.log4j.LogManager; @@ -17,12 +17,13 @@ public class ContainerConfiguration implements WebServerFactoryCustomizer { @@ -30,7 +31,6 @@ public void customize(TomcatServletWebServerFactory factory) { protocol.setMaxKeepAliveRequests(containerConfProperties.getMaxKeepAliveRequests()); - // log.info("####################################################################################"); log.info("#"); log.info("# TomcatCustomizer"); @@ -41,9 +41,7 @@ public void customize(TomcatServletWebServerFactory factory) { log.info("# connection timeout: {} ms", protocol.getConnectionTimeout()); log.info("# max connections: {}", protocol.getMaxConnections()); log.info("#"); - log.info( - "####################################################################################"); + log.info("####################################################################################"); }); } - } \ No newline at end of file diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/constants/PublisherConstants.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/constants/PublisherConstants.java similarity index 90% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/constants/PublisherConstants.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/constants/PublisherConstants.java index 5e459a7..7a2c403 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/constants/PublisherConstants.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/constants/PublisherConstants.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.constants; +package eu.arrowhead.application.skeleton.publisher.constants; public class PublisherConstants { //================================================================================================= diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/controller/PublisherController.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/controller/PublisherController.java similarity index 75% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/controller/PublisherController.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/controller/PublisherController.java index 006fb9f..e36f61c 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/controller/PublisherController.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/controller/PublisherController.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.controller; +package eu.arrowhead.application.skeleton.publisher.controller; import java.util.Map; @@ -9,9 +9,9 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import eu.arrowhead.client.skeleton.publisher.event.EventTypeConstants; -import eu.arrowhead.client.skeleton.publisher.event.PresetEventType; -import eu.arrowhead.client.skeleton.publisher.service.PublisherService; +import eu.arrowhead.application.skeleton.publisher.event.EventTypeConstants; +import eu.arrowhead.application.skeleton.publisher.event.PresetEventType; +import eu.arrowhead.application.skeleton.publisher.service.PublisherService; import eu.arrowhead.common.CommonConstants; @RestController @@ -33,12 +33,11 @@ public class PublisherController { public String echoService() { logger.debug("echoService started..."); - publisherService.publish(PresetEventType.REQUEST_RECEIVED, Map.of( EventTypeConstants.EVENT_TYPE_REQUEST_RECEIVED_METADATA_REQUEST_TYPE, HttpMethod.GET.name() ), CommonConstants.ECHO_URI); + publisherService.publish(PresetEventType.REQUEST_RECEIVED, Map.of(EventTypeConstants.EVENT_TYPE_REQUEST_RECEIVED_METADATA_REQUEST_TYPE, HttpMethod.GET.name()), CommonConstants.ECHO_URI); return "Got it!"; } //------------------------------------------------------------------------------------------------- //TODO: implement here your provider related REST end points - -} +} \ No newline at end of file diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/event/EventTypeConstants.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/event/EventTypeConstants.java similarity index 92% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/event/EventTypeConstants.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/event/EventTypeConstants.java index 87e56a1..4fe15fc 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/event/EventTypeConstants.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/event/EventTypeConstants.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.event; +package eu.arrowhead.application.skeleton.publisher.event; public class EventTypeConstants { diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/event/PresetEventType.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/event/PresetEventType.java similarity index 96% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/event/PresetEventType.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/event/PresetEventType.java index e35b0cd..4155641 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/event/PresetEventType.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/event/PresetEventType.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.event; +package eu.arrowhead.application.skeleton.publisher.event; import java.util.Collections; import java.util.List; diff --git a/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherAccessControlFilter.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherAccessControlFilter.java new file mode 100644 index 0000000..5c2ede4 --- /dev/null +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherAccessControlFilter.java @@ -0,0 +1,22 @@ +package eu.arrowhead.application.skeleton.publisher.security; + +import java.util.Map; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.stereotype.Component; + +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.common.CommonConstants; +import eu.arrowhead.common.security.AccessControlFilter; + +@Component +@ConditionalOnExpression(CommonConstants.$SERVER_SSL_ENABLED_WD + " and !" + ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) +public class PublisherAccessControlFilter extends AccessControlFilter { + + @Override + protected void checkClientAuthorized(final String clientCN, final String method, final String requestTarget, final String requestJSON, final Map queryParams) { + super.checkClientAuthorized(clientCN, method, requestTarget, requestJSON, queryParams); + + //TODO: implement here your custom access filter if any further + } +} \ No newline at end of file diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherSecurityConfig.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherSecurityConfig.java similarity index 77% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherSecurityConfig.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherSecurityConfig.java index 37fb9ca..4d9da42 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherSecurityConfig.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherSecurityConfig.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.security; +package eu.arrowhead.application.skeleton.publisher.security; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -6,8 +6,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter; -import eu.arrowhead.client.library.config.DefaultSecurityConfig; -import eu.arrowhead.client.library.util.ClientCommonConstants; +import ai.aitia.arrowhead.application.library.config.DefaultSecurityConfig; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; @Configuration @EnableWebSecurity @@ -16,7 +16,7 @@ public class PublisherSecurityConfig extends DefaultSecurityConfig { //================================================================================================= // members - @Value(ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) + @Value(ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) private boolean tokenSecurityFilterEnabled; private PublisherTokenSecurityFilter tokenSecurityFilter; @@ -30,7 +30,7 @@ protected void configure(HttpSecurity http) throws Exception { super.configure(http); if (tokenSecurityFilterEnabled) { tokenSecurityFilter = new PublisherTokenSecurityFilter(); - http.addFilterAfter(tokenSecurityFilter, SecurityContextHolderAwareRequestFilter.class); + http.addFilterAfter(tokenSecurityFilter, SecurityContextHolderAwareRequestFilter.class); } } @@ -38,4 +38,4 @@ protected void configure(HttpSecurity http) throws Exception { public PublisherTokenSecurityFilter getTokenSecurityFilter() { return tokenSecurityFilter; } -} +} \ No newline at end of file diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherTokenSecurityFilter.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherTokenSecurityFilter.java similarity index 95% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherTokenSecurityFilter.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherTokenSecurityFilter.java index 1b2757c..94043ef 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherTokenSecurityFilter.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/security/PublisherTokenSecurityFilter.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.security; +package eu.arrowhead.application.skeleton.publisher.security; import java.security.PrivateKey; import java.security.PublicKey; diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/service/PublisherService.java b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/service/PublisherService.java similarity index 76% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/service/PublisherService.java rename to application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/service/PublisherService.java index a23cfe3..ea4de25 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/service/PublisherService.java +++ b/application-skeleton-publisher/src/main/java/eu/arrowhead/application/skeleton/publisher/service/PublisherService.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.service; +package eu.arrowhead.application.skeleton.publisher.service; import java.time.ZonedDateTime; import java.util.Base64; @@ -10,10 +10,10 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.client.skeleton.publisher.PublisherApplicationInitListener; -import eu.arrowhead.client.skeleton.publisher.event.PresetEventType; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.application.skeleton.publisher.PublisherApplicationInitListener; +import eu.arrowhead.application.skeleton.publisher.event.PresetEventType; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.dto.shared.EventPublishRequestDTO; @@ -24,14 +24,14 @@ public class PublisherService { //================================================================================================= // members - @Value(ClientCommonConstants.$CLIENT_SYSTEM_NAME) - private String clientSystemName; + @Value(ApplicationCommonConstants.$APPLICATION_SYSTEM_NAME) + private String applicationSystemName; - @Value(ClientCommonConstants.$CLIENT_SERVER_ADDRESS_WD) - private String clientSystemAddress; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_ADDRESS_WD) + private String applicationSystemAddress; - @Value(ClientCommonConstants.$CLIENT_SERVER_PORT_WD) - private int clientSystemPort; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_PORT_WD) + private int applicationSystemPort; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) private boolean sslEnabled; @@ -47,7 +47,6 @@ public class PublisherService { //------------------------------------------------------------------------------------------------- //Sample implementation of event publishing of preset event types public void publish(final PresetEventType eventType, final Map metadata, final String payload) { - final EventPublishRequestDTO request = getPublishRequest(eventType, metadata, payload); arrowheadService.publishToEventHandler(request); } @@ -69,13 +68,13 @@ private SystemRequestDTO getSource() { logger.debug("getSource started..."); final SystemRequestDTO source = new SystemRequestDTO(); - source.setSystemName(clientSystemName); - source.setAddress(clientSystemAddress); - source.setPort(clientSystemPort); + source.setSystemName(applicationSystemName); + source.setAddress(applicationSystemAddress); + source.setPort(applicationSystemPort); if (sslEnabled) { source.setAuthenticationInfo( Base64.getEncoder().encodeToString(arrowheadService.getMyPublicKey().getEncoded())); } return source; } -} +} \ No newline at end of file diff --git a/client-skeleton-publisher/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/application-skeleton-publisher/src/main/resources/META-INF/additional-spring-configuration-metadata.json similarity index 100% rename from client-skeleton-publisher/src/main/resources/META-INF/additional-spring-configuration-metadata.json rename to application-skeleton-publisher/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/client-skeleton-publisher/src/main/resources/application.properties b/application-skeleton-publisher/src/main/resources/application.properties similarity index 86% rename from client-skeleton-publisher/src/main/resources/application.properties rename to application-skeleton-publisher/src/main/resources/application.properties index d794cb2..e8baf75 100644 --- a/client-skeleton-publisher/src/main/resources/application.properties +++ b/application-skeleton-publisher/src/main/resources/application.properties @@ -3,7 +3,7 @@ ############################################ # Name of the client system -client_system_name=PUBLISHER_SKELETON +application_system_name=PUBLISHERSKELETON # Client web-server parameters server.address=127.0.0.1 @@ -25,9 +25,9 @@ server.ssl.enabled=true token.security.filter.enabled=false server.ssl.key-store-type=PKCS12 -server.ssl.key-store=classpath:certificates/publisher_skeleton.p12 +server.ssl.key-store=classpath:certificates/publisherskeleton.p12 server.ssl.key-store-password=123456 -server.ssl.key-alias=publisher_skeleton +server.ssl.key-alias=publisherskeleton server.ssl.key-password=123456 server.ssl.client-auth=need server.ssl.trust-store-type=PKCS12 diff --git a/application-skeleton-publisher/src/main/resources/certificates/publisherskeleton.p12 b/application-skeleton-publisher/src/main/resources/certificates/publisherskeleton.p12 new file mode 100644 index 0000000..c7c0a7a Binary files /dev/null and b/application-skeleton-publisher/src/main/resources/certificates/publisherskeleton.p12 differ diff --git a/client-skeleton-publisher/src/main/resources/certificates/truststore.p12 b/application-skeleton-publisher/src/main/resources/certificates/truststore.p12 similarity index 100% rename from client-skeleton-publisher/src/main/resources/certificates/truststore.p12 rename to application-skeleton-publisher/src/main/resources/certificates/truststore.p12 diff --git a/client-skeleton-subscriber/.classpath b/application-skeleton-subscriber/.classpath similarity index 77% rename from client-skeleton-subscriber/.classpath rename to application-skeleton-subscriber/.classpath index fb22b95..cd04a79 100644 --- a/client-skeleton-subscriber/.classpath +++ b/application-skeleton-subscriber/.classpath @@ -21,17 +21,6 @@ - - - - - - - - - - - diff --git a/client-skeleton-subscriber/.project b/application-skeleton-subscriber/.project similarity index 95% rename from client-skeleton-subscriber/.project rename to application-skeleton-subscriber/.project index 26bd190..899af96 100644 --- a/client-skeleton-subscriber/.project +++ b/application-skeleton-subscriber/.project @@ -1,6 +1,6 @@ - client-skeleton-provider + arrowhead-application-skeleton-subscriber diff --git a/client-skeleton-subscriber/.settings/org.eclipse.wst.common.project.facet.core.xml b/application-skeleton-subscriber/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from client-skeleton-subscriber/.settings/org.eclipse.wst.common.project.facet.core.xml rename to application-skeleton-subscriber/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/client-skeleton-subscriber/.springBeans b/application-skeleton-subscriber/.springBeans similarity index 100% rename from client-skeleton-subscriber/.springBeans rename to application-skeleton-subscriber/.springBeans diff --git a/client-skeleton-subscriber/pom.xml b/application-skeleton-subscriber/pom.xml similarity index 88% rename from client-skeleton-subscriber/pom.xml rename to application-skeleton-subscriber/pom.xml index 205d547..cf28210 100644 --- a/client-skeleton-subscriber/pom.xml +++ b/application-skeleton-subscriber/pom.xml @@ -2,12 +2,12 @@ 4.0.0 - eu.arrowhead - client-skeleton - 4.1.3.3 + eu.arrowhead + application-skeleton-java-spring + 4.4.0.0 - arrowhead-client-skeleton-subscriber + arrowhead-application-skeleton-subscriber Arrowhead Subscriber Skeleton diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/ConfigEventProperites.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/ConfigEventProperites.java similarity index 94% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/ConfigEventProperites.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/ConfigEventProperites.java index 7fac17a..3e9bd83 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/ConfigEventProperites.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/ConfigEventProperites.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber; +package eu.arrowhead.application.skeleton.subscriber; import java.util.Map; diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberApplicationInitListener.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberApplicationInitListener.java similarity index 77% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberApplicationInitListener.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberApplicationInitListener.java index 0f273cc..b2a3f8a 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberApplicationInitListener.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberApplicationInitListener.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber; +package eu.arrowhead.application.skeleton.subscriber; import java.io.IOException; import java.security.KeyStore; @@ -17,10 +17,10 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.config.ApplicationInitListener; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.client.skeleton.subscriber.security.SubscriberSecurityConfig; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.config.ApplicationInitListener; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.application.skeleton.subscriber.security.SubscriberSecurityConfig; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.core.CoreSystem; @@ -40,20 +40,20 @@ public class SubscriberApplicationInitListener extends ApplicationInitListener { @Autowired private SubscriberSecurityConfig subscriberSecurityConfig; - @Value(ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) + @Value(ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) private boolean tokenSecurityFilterEnabled; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) private boolean sslEnabled; - @Value(ClientCommonConstants.$CLIENT_SYSTEM_NAME) - private String clientSystemName; + @Value(ApplicationCommonConstants.$APPLICATION_SYSTEM_NAME) + private String applicationSystemName; - @Value(ClientCommonConstants.$CLIENT_SERVER_ADDRESS_WD) - private String clientSystemAddress; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_ADDRESS_WD) + private String applicationSystemAddress; - @Value(ClientCommonConstants.$CLIENT_SERVER_PORT_WD) - private int clientSystemPort; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_PORT_WD) + private int applicationSystemPort; private final Logger logger = LogManager.getLogger(SubscriberApplicationInitListener.class); @@ -66,9 +66,10 @@ public class SubscriberApplicationInitListener extends ApplicationInitListener { //------------------------------------------------------------------------------------------------- @Override protected void customInit(final ContextRefreshedEvent event) { - + checkConfiguration(); + //Checking the availability of necessary core systems - checkCoreSystemReachability(CoreSystem.SERVICE_REGISTRY); + checkCoreSystemReachability(CoreSystem.SERVICEREGISTRY); checkCoreSystemReachability(CoreSystem.ORCHESTRATOR); arrowheadService.updateCoreServiceURIs(CoreSystem.ORCHESTRATOR); @@ -91,9 +92,8 @@ protected void customInit(final ContextRefreshedEvent event) { } - - if ( arrowheadService.echoCoreSystem(CoreSystem.EVENT_HANDLER)) { - arrowheadService.updateCoreServiceURIs(CoreSystem.EVENT_HANDLER); + if (arrowheadService.echoCoreSystem(CoreSystem.EVENTHANDLER)) { + arrowheadService.updateCoreServiceURIs(CoreSystem.EVENTHANDLER); subscribeToPresetEvents(); } @@ -110,13 +110,21 @@ public void customDestroy() { logger.info("No preset events to unsubscribe."); } else { for (final String eventType : eventTypeMap.keySet()) { - arrowheadService.unsubscribeFromEventHandler(eventType, clientSystemName, clientSystemAddress, clientSystemPort); + arrowheadService.unsubscribeFromEventHandler(eventType, applicationSystemName, applicationSystemAddress, applicationSystemPort); } } } //================================================================================================= // assistant methods + + //------------------------------------------------------------------------------------------------- + private void checkConfiguration() { + if (!sslEnabled && tokenSecurityFilterEnabled) { + logger.warn("Contradictory configuration:"); + logger.warn("token.security.filter.enabled=true while server.ssl.enabled=false"); + } + } //------------------------------------------------------------------------------------------------- private void setTokenSecurityFilter() { @@ -152,16 +160,16 @@ private void subscribeToPresetEvents() { logger.info("No preset events to subscribe."); } else { final SystemRequestDTO subscriber = new SystemRequestDTO(); - subscriber.setSystemName(clientSystemName); - subscriber.setAddress(clientSystemAddress); - subscriber.setPort(clientSystemPort); + subscriber.setSystemName(applicationSystemName); + subscriber.setAddress(applicationSystemAddress); + subscriber.setPort(applicationSystemPort); if (sslEnabled) { subscriber.setAuthenticationInfo(Base64.getEncoder().encodeToString(arrowheadService.getMyPublicKey().getEncoded())); } for (final String eventType : eventTypeMap.keySet()) { try { - arrowheadService.unsubscribeFromEventHandler(eventType, clientSystemName, clientSystemAddress, clientSystemPort); + arrowheadService.unsubscribeFromEventHandler(eventType, applicationSystemName, applicationSystemAddress, applicationSystemPort); } catch (final Exception ex) { logger.debug("Exception happend in subscription initalization " + ex); } diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberMain.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberMain.java similarity index 77% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberMain.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberMain.java index 8b704cb..6fefaf9 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberMain.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberMain.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber; +package eu.arrowhead.application.skeleton.subscriber; import java.util.Base64; import java.util.Map; @@ -14,16 +14,16 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.ComponentScan; -import eu.arrowhead.client.library.ArrowheadService; -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.client.skeleton.subscriber.constants.SubscriberConstants; +import ai.aitia.arrowhead.application.library.ArrowheadService; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; +import eu.arrowhead.application.skeleton.subscriber.constants.SubscriberConstants; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.dto.shared.SystemRequestDTO; import eu.arrowhead.common.exception.InvalidParameterException; @SpringBootApplication @EnableConfigurationProperties(ConfigEventProperites.class) -@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE}) //TODO: add custom packages if any +@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE, "ai.aitia"}) //TODO: add custom packages if any public class SubscriberMain implements ApplicationRunner { //================================================================================================= @@ -32,14 +32,14 @@ public class SubscriberMain implements ApplicationRunner { @Value( SubscriberConstants.$PRESET_EVENT_TYPES_WD ) private String presetEvents; - @Value(ClientCommonConstants.$CLIENT_SYSTEM_NAME) - private String clientSystemName; + @Value(ApplicationCommonConstants.$APPLICATION_SYSTEM_NAME) + private String applicationSystemName; - @Value(ClientCommonConstants.$CLIENT_SERVER_ADDRESS_WD) - private String clientSystemAddress; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_ADDRESS_WD) + private String applicationSystemAddress; - @Value(ClientCommonConstants.$CLIENT_SERVER_PORT_WD) - private int clientSystemPort; + @Value(ApplicationCommonConstants.$APPLICATION_SERVER_PORT_WD) + private int applicationSystemPort; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) private boolean sslEnabled; @@ -80,9 +80,9 @@ private void subscribeToPresetEvents() { } else { final SystemRequestDTO subscriber = new SystemRequestDTO(); - subscriber.setSystemName(clientSystemName); - subscriber.setAddress(clientSystemAddress); - subscriber.setPort(clientSystemPort); + subscriber.setSystemName(applicationSystemName); + subscriber.setAddress(applicationSystemAddress); + subscriber.setPort(applicationSystemPort); if (sslEnabled) { subscriber.setAuthenticationInfo( Base64.getEncoder().encodeToString(arrowheadService.getMyPublicKey().getEncoded())); @@ -90,7 +90,7 @@ private void subscribeToPresetEvents() { for (final String eventType : eventTypeMap.keySet()) { try { - arrowheadService.unsubscribeFromEventHandler(eventType, clientSystemName, clientSystemAddress, clientSystemPort); + arrowheadService.unsubscribeFromEventHandler(eventType, applicationSystemName, applicationSystemAddress, applicationSystemPort); } catch (final Exception ex) { logger.debug("Could not unsubscribe from EventType: " + eventType); } diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberUtilities.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberUtilities.java similarity index 84% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberUtilities.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberUtilities.java index ead7adb..ec756fb 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/SubscriberUtilities.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/SubscriberUtilities.java @@ -1,6 +1,6 @@ -package eu.arrowhead.client.skeleton.subscriber; +package eu.arrowhead.application.skeleton.subscriber; -import eu.arrowhead.client.skeleton.subscriber.constants.SubscriberDefaults; +import eu.arrowhead.application.skeleton.subscriber.constants.SubscriberDefaults; import eu.arrowhead.common.dto.shared.SubscriptionRequestDTO; import eu.arrowhead.common.dto.shared.SystemRequestDTO; @@ -11,7 +11,6 @@ public class SubscriberUtilities { //------------------------------------------------------------------------------------------------- public static SubscriptionRequestDTO createSubscriptionRequestDTO(final String eventType, final SystemRequestDTO subscriber, final String notificationUri) { - final SubscriptionRequestDTO subscription = new SubscriptionRequestDTO(eventType.toUpperCase(), subscriber, null, @@ -19,7 +18,8 @@ public static SubscriptionRequestDTO createSubscriptionRequestDTO(final String e false, null, null, - null); + null); + return subscription; } -} +} \ No newline at end of file diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ConfigConstants.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ConfigConstants.java similarity index 89% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ConfigConstants.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ConfigConstants.java index c51fead..5d661b4 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ConfigConstants.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ConfigConstants.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.configuration; +package eu.arrowhead.application.skeleton.subscriber.configuration; public class ConfigConstants { diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ContainerConfProperties.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ContainerConfProperties.java similarity index 94% rename from client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ContainerConfProperties.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ContainerConfProperties.java index fd2dc48..3bd5a08 100644 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/configuration/ContainerConfProperties.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ContainerConfProperties.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.publisher.configuration; +package eu.arrowhead.application.skeleton.subscriber.configuration; import javax.validation.constraints.Max; import javax.validation.constraints.Min; diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ContainerConfiguration.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ContainerConfiguration.java similarity index 90% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ContainerConfiguration.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ContainerConfiguration.java index 4a39cdb..ed6750c 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/configuration/ContainerConfiguration.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/configuration/ContainerConfiguration.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.configuration; +package eu.arrowhead.application.skeleton.subscriber.configuration; import org.apache.coyote.http11.AbstractHttp11Protocol; import org.apache.logging.log4j.LogManager; @@ -23,6 +23,7 @@ public class ContainerConfiguration implements WebServerFactoryCustomizer { @@ -30,7 +31,6 @@ public void customize(TomcatServletWebServerFactory factory) { protocol.setMaxKeepAliveRequests(containerConfProperties.getMaxKeepAliveRequests()); - // log.info("####################################################################################"); log.info("#"); log.info("# TomcatCustomizer"); @@ -41,9 +41,7 @@ public void customize(TomcatServletWebServerFactory factory) { log.info("# connection timeout: {} ms", protocol.getConnectionTimeout()); log.info("# max connections: {}", protocol.getMaxConnections()); log.info("#"); - log.info( - "####################################################################################"); + log.info("####################################################################################"); }); } - } \ No newline at end of file diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/constants/SubscriberConstants.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/constants/SubscriberConstants.java similarity index 93% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/constants/SubscriberConstants.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/constants/SubscriberConstants.java index 11faf70..a666292 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/constants/SubscriberConstants.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/constants/SubscriberConstants.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.constants; +package eu.arrowhead.application.skeleton.subscriber.constants; public class SubscriberConstants { //================================================================================================= diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/constants/SubscriberDefaults.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/constants/SubscriberDefaults.java similarity index 89% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/constants/SubscriberDefaults.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/constants/SubscriberDefaults.java index a658728..98b8490 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/constants/SubscriberDefaults.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/constants/SubscriberDefaults.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.constants; +package eu.arrowhead.application.skeleton.subscriber.constants; public class SubscriberDefaults { diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/controller/SubscriberController.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/controller/SubscriberController.java similarity index 82% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/controller/SubscriberController.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/controller/SubscriberController.java index c7e14dd..5c0e906 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/controller/SubscriberController.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/controller/SubscriberController.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.controller; +package eu.arrowhead.application.skeleton.subscriber.controller; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,8 +8,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import eu.arrowhead.client.skeleton.subscriber.constants.SubscriberConstants; -import eu.arrowhead.client.skeleton.subscriber.constants.SubscriberDefaults; +import eu.arrowhead.application.skeleton.subscriber.constants.SubscriberConstants; +import eu.arrowhead.application.skeleton.subscriber.constants.SubscriberDefaults; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.dto.shared.EventDTO; @@ -36,7 +36,7 @@ public String echoService() { public void receivePublisherReceivedRequestEvent(@RequestBody final EventDTO event ) { logger.debug("receivePublisherReceivedRequestEvent started..."); - if( event.getEventType() == null) { + if (event.getEventType() == null) { logger.debug("EventType is null."); } @@ -45,10 +45,10 @@ public void receivePublisherReceivedRequestEvent(@RequestBody final EventDTO eve //------------------------------------------------------------------------------------------------- @PostMapping(path = SubscriberConstants.START_INIT_NOTIFICATION_URI) - public void receivePublsisherStartedInitEvent(@RequestBody final EventDTO event) { + public void receivePublisherStartedInitEvent(@RequestBody final EventDTO event) { logger.debug("receivePublsisherStartedInitEvent started... "); - if( event.getEventType() == null) { + if (event.getEventType() == null) { logger.debug("EventType is null."); } @@ -57,10 +57,10 @@ public void receivePublsisherStartedInitEvent(@RequestBody final EventDTO event) //------------------------------------------------------------------------------------------------- @PostMapping(path = SubscriberConstants.START_RUN_NOTIFICATION_URI) - public void receivePublsisherStartedRunEvent(@RequestBody final EventDTO event ) { + public void receivePublisherStartedRunEvent(@RequestBody final EventDTO event ) { logger.debug("receivePublsisherStartedRunEvent started... "); - if( event.getEventType() == null) { + if (event.getEventType() == null) { logger.debug("EventType is null."); } @@ -69,4 +69,4 @@ public void receivePublsisherStartedRunEvent(@RequestBody final EventDTO event ) //------------------------------------------------------------------------------------------------- //TODO: implement here additional subscriber related REST end points -} +} \ No newline at end of file diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberAccessControlFilter.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberAccessControlFilter.java similarity index 77% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberAccessControlFilter.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberAccessControlFilter.java index dbd207c..a526a5e 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberAccessControlFilter.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberAccessControlFilter.java @@ -1,16 +1,16 @@ -package eu.arrowhead.client.skeleton.subscriber.security; +package eu.arrowhead.application.skeleton.subscriber.security; import java.util.Map; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; -import eu.arrowhead.client.library.util.ClientCommonConstants; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.security.AccessControlFilter; @Component -@ConditionalOnExpression(CommonConstants.$SERVER_SSL_ENABLED_WD + " and !" + ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) +@ConditionalOnExpression(CommonConstants.$SERVER_SSL_ENABLED_WD + " and !" + ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) public class SubscriberAccessControlFilter extends AccessControlFilter { @Override diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberNotificationAccessControlFilter.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberNotificationAccessControlFilter.java similarity index 93% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberNotificationAccessControlFilter.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberNotificationAccessControlFilter.java index ab21e18..7797698 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberNotificationAccessControlFilter.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberNotificationAccessControlFilter.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.security; +package eu.arrowhead.application.skeleton.subscriber.security; import java.io.IOException; import java.security.cert.X509Certificate; @@ -13,7 +13,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.Assert; -import eu.arrowhead.client.skeleton.subscriber.constants.SubscriberDefaults; +import eu.arrowhead.application.skeleton.subscriber.constants.SubscriberDefaults; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.core.CoreSystem; @@ -26,7 +26,7 @@ public class SubscriberNotificationAccessControlFilter extends ArrowheadFilter { //================================================================================================= // members - private static final CoreSystem[] allowedCoreSystemsForSendingNotification = { CoreSystem.EVENT_HANDLER }; + private static final CoreSystem[] allowedCoreSystemsForSendingNotification = { CoreSystem.EVENTHANDLER }; private Map eventTypeMap; private String serverCN; @@ -39,9 +39,6 @@ public class SubscriberNotificationAccessControlFilter extends ArrowheadFilter { public void setEventTypeMap( final Map eventTypeMap) { this.eventTypeMap = eventTypeMap;} public void setServerCN( final String serverCN) { this.serverCN = serverCN; } - //================================================================================================= - // assistant methods - //------------------------------------------------------------------------------------------------- @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { @@ -53,7 +50,7 @@ public void doFilter(final ServletRequest request, final ServletResponse respons if (eventTypeMap != null) { for (final String notificationUri : eventTypeMap.values()) { - if (requestTarget.endsWith( SubscriberDefaults.DEFAULT_EVENT_NOTIFICATION_BASE_URI + "/" + notificationUri )) { + if (requestTarget.endsWith(SubscriberDefaults.DEFAULT_EVENT_NOTIFICATION_BASE_URI + "/" + notificationUri)) { checkIfClientIsAnAllowedCoreSystem(getCertificateCNFromRequest(httpRequest), getServerCloudCN(serverCN), allowedCoreSystemsForSendingNotification, requestTarget); } } @@ -65,6 +62,9 @@ public void doFilter(final ServletRequest request, final ServletResponse respons chain.doFilter(request, response); } + //================================================================================================= + // assistant methods + //------------------------------------------------------------------------------------------------- @Nullable private String getCertificateCNFromRequest(final HttpServletRequest request) { @@ -108,4 +108,4 @@ protected String getServerCloudCN( final String serverCN ) { return serverFields[1]; } -} +} \ No newline at end of file diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberSecurityConfig.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberSecurityConfig.java similarity index 87% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberSecurityConfig.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberSecurityConfig.java index 41f0013..edce22c 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberSecurityConfig.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberSecurityConfig.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.security; +package eu.arrowhead.application.skeleton.subscriber.security; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -6,8 +6,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter; -import eu.arrowhead.client.library.config.DefaultSecurityConfig; -import eu.arrowhead.client.library.util.ClientCommonConstants; +import ai.aitia.arrowhead.application.library.config.DefaultSecurityConfig; +import ai.aitia.arrowhead.application.library.util.ApplicationCommonConstants; import eu.arrowhead.common.CommonConstants; @Configuration @@ -17,7 +17,7 @@ public class SubscriberSecurityConfig extends DefaultSecurityConfig { //================================================================================================= // members - @Value(ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) + @Value(ApplicationCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) private boolean tokenSecurityFilterEnabled; @Value(CommonConstants.$SERVER_SSL_ENABLED_WD) @@ -35,16 +35,13 @@ protected void configure( final HttpSecurity http) throws Exception { super.configure(http); if (sslEnabled) { - notificationFilter = new SubscriberNotificationAccessControlFilter(); http.addFilterBefore( notificationFilter , SecurityContextHolderAwareRequestFilter.class ); - if (tokenSecurityFilterEnabled) { tokenSecurityFilter = new SubscriberTokenSecurityFilter(); http.addFilterAfter(tokenSecurityFilter, SecurityContextHolderAwareRequestFilter.class); } - } } @@ -57,5 +54,4 @@ public SubscriberTokenSecurityFilter getTokenSecurityFilter() { public SubscriberNotificationAccessControlFilter getNotificationFilter() { return notificationFilter; } - -} +} \ No newline at end of file diff --git a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberTokenSecurityFilter.java b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberTokenSecurityFilter.java similarity index 93% rename from client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberTokenSecurityFilter.java rename to application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberTokenSecurityFilter.java index 89f590e..d0ae1b3 100644 --- a/client-skeleton-subscriber/src/main/java/eu/arrowhead/client/skeleton/subscriber/security/SubscriberTokenSecurityFilter.java +++ b/application-skeleton-subscriber/src/main/java/eu/arrowhead/application/skeleton/subscriber/security/SubscriberTokenSecurityFilter.java @@ -1,4 +1,4 @@ -package eu.arrowhead.client.skeleton.subscriber.security; +package eu.arrowhead.application.skeleton.subscriber.security; import java.io.IOException; import java.security.PrivateKey; @@ -14,7 +14,7 @@ import org.springframework.lang.Nullable; -import eu.arrowhead.client.skeleton.subscriber.constants.SubscriberDefaults; +import eu.arrowhead.application.skeleton.subscriber.constants.SubscriberDefaults; import eu.arrowhead.common.CommonConstants; import eu.arrowhead.common.Utilities; import eu.arrowhead.common.exception.ArrowheadException; @@ -72,7 +72,7 @@ public void doFilter(final ServletRequest request, final ServletResponse respons if (eventTypeMap != null) { for (final String notificationUri : eventTypeMap.values()) { - if ( requestTarget.endsWith(SubscriberDefaults.DEFAULT_EVENT_NOTIFICATION_BASE_URI + "/" + notificationUri)) { + if (requestTarget.endsWith(SubscriberDefaults.DEFAULT_EVENT_NOTIFICATION_BASE_URI + "/" + notificationUri)) { chain.doFilter(request, response); return; } @@ -92,7 +92,6 @@ public void doFilter(final ServletRequest request, final ServletResponse respons } checkToken(clientCN, token, requestTarget); - } catch (final ArrowheadException ex) { handleException(ex, response); } @@ -112,5 +111,4 @@ private String getCertificateCNFromRequest(final HttpServletRequest request) { return null; } - -} +} \ No newline at end of file diff --git a/client-skeleton-subscriber/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/application-skeleton-subscriber/src/main/resources/META-INF/additional-spring-configuration-metadata.json similarity index 100% rename from client-skeleton-subscriber/src/main/resources/META-INF/additional-spring-configuration-metadata.json rename to application-skeleton-subscriber/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/client-skeleton-subscriber/src/main/resources/application.properties b/application-skeleton-subscriber/src/main/resources/application.properties similarity index 90% rename from client-skeleton-subscriber/src/main/resources/application.properties rename to application-skeleton-subscriber/src/main/resources/application.properties index 792e5ac..40eee24 100644 --- a/client-skeleton-subscriber/src/main/resources/application.properties +++ b/application-skeleton-subscriber/src/main/resources/application.properties @@ -3,7 +3,7 @@ ############################################ # Name of the client system -client_system_name=SUBSCRIBER_SKELETON +application_system_name=SUBSCRIBERSKELETON # Client web-server parameters server.address=127.0.0.1 @@ -38,9 +38,9 @@ server.ssl.enabled=true token.security.filter.enabled=true server.ssl.key-store-type=PKCS12 -server.ssl.key-store=classpath:certificates/subscriber_skeleton.p12 +server.ssl.key-store=classpath:certificates/subscriberskeleton.p12 server.ssl.key-store-password=123456 -server.ssl.key-alias=subscriber_skeleton +server.ssl.key-alias=subscriberskeleton server.ssl.key-password=123456 server.ssl.client-auth=need server.ssl.trust-store-type=PKCS12 diff --git a/application-skeleton-subscriber/src/main/resources/certificates/subscriberskeleton.p12 b/application-skeleton-subscriber/src/main/resources/certificates/subscriberskeleton.p12 new file mode 100644 index 0000000..2408400 Binary files /dev/null and b/application-skeleton-subscriber/src/main/resources/certificates/subscriberskeleton.p12 differ diff --git a/client-skeleton-subscriber/src/main/resources/certificates/truststore.p12 b/application-skeleton-subscriber/src/main/resources/certificates/truststore.p12 similarity index 100% rename from client-skeleton-subscriber/src/main/resources/certificates/truststore.p12 rename to application-skeleton-subscriber/src/main/resources/certificates/truststore.p12 diff --git a/client-skeleton-consumer/src/main/resources/certificates/consumer_skeleton.p12 b/client-skeleton-consumer/src/main/resources/certificates/consumer_skeleton.p12 deleted file mode 100644 index 3d4b8b6..0000000 Binary files a/client-skeleton-consumer/src/main/resources/certificates/consumer_skeleton.p12 and /dev/null differ diff --git a/client-skeleton-provider/src/main/resources/certificates/provider_skeleton.p12 b/client-skeleton-provider/src/main/resources/certificates/provider_skeleton.p12 deleted file mode 100644 index 21a0627..0000000 Binary files a/client-skeleton-provider/src/main/resources/certificates/provider_skeleton.p12 and /dev/null differ diff --git a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherAccessControlFilter.java b/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherAccessControlFilter.java deleted file mode 100644 index c6aaf88..0000000 --- a/client-skeleton-publisher/src/main/java/eu/arrowhead/client/skeleton/publisher/security/PublisherAccessControlFilter.java +++ /dev/null @@ -1,22 +0,0 @@ -package eu.arrowhead.client.skeleton.publisher.security; - -import java.util.Map; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; -import org.springframework.stereotype.Component; - -import eu.arrowhead.client.library.util.ClientCommonConstants; -import eu.arrowhead.common.CommonConstants; -import eu.arrowhead.common.security.AccessControlFilter; - -@Component -@ConditionalOnExpression(CommonConstants.$SERVER_SSL_ENABLED_WD + " and !" + ClientCommonConstants.$TOKEN_SECURITY_FILTER_ENABLED_WD) -public class PublisherAccessControlFilter extends AccessControlFilter { - -@Override -protected void checkClientAuthorized(final String clientCN, final String method, final String requestTarget, final String requestJSON, final Map queryParams) { - super.checkClientAuthorized(clientCN, method, requestTarget, requestJSON, queryParams); - - //TODO: implement here your custom access filter if any further -} -} diff --git a/client-skeleton-publisher/src/main/resources/certificates/publisher_skeleton.p12 b/client-skeleton-publisher/src/main/resources/certificates/publisher_skeleton.p12 deleted file mode 100644 index 3a5840d..0000000 Binary files a/client-skeleton-publisher/src/main/resources/certificates/publisher_skeleton.p12 and /dev/null differ diff --git a/client-skeleton-subscriber/src/main/resources/certificates/subscriber_skeleton.p12 b/client-skeleton-subscriber/src/main/resources/certificates/subscriber_skeleton.p12 deleted file mode 100644 index f5f9681..0000000 Binary files a/client-skeleton-subscriber/src/main/resources/certificates/subscriber_skeleton.p12 and /dev/null differ diff --git a/pom.xml b/pom.xml index f5e0324..01304cb 100644 --- a/pom.xml +++ b/pom.xml @@ -9,32 +9,32 @@ eu.arrowhead - client-skeleton - 4.1.3.3 + application-skeleton-java-spring + 4.4.0.0 pom - client-skeleton-java-spring - Arrowhead Client Skeleton using Spring Boot + application-skeleton-java-spring + Arrowhead Application Skeleton using Spring Boot https://github.com/arrowhead-f/client-java-spring - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt + Eclipse Public License - v 2.0 + https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt - client-skeleton-consumer - client-skeleton-provider - client-skeleton-subscriber - client-skeleton-publisher + application-skeleton-consumer + application-skeleton-provider + application-skeleton-subscriber + application-skeleton-publisher - + - eu.arrowhead - client-library - 4.1.3.13 + ai.aitia + arrowhead-application-library-java-spring + 4.4.0.0