Skip to content

Commit

Permalink
Adds options to connect to Authorized HTTP Consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedJannik committed Jul 10, 2024
1 parent 53ae939 commit 63afc36
Show file tree
Hide file tree
Showing 12 changed files with 531 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@
*/
public class HttpPollingConsumerConfiguration extends DataSourceConfiguration {
public HttpPollingConsumerConfiguration() {}
private String authUsername;
private String authPassword;

public HttpPollingConsumerConfiguration(String uniqueId, String serverUrl, int serverPort) {
public HttpPollingConsumerConfiguration(String uniqueId, String serverUrl, int serverPort, String authUsername, String authPassword) {
super(uniqueId, serverUrl, serverPort);
this.authUsername = authUsername;
this.authPassword = authPassword;
}

@Override
public String getConnectionURI() {

if(!(authUsername == null || authPassword == null)) {
String dataSourceServerUrl = getServerUrl();
return dataSourceServerUrl + (dataSourceServerUrl.contains("?")? "&" : "?") + "authUsername=" + authUsername + "&authPassword=" + authPassword+"&authMethod=Basic&authenticationPreemptive=true";
}

return getServerUrl();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>databridge.examples</artifactId>
<version>${revision}</version>
</parent>

<artifactId>httppolling-auth-jsonata-aas</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>databridge.core</artifactId>
<version>${revision}</version>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>databridge.camel-aas</artifactId>
<version>0.0.1-SNAPSHOT</version>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>databridge.camel-httppolling</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>databridge.camel-jsonata</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>databridge.camel-timer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JUnit 4 for running JUnit tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>5.13.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-client-java</artifactId>
<version>5.13.2</version>

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.submodelrepository.component</artifactId>
<version>2.0.0-milestone-02</version>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.submodelrepository-backend-inmemory</artifactId>
<version>2.0.0-milestone-02</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.6</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# #############################
# AAS Server configuration file
# #############################

# #############################
# Backend
# #############################
# Specifies the backend that loads the AAS and Submodels

# InMemory - does not persist AAS or submodels
aas.backend=InMemory

# MongoDB - persists data within a MongoDB
# See connection configuration in mongodb.properties
# aas.backend=MongoDB

# #############################
# Source
# #############################
# Possible to load an AAS Environment from a file

aas.source=

# Other examples (Currently supported: *.xml, *.json and *.aasx):
# aas.source=aasx/myAAS.aasx
# aas.source=aasx/myAAS.xml
# aas.source=aasx/myAAS.json
# Or when encapsulated in the docker volume for this container:
# aas.source=/usr/share/config/myAAS.aasx

# #############################
# MQTT
# #############################
# Possible to enable MQTT events

aas.events=NONE
# aas.events=MQTT

# #############################
# AASX Upload
# #############################
# Possible to enable AASX Upload

aas.aasxUpload=Disabled
# aas.aasxUpload=Enabled


# #############################
# Registry
# #############################
# If specified, can directly registers the AAS that has been loaded from the source file

# Path specifies the registry endpoint
# registry.path=http://localhost:4000/registry/

# Hostpath specifies the endpoint of the deployed AAS component
# If hostpath is empty, the registered AAS endpoint is derived from the context properties
# registry.hostpath=

# If one or more submodels are specified here, only the submodels will be registered at the
# registry. This can be used for distributed submodel deployments
# In case of an empty or no list, this does not have an effect. By default, all submodels
# are registered at a given registry.
# registry.submodels=["smId1","smId2"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"uniqueId": "SubmodelSink1",
"submodelEndpoint": "http://localhost:4001/submodels/aHR0cHM6Ly9leGFtcGxlLmNvbS9pZHMvU3VibW9kZWwvMzE3NV80MTMxXzc2MzFfMzQ5Mw",
"idShortPath": "intProperty",
"api": "DotAAS-V3"
},
{
"uniqueId": "SubmodelSink2",
"submodelEndpoint": "http://localhost:4001/submodels/aHR0cHM6Ly9leGFtcGxlLmNvbS9pZHMvU3VibW9kZWwvMzE3NV80MTMxXzc2MzFfMzQ5Mw",
"idShortPath": "stringProperty",
"api": "DotAAS-V3"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"uniqueId": "httpsource1",
"serverUrl": "http://127.0.0.1:8070/value1",
"authUsername": "demoUsername",
"authPassword": "demoPassword"
},
{
"uniqueId": "httpsource2",
"serverUrl": "http://127.0.0.1:8070/value2",
"authUsername": "demoUsername",
"authPassword": "demoPassword"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"uniqueId": "jsonataA",
"queryPath": "jsonataA.json",
"inputType": "JsonString",
"outputType": "JsonString"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"datasource": "httpsource1",
"transformers": ["jsonataA"],
"datasinks": ["SubmodelSink1"],
"trigger": "timer",
"triggerData" : {
"timerName": "timer1"
}
},
{
"datasource": "httpsource2",
"transformers": ["jsonataA"],
"datasinks": ["SubmodelSink2"],
"trigger": "timer",
"triggerData" : {
"timerName": "timer1"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"uniqueId": "timer1",
"fixedRate": true,
"delay": 0,
"period": 5000
}
]
Loading

0 comments on commit 63afc36

Please sign in to comment.