Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
522b7ef
fixing alias
rbocsi Mar 17, 2021
d36b6b2
no underscores in system names (and cloud names and operators) anymore
rbocsi Apr 9, 2021
c9a740d
Merge branch 'development' into 4.4-issues
borditamas Apr 9, 2021
d6460b8
Merge branch 'development' into common-name-issue
borditamas Apr 9, 2021
37530bb
adjust skeletons to changes in constants and enums
rbocsi Apr 19, 2021
d23b189
Merge remote-tracking branch 'remotes/origin/development' into sr-db-…
rbocsi Apr 20, 2021
de1ba6b
upgrade to client-library v4.3.0.0
borditamas Apr 20, 2021
74224fa
Merge branch 'development' into 4.4-issues
borditamas Jul 20, 2021
a7291fd
Merge pull request #20 from arrowhead-f/4.4-issues
borditamas Jul 20, 2021
c8e7898
Merge branch 'development' into common-name-issue
borditamas Jul 20, 2021
0252eba
Merge pull request #21 from arrowhead-f/common-name-issue
borditamas Jul 20, 2021
35d8390
Merge branch 'development' into sr-db-constaint-change
borditamas Jul 20, 2021
09faab2
Merge pull request #23 from arrowhead-f/sr-db-constaint-change
borditamas Jul 20, 2021
b8accfb
Update README.md
borditamas Jul 20, 2021
21db0c5
change client to application
borditamas Jul 20, 2021
77c1a79
Update README.md
borditamas Jul 21, 2021
04caef4
check configuration
borditamas Sep 1, 2021
b9b3893
check configuration change log level to warn
borditamas Sep 1, 2021
8f792b1
Merge pull request #27 from arrowhead-f/bug-fixing
borditamas Sep 1, 2021
65bccbc
add missing base package to component scan
borditamas Nov 9, 2021
c2619d9
change to arrowhead-application-library-java-spring v4.4.0.0 release
borditamas Nov 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>client</name>
<name>application-skeleton</name>
<comment></comment>
<projects>
</projects>
Expand Down
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -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))

Expand All @@ -10,34 +10,33 @@ Fork this repo and extend the skeletons with your own application code. ([check
The project has the following dependencies:
Comment thread
borditamas marked this conversation as resolved.
* 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

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.

##### 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.
Expand All @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path=".apt_generated_tests">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>client-skeleton-consumer</name>
<name>arrowhead-application-skeleton-consumer</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>eu.arrowhead</groupId>
<artifactId>client-skeleton</artifactId>
<version>4.1.3.3</version>
<groupId>eu.arrowhead</groupId>
<artifactId>application-skeleton-java-spring</artifactId>
<version>4.4.0.0</version>
</parent>

<artifactId>arrowhead-client-skeleton-consumer</artifactId>
<artifactId>arrowhead-application-skeleton-consumer</artifactId>
<name>Arrowhead Consumer Skeleton</name>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package eu.arrowhead.client.skeleton.consumer;
package eu.arrowhead.application.skeleton.consumer;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
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
Expand All @@ -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);


Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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 {

//=================================================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.arrowhead.client.skeleton.consumer.security;
package eu.arrowhead.application.skeleton.consumer.security;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,16 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path=".apt_generated_tests">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>client-skeleton-provider</name>
<name>arrowhead-application-skeleton-provider</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>eu.arrowhead</groupId>
<artifactId>client-skeleton</artifactId>
<version>4.1.3.3</version>
<groupId>eu.arrowhead</groupId>
<artifactId>application-skeleton-java-spring</artifactId>
<version>4.4.0.0</version>
</parent>

<artifactId>arrowhead-client-skeleton-provider</artifactId>
<artifactId>arrowhead-application-skeleton-provider</artifactId>
<name>Arrowhead Provider Skeleton</name>

<build>
Expand Down
Loading