You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
##### The project provides application skeletons for the Arrowhead Framework
3
3
4
-
### How to use client skeletons?
4
+
### How to use application skeletons?
5
5
6
6
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))
7
7
@@ -10,34 +10,33 @@ Fork this repo and extend the skeletons with your own application code. ([check
10
10
The project has the following dependencies:
11
11
* JRE/JDK 11 [Download from here](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html)
12
12
* Maven 3.5+ [Download from here](http://maven.apache.org/download.cgi) | [Install guide](https://www.baeldung.com/install-maven-on-windows-linux-mac)
13
-
* 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)
14
13
15
14
### Project structure
16
15
17
16
This is a multi-module maven project relying on the [parent `pom.xml`](https://github.com/arrowhead-f/client-skeleton-java-spring/blob/master/pom.xml) which lists all the modules and common dependencies.
18
17
19
18
##### Modules:
20
19
21
-
***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.
20
+
***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.
22
21
23
-
***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.
22
+
***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.
24
23
25
-
***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.
24
+
***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.
26
25
27
-
***client-skeleton-publisher**: client publisher module with the purpose of publishing events into the Event Handler.
26
+
***application-skeleton-publisher**: application publisher module with the purpose of publishing events into the Event Handler.
28
27
29
-
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.)*
28
+
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.)*
30
29
31
-
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.
30
+
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.
32
31
33
32
### Best practices to start with the skeletons
34
33
35
34
##### (1st) application.properties
36
35
Location: `src/main/resources`
37
-
**Decide the required security level and set the `server.ssl.enabled` and `token.security.filter.enabled` properties accordingly.
38
-
**If `token.security.filter.enabled` is true, `server.ssl.enabled` also has to be true !!!
36
+
* Decide the required security level and set the `server.ssl.enabled` and `token.security.filter.enabled` properties accordingly.
37
+
* If `token.security.filter.enabled` is true, `server.ssl.enabled` also has to be true !!!
39
38
*[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.)*
40
-
* 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`)*
39
+
* 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`)*
41
40
* Adjust the Service Registry Core System location by the `sr_address` and `sr_port` properties.
42
41
* In case of a provider you have to set its web-server parameters by the `server.address` and `server.port` properties.
43
42
* 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
52
51
* 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)*.
53
52
54
53
##### (3rd) security configuration
55
-
The skeletons provide a built-in arrowhed framework compatible security configuration located in `eu.arrowhead.client.skeleton.consumer|provider.security` package.
56
-
* 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.)*
57
-
* 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`.
54
+
The skeletons provide a built-in arrowhed framework compatible security configuration located in `eu.arrowhead.application.skeleton.consumer|provider.security` package.
55
+
* 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.)*
56
+
* 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`.
58
57
- `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.)*
59
58
- `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.)*
60
59
- `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
63
62
* 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.)*
64
63
65
64
##### (4th) start-up & shutdown configuration
66
-
The skeletons provide a built-in application start-up and shutdown configuration located in `eu.arrowhead.client.skeleton.consumer|provider` package.
65
+
The skeletons provide a built-in application start-up and shutdown configuration located in `eu.arrowhead.application.skeleton.consumer|provider` package.
67
66
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.)*
Copy file name to clipboardExpand all lines: application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/ConsumerApplicationInitListener.java
Copy file name to clipboardExpand all lines: application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerAccessControlFilter.java
Copy file name to clipboardExpand all lines: application-skeleton-consumer/src/main/java/eu/arrowhead/application/skeleton/consumer/security/ConsumerSecurityConfig.java
0 commit comments