Remove swagger and minor feature extensions and bug fixes
- Various Bug fixes and improvements - Management API extended - Swagger removed - Guava Upgraded to 19
This commit is contained in:
10
.gitattributes
vendored
Normal file
10
.gitattributes
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
* text eol=lf
|
||||||
|
# Denote all files that are truly binary and should not be modified.
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.pdf binary
|
||||||
|
*.PNG binary
|
||||||
|
*.pptx binary
|
||||||
|
*.eot binary
|
||||||
|
*.ttf binary
|
||||||
|
*.woff binary
|
||||||
50
.gitignore
vendored
Normal file
50
.gitignore
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Directories #
|
||||||
|
/build/
|
||||||
|
/*/build/
|
||||||
|
/bin/
|
||||||
|
/*/bin/
|
||||||
|
/target/
|
||||||
|
/*/target/
|
||||||
|
/*/*/target/
|
||||||
|
|
||||||
|
# OS Files #
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
|
||||||
|
# Eclipse IDE
|
||||||
|
|
||||||
|
*.pydevproject
|
||||||
|
.project
|
||||||
|
.metadata
|
||||||
|
bin/**
|
||||||
|
tmp/**
|
||||||
|
tmp/**/*
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# CDT-specific
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# PDT-specific
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
# Maven
|
||||||
|
maven.properties
|
||||||
|
/*/maven.properties
|
||||||
0
3rd-dependencies/compile.txt
Executable file → Normal file
0
3rd-dependencies/compile.txt
Executable file → Normal file
0
3rd-dependencies/provided.txt
Executable file → Normal file
0
3rd-dependencies/provided.txt
Executable file → Normal file
0
3rd-dependencies/test.txt
Executable file → Normal file
0
3rd-dependencies/test.txt
Executable file → Normal file
0
CONTRUBUTING.md
Executable file → Normal file
0
CONTRUBUTING.md
Executable file → Normal file
127
DMFA.md
Normal file
127
DMFA.md
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
# !!! DRAFT !!! #
|
||||||
|
# Device Management Federation API #
|
||||||
|
|
||||||
|
This document describes the **DMF API**. This API is based on AMQP [(AMQP-Specification)](ht1tp://www.amqp.org/sites/amqp.org/files/amqp.pdf "AMQP-Specification"). The SP Update server provides a message queue (default: "*dmf_receiver*") on the corresponding Rabbit MQ service, which accepts all incoming messages.
|
||||||
|
|
||||||
|
Every Service, which wants to communicate, has to offer a own queue, to which the SP update server can send messages. The name of this queue is sent
|
||||||
|
|
||||||
|
## Authentication ##
|
||||||
|
???
|
||||||
|
|
||||||
|
## Regular update process ##
|
||||||
|
|
||||||
|
### Step 1: Creating a Thing on SP ###
|
||||||
|
|
||||||
|
At the beginning every connecting service has to register its targets at the Sp update server. During the creating process the service has to send the name of the queue, which accepts messages, which are sent back from the Sp update server.
|
||||||
|
|
||||||
|
The message which is sent by the connecting service to the SP update service has to fulfill the following format. The connecting service has to set the attributes in the header. The name of the tenent (*tenant*, an unique identifier of the thing/target (*thingId*) and an string which identifies the sending service (*sender*). Furthermore it has to set the *replyTo*-Property which defines the name of the queue, which receives messages sent by the SP Update Server. The body of the message is not analyzed and can be empty.
|
||||||
|
|
||||||
|
**Header**
|
||||||
|
<pre>
|
||||||
|
type=THING_CREATED
|
||||||
|
tenant=<b>#TENANTNAME#</b>
|
||||||
|
thingId=<b>#ExampleDevice001#</b>
|
||||||
|
sender=<b>#CONNECTORSERVICE#</b>
|
||||||
|
</pre>
|
||||||
|
**Properties**
|
||||||
|
<pre>
|
||||||
|
contentType=application/json
|
||||||
|
replyTo=<b>#queue.which.accepts.messages.from.sp#</b>
|
||||||
|
</pre>
|
||||||
|
**Example Body**
|
||||||
|
<pre> </pre>
|
||||||
|
|
||||||
|
### Step 2: Begin of update process ###
|
||||||
|
Afterwards an distribution set can be assigned to the created thing. This can be done on the UI or with the REST API. To start the update process the SP update server sends a message over the registered queue back to the connecting service.
|
||||||
|
|
||||||
|
Inside the message send from the Sp update service the header specifies the target which has to be updated. Therefor the *tenent* and the unique *thingId* are used. The body contains an identifier which defines the update process (*actionId*) and the information of the software modules. The *actionId* is important to send the progress of the update process to the server. The information about the software describes all modules which are included in the current update process, their identifier, their type, their version and the corresponding artifacts with the urls where the target can download the artifacts.
|
||||||
|
|
||||||
|
**Header**
|
||||||
|
<pre>
|
||||||
|
type=EVENT
|
||||||
|
tenant=<b>#TENANTNAME#</b>
|
||||||
|
thingId=<b>#ExampleDevice001#</b>
|
||||||
|
topic=DOWNLOAD_AND_INSTALL
|
||||||
|
</pre>
|
||||||
|
**Properties**
|
||||||
|
<pre>
|
||||||
|
contentType=application/json
|
||||||
|
</pre>
|
||||||
|
**Example Body**
|
||||||
|
<pre>
|
||||||
|
{
|
||||||
|
"actionId":172,
|
||||||
|
"softwareModules":[
|
||||||
|
{
|
||||||
|
"moduleId":6,
|
||||||
|
"moduleType":"firmware",
|
||||||
|
"moduleVersion":"7.7.7",
|
||||||
|
"artifacts":[
|
||||||
|
{
|
||||||
|
"urls":{
|
||||||
|
"coap":"coap://bumlux.test",
|
||||||
|
"http":"coap://bumlux.test"}
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
### Step 3: Sending the state update process <a name="sendingactionstate"></a>###
|
||||||
|
|
||||||
|
During the update progress the connected service can inform the sp update service about the progress and eventual warnings or errors. Therefore the *actionId* and the *softwareModuleId* are used to specify for which process and for which software module the progress update is for. Additionally in the Body there is a field *actionStatus*. This field is used to describe the type of the progress update and there are several allowed values:
|
||||||
|
|
||||||
|
- **RETRIEVED**: general acknowledge message
|
||||||
|
- **DOWNLOAD**: describes all messages related to the download prorgess
|
||||||
|
- **RUNNING**:
|
||||||
|
- **WARNING**: A smaller problem which influence the update process, but no need for stop it.
|
||||||
|
- **ERROR**: A big issues which not allows continuing the update process.
|
||||||
|
- **FINISHED**: Successfully finished the update process.
|
||||||
|
- **CANCELED**: Response to a cancel request, when the process is canceled.
|
||||||
|
- **CANCEL_REJECTED**: Response to a cancel request, when canceling is not possible.
|
||||||
|
|
||||||
|
The update process is marked as running until the connected Server sends a **FINISHED**, an **ERROR** or a **CANCELED** message. Additionally the connected service can put some human readable information into the message, which describes the state of the action more detailed.
|
||||||
|
|
||||||
|
**Header**
|
||||||
|
<pre>
|
||||||
|
type=EVENT
|
||||||
|
tenant=<b>#TENANTNAME#</b>
|
||||||
|
topic=UPDATE_ACTION_STATUS
|
||||||
|
</pre>
|
||||||
|
**Properties**
|
||||||
|
<pre>
|
||||||
|
contentType=application/json
|
||||||
|
</pre>
|
||||||
|
**Example Body**
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{
|
||||||
|
"actionId":115,
|
||||||
|
"softwareModuleId":3,
|
||||||
|
"actionStatus":"DOWNLOAD",
|
||||||
|
"message":["The download has started"]
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
## Cancel process ##
|
||||||
|
|
||||||
|
During the update process the SP update server has the chance to cancel an update. Therefore it sends the following message. This message includes the *tenant* and the corresponding *thingId* on theheader.
|
||||||
|
|
||||||
|
**Header**
|
||||||
|
<pre>
|
||||||
|
type=EVENT
|
||||||
|
tenant=<b>#TENANTNAME#</b>
|
||||||
|
thingId=<b>#ExampleDevice001#</b>
|
||||||
|
topic=CANCEL_DOWNLOAD
|
||||||
|
</pre>
|
||||||
|
**Properties**
|
||||||
|
<pre>
|
||||||
|
contentType=application/json
|
||||||
|
</pre>
|
||||||
|
**Example Body**
|
||||||
|
<pre>
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
Receiving this message the connected service has to decide if an update can be canceled or not. If it is the update has to be canceled and a **CANCELED** message has to be sent to the SP server. Otherwise a **CANCEL_REJECTED** message has to be sent.
|
||||||
|
|
||||||
|

|
||||||
0
LICENCE_HEADER_TEMPLATE.txt
Executable file → Normal file
0
LICENCE_HEADER_TEMPLATE.txt
Executable file → Normal file
2
README.md
Executable file → Normal file
2
README.md
Executable file → Normal file
@@ -33,4 +33,4 @@ mvn install
|
|||||||
# Device Integration
|
# Device Integration
|
||||||
There are two device integration APIs provided by the hawkbit update server.
|
There are two device integration APIs provided by the hawkbit update server.
|
||||||
* [Direct Device Integration API (HTTP)](DDIA.md)
|
* [Direct Device Integration API (HTTP)](DDIA.md)
|
||||||
* Device Management Federation API (AMQP)
|
* [Device Management Federation API (AMQP)](DMFA.md)
|
||||||
|
|||||||
0
circle.yml
Executable file → Normal file
0
circle.yml
Executable file → Normal file
0
eclipse_codeformatter.xml
Executable file → Normal file
0
eclipse_codeformatter.xml
Executable file → Normal file
0
examples/README.md
Executable file → Normal file
0
examples/README.md
Executable file → Normal file
0
examples/hawkbit-device-simulator/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-device-simulator/.gitignore
vendored
Executable file → Normal file
23
examples/hawkbit-device-simulator/README.md
Executable file → Normal file
23
examples/hawkbit-device-simulator/README.md
Executable file → Normal file
@@ -11,8 +11,29 @@ Or:
|
|||||||
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
The simulator has user authentication enabled by default. Default credentials:
|
||||||
|
* username : admin
|
||||||
|
* passwd : admin
|
||||||
|
|
||||||
|
This can be configured/disabled by spring boot properties
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
The device simulator exposes an REST-API which can be used to trigger device creation.
|
The device simulator exposes an REST-API which can be used to trigger device creation.
|
||||||
|
|
||||||
|
Optional parameters:
|
||||||
|
* name : name prefix simulated devices (default: "dmfSimulated"), followed by counter
|
||||||
|
* amount : number of simulated devices (default: 20, capped at: 4000)
|
||||||
|
* tenant : in a multi-tenenat ready hawkBit installation (default: "DEFAULT")
|
||||||
|
|
||||||
|
|
||||||
|
Example: for 20 simulated devices (default)
|
||||||
```
|
```
|
||||||
http://localhost:8083/start?amount=10
|
http://localhost:8083/start
|
||||||
|
```
|
||||||
|
|
||||||
|
Example: for 10 simulated devices that start with the name prefix "activeSim":
|
||||||
|
```
|
||||||
|
http://localhost:8083/start?amount=10&name=activeSim
|
||||||
```
|
```
|
||||||
|
|||||||
118
examples/hawkbit-device-simulator/pom.xml
Executable file → Normal file
118
examples/hawkbit-device-simulator/pom.xml
Executable file → Normal file
@@ -9,53 +9,81 @@
|
|||||||
http://www.eclipse.org/legal/epl-v10.html
|
http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
<artifactId>hawkbit-examples-parent</artifactId>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<project
|
<artifactId>hawkbit-device-simulator</artifactId>
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
<name>hawkBit :: Device Simulator</name>
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<description>Device Management Federation API based simulator</description>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
|
||||||
<artifactId>hawkbit-examples-parent</artifactId>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>hawkbit-device-simulator</artifactId>
|
<build>
|
||||||
<name>hawkBit :: Device Simulator</name>
|
<plugins>
|
||||||
<description>Device Management Federation API based simulator</description>
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${baseDir}</outputDirectory>
|
||||||
|
<addResources>false</addResources>
|
||||||
|
<mainClass>org.eclipse.hawkbit.simulator.DeviceSimulator</mainClass>
|
||||||
|
<layout>JAR</layout>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-dmf-api</artifactId>
|
<artifactId>hawkbit-dmf-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.amqp</groupId>
|
<groupId>org.springframework.amqp</groupId>
|
||||||
<artifactId>spring-rabbit</artifactId>
|
<artifactId>spring-rabbit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-security-web</artifactId>
|
||||||
<exclusions>
|
</dependency>
|
||||||
<exclusion>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
<artifactId>spring-security-config</artifactId>
|
||||||
</exclusion>
|
</dependency>
|
||||||
</exclusions>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<dependency>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<exclusions>
|
||||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
<exclusion>
|
||||||
</dependency>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<dependency>
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
<groupId>org.springframework.boot</groupId>
|
</exclusion>
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java
Executable file → Normal file
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java
Executable file → Normal file
@@ -20,6 +20,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class DeviceSimulator {
|
public class DeviceSimulator {
|
||||||
|
|
||||||
|
private DeviceSimulator() {
|
||||||
|
// utility class
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the Spring Boot Application.
|
* Start the Spring Boot Application.
|
||||||
*
|
*
|
||||||
|
|||||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java
Executable file → Normal file
18
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java
Executable file → Normal file
18
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java
Executable file → Normal file
@@ -48,7 +48,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create jackson message converter bean.
|
* Create jackson message converter bean.
|
||||||
*
|
*
|
||||||
* @return the jackson message converter
|
* @return the jackson message converter
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -60,7 +60,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the receiver queue from sp. Receive messages from sp.
|
* Create the receiver queue from sp. Receive messages from sp.
|
||||||
*
|
*
|
||||||
* @return the queue
|
* @return the queue
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -71,7 +71,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the recevier exchange. Sp send messages to this exchange.
|
* Create the recevier exchange. Sp send messages to this exchange.
|
||||||
*
|
*
|
||||||
* @return the exchange
|
* @return the exchange
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -83,7 +83,7 @@ public class AmqpConfiguration {
|
|||||||
* Create the Binding
|
* Create the Binding
|
||||||
* {@link AmqpConfiguration#receiverConnectorQueueFromSp()} to
|
* {@link AmqpConfiguration#receiverConnectorQueueFromSp()} to
|
||||||
* {@link AmqpConfiguration#exchangeQueueToConnector()}.
|
* {@link AmqpConfiguration#exchangeQueueToConnector()}.
|
||||||
*
|
*
|
||||||
* @return the binding and create the queue and exchange
|
* @return the binding and create the queue and exchange
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -93,7 +93,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create dead letter queue.
|
* Create dead letter queue.
|
||||||
*
|
*
|
||||||
* @return the queue
|
* @return the queue
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -103,7 +103,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the dead letter fanout exchange.
|
* Create the dead letter fanout exchange.
|
||||||
*
|
*
|
||||||
* @return the fanout exchange
|
* @return the fanout exchange
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -113,7 +113,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Binding deadLetterQueue to exchangeDeadLetter.
|
* Create the Binding deadLetterQueue to exchangeDeadLetter.
|
||||||
*
|
*
|
||||||
* @return the binding
|
* @return the binding
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -123,7 +123,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Listener factory.
|
* Returns the Listener factory.
|
||||||
*
|
*
|
||||||
* @return the {@link SimpleMessageListenerContainer} that gets used receive
|
* @return the {@link SimpleMessageListenerContainer} that gets used receive
|
||||||
* AMQP messages
|
* AMQP messages
|
||||||
*/
|
*/
|
||||||
@@ -136,7 +136,7 @@ public class AmqpConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getDeadLetterExchangeArgs() {
|
private Map<String, Object> getDeadLetterExchangeArgs() {
|
||||||
final Map<String, Object> args = new HashMap<String, Object>();
|
final Map<String, Object> args = new HashMap<>();
|
||||||
args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
|
args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|||||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java
Executable file → Normal file
2
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java
Executable file → Normal file
2
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java
Executable file → Normal file
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.simulator.amqp;
|
|||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.core.MessageProperties;
|
import org.springframework.amqp.core.MessageProperties;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,6 +49,7 @@ public abstract class SenderService extends MessageService {
|
|||||||
if (message == null) {
|
if (message == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
message.getMessageProperties().getHeaders().remove(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME);
|
||||||
rabbitTemplate.setExchange(adress);
|
rabbitTemplate.setExchange(adress);
|
||||||
rabbitTemplate.send(message);
|
rabbitTemplate.send(message);
|
||||||
}
|
}
|
||||||
|
|||||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java
Executable file → Normal file
12
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java
Executable file → Normal file
12
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java
Executable file → Normal file
@@ -131,11 +131,23 @@ public class SpReceiverService extends ReceiverService {
|
|||||||
DownloadAndUpdateRequest.class);
|
DownloadAndUpdateRequest.class);
|
||||||
final Long actionId = downloadAndUpdateRequest.getActionId();
|
final Long actionId = downloadAndUpdateRequest.getActionId();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1_000);
|
||||||
|
} catch (final InterruptedException e) {
|
||||||
|
LOGGER.error("Sleep interrupted", e);
|
||||||
|
}
|
||||||
|
|
||||||
spSenderService.sendActionStatusMessage(tenant, ActionStatus.RUNNING,
|
spSenderService.sendActionStatusMessage(tenant, ActionStatus.RUNNING,
|
||||||
"device Simulator retrieved update request. proceeding with simulation.", actionId);
|
"device Simulator retrieved update request. proceeding with simulation.", actionId);
|
||||||
|
|
||||||
final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId);
|
final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1_000);
|
||||||
|
} catch (final InterruptedException e) {
|
||||||
|
LOGGER.error("Sleep interrupted", e);
|
||||||
|
}
|
||||||
|
|
||||||
spSenderService.finishUpdateProcess(update, "Simulation complete!");
|
spSenderService.finishUpdateProcess(update, "Simulation complete!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java
Executable file → Normal file
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java
Executable file → Normal file
@@ -216,9 +216,7 @@ public class SpSenderService extends SenderService {
|
|||||||
|
|
||||||
private Message createActionStatusMessage(final SimulatedUpdate update, final String messageDescription,
|
private Message createActionStatusMessage(final SimulatedUpdate update, final String messageDescription,
|
||||||
final ActionStatus status) {
|
final ActionStatus status) {
|
||||||
final Message sendMessage = createActionStatusMessage(update.getTenant(), status, messageDescription,
|
return createActionStatusMessage(update.getTenant(), status, messageDescription, update.getActionId());
|
||||||
update.getActionId());
|
|
||||||
return sendMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
56
examples/hawkbit-device-simulator/src/main/resources/application.properties
Executable file → Normal file
56
examples/hawkbit-device-simulator/src/main/resources/application.properties
Executable file → Normal file
@@ -12,7 +12,7 @@
|
|||||||
# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here)
|
# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here)
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
## Configuration for RabbitMQ communication
|
## Configuration for RabbitMQ communication
|
||||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=sp_connector_receiver
|
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver
|
||||||
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
||||||
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
||||||
hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo
|
hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo
|
||||||
@@ -27,58 +27,6 @@ spring.rabbitmq.port=5672
|
|||||||
spring.rabbitmq.dynamic=true
|
spring.rabbitmq.dynamic=true
|
||||||
|
|
||||||
|
|
||||||
#disable expose jmx beans
|
|
||||||
spring.jmx.enabled=false
|
|
||||||
# the context path of the monitor spring actuator which offers following endpoints
|
|
||||||
# /autoconfig, /beans, /configprops, /dump, /env, /health, /info, /metrics, /mappings, /trace
|
|
||||||
management.context-path=/system
|
|
||||||
management.security.enabled=true
|
|
||||||
management.security.sessions=stateless
|
|
||||||
# ENDPOINTS
|
|
||||||
endpoints.autoconfig.id=autoconfig
|
|
||||||
endpoints.autoconfig.sensitive=true
|
|
||||||
endpoints.autoconfig.enabled=false
|
|
||||||
endpoints.beans.id=beans
|
|
||||||
endpoints.beans.sensitive=true
|
|
||||||
endpoints.beans.enabled=false
|
|
||||||
endpoints.configprops.id=configprops
|
|
||||||
endpoints.configprops.sensitive=true
|
|
||||||
endpoints.configprops.enabled=true
|
|
||||||
#endpoints.configprops.keys-to-sanitize=password,secret,key # suffix or regex
|
|
||||||
endpoints.dump.id=dump
|
|
||||||
endpoints.dump.sensitive=true
|
|
||||||
endpoints.dump.enabled=false
|
|
||||||
endpoints.env.id=env
|
|
||||||
endpoints.env.sensitive=true
|
|
||||||
endpoints.env.enabled=true
|
|
||||||
#endpoints.env.keys-to-sanitize=password,secret,key # suffix or regex
|
|
||||||
endpoints.health.id=health
|
|
||||||
endpoints.health.sensitive=true
|
|
||||||
endpoints.health.enabled=true
|
|
||||||
endpoints.info.id=info
|
|
||||||
endpoints.info.sensitive=true
|
|
||||||
endpoints.info.enabled=true
|
|
||||||
endpoints.metrics.id=metrics
|
|
||||||
endpoints.metrics.sensitive=true
|
|
||||||
endpoints.metrics.enabled=true
|
|
||||||
endpoints.shutdown.id=shutdown
|
|
||||||
endpoints.shutdown.sensitive=true
|
|
||||||
endpoints.shutdown.enabled=false
|
|
||||||
endpoints.trace.id=trace
|
|
||||||
endpoints.trace.sensitive=true
|
|
||||||
endpoints.trace.enabled=true
|
|
||||||
|
|
||||||
# HEALTH INDICATORS (previously health.*)
|
|
||||||
management.health.db.enabled=true
|
|
||||||
management.health.diskspace.enabled=true
|
|
||||||
management.health.mongo.enabled=true
|
|
||||||
management.health.rabbit.enabled=true
|
|
||||||
management.health.redis.enabled=false
|
|
||||||
management.health.solr.enabled=false
|
|
||||||
management.health.diskspace.path=.
|
|
||||||
management.health.diskspace.threshold=10485760
|
|
||||||
management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, UP
|
|
||||||
|
|
||||||
# SECURITY (SecurityProperties)
|
# SECURITY (SecurityProperties)
|
||||||
security.user.name=${BASIC_USERNAME:admin}
|
security.user.name=${BASIC_USERNAME:admin}
|
||||||
security.user.password=${BASIC_PASSWORD:admin}
|
security.user.password=${BASIC_PASSWORD:admin}
|
||||||
@@ -87,7 +35,7 @@ security.require-ssl=false
|
|||||||
security.enable-csrf=false
|
security.enable-csrf=false
|
||||||
security.basic.enabled=true
|
security.basic.enabled=true
|
||||||
security.basic.realm=DeviceSimulator
|
security.basic.realm=DeviceSimulator
|
||||||
security.basic.path= /system/**
|
security.basic.path= /**
|
||||||
security.basic.authorize-mode=ROLE
|
security.basic.authorize-mode=ROLE
|
||||||
security.filter-order=0
|
security.filter-order=0
|
||||||
security.headers.xss=false
|
security.headers.xss=false
|
||||||
|
|||||||
0
examples/hawkbit-example-app/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-example-app/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-example-app/README.md
Executable file → Normal file
0
examples/hawkbit-example-app/README.md
Executable file → Normal file
9
examples/hawkbit-example-app/pom.xml
Executable file → Normal file
9
examples/hawkbit-example-app/pom.xml
Executable file → Normal file
@@ -48,6 +48,11 @@
|
|||||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-rest-resource</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-dmf-amqp</artifactId>
|
<artifactId>hawkbit-dmf-amqp</artifactId>
|
||||||
@@ -92,10 +97,6 @@
|
|||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-aspects</artifactId>
|
<artifactId>spring-security-aspects</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
|
|||||||
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java
Executable file → Normal file
12
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java
Executable file → Normal file
12
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java
Executable file → Normal file
@@ -10,25 +10,27 @@ package org.eclipse.hawkbit.app;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||||
|
import org.eclipse.hawkbit.controller.EnableDirectDeviceApi;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.EnableRestResources;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SpringBootApplication} annoated class with a main method to start.
|
* A {@link SpringBootApplication} annotated class with a main method to start.
|
||||||
* The minimal configuration for the standalone hawkBit server.
|
* The minimal configuration for the stand alone hawkBit server.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Import({ RepositoryApplicationConfiguration.class })
|
@Import({ RepositoryApplicationConfiguration.class })
|
||||||
@EnableHawkbitManagedSecurityConfiguration
|
@EnableHawkbitManagedSecurityConfiguration
|
||||||
|
@EnableRestResources
|
||||||
|
@EnableDirectDeviceApi
|
||||||
public class Start {
|
public class Start {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main method to start the spring-boot application.
|
* Main method to start the spring-boot application.
|
||||||
*
|
*
|
||||||
* @param args
|
* @param args
|
||||||
* the VM arguments.
|
* the VM arguments.
|
||||||
*/
|
*/
|
||||||
|
|||||||
0
examples/hawkbit-example-app/src/main/resources/application.properties
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/resources/application.properties
Executable file → Normal file
2
examples/hawkbit-mgmt-api-client/.gitignore
vendored
Normal file
2
examples/hawkbit-mgmt-api-client/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/target/
|
||||||
|
/bin/
|
||||||
3
examples/hawkbit-mgmt-api-client/README.md
Normal file
3
examples/hawkbit-mgmt-api-client/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Example client that shows how to efficiently use the hawkBit management API.
|
||||||
|
|
||||||
|
Powered by [Feign](https://github.com/Netflix/feign).
|
||||||
70
examples/hawkbit-mgmt-api-client/pom.xml
Normal file
70
examples/hawkbit-mgmt-api-client/pom.xml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
which accompanies this distribution, and is available at
|
||||||
|
http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
|
||||||
|
-->
|
||||||
|
<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.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-examples-parent</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>hawkbit-mgmt-api-client</artifactId>
|
||||||
|
<name>hawkBit Management API example client</name>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-rest-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.netflix.feign</groupId>
|
||||||
|
<artifactId>feign-jackson</artifactId>
|
||||||
|
<version>8.12.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.netflix.feign</groupId>
|
||||||
|
<artifactId>feign-core</artifactId>
|
||||||
|
<version>8.12.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-example-app</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ru.yandex.qatools.allure</groupId>
|
||||||
|
<artifactId>allure-junit-adaptor</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.easytesting</groupId>
|
||||||
|
<artifactId>fest-assert-core</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.easytesting</groupId>
|
||||||
|
<artifactId>fest-assert</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest;
|
||||||
|
|
||||||
|
import feign.Headers;
|
||||||
|
import feign.RequestLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client binding for the Distribution resource of the management API.
|
||||||
|
*/
|
||||||
|
public interface DistributionSetResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a list of distrbution sets.
|
||||||
|
*
|
||||||
|
* @param sets
|
||||||
|
* the request body java bean containing the necessary attributes
|
||||||
|
* for creating a distribution set.
|
||||||
|
* @return the list of targets which have been created
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
DistributionSetsRest createDistributionSets(final List<DistributionSetRequestBodyPost> sets);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||||
|
|
||||||
|
import feign.Headers;
|
||||||
|
import feign.Param;
|
||||||
|
import feign.RequestLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client binding for the DistributionSetTag resource of the management API.
|
||||||
|
*/
|
||||||
|
public interface DistrubutionSetTagResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a single distributionset tag based on the given ID.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the ID of the distributionset tag to retrieve
|
||||||
|
* @return a deserialized java bean containing the attributes of the
|
||||||
|
* returned distributionset tag
|
||||||
|
*/
|
||||||
|
@RequestLine("GET " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}")
|
||||||
|
TagRest getDistributionSetTag(@Param("dsTagId") Long dsTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a list of distributionset tags.
|
||||||
|
*
|
||||||
|
* @param tags
|
||||||
|
* the tags to be created
|
||||||
|
* @return the created tag list
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TagsRest createDistributionSetTags(List<TagRequestBodyPut> tags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update attributes of a distributionset tag.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the distributionset tag id to be updated
|
||||||
|
* @param tag
|
||||||
|
* the request body
|
||||||
|
* @return the updated distributionset tag
|
||||||
|
*/
|
||||||
|
@RequestLine("PUT " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}")
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TagRest updateDistributionSetTag(@Param("dsTagId") Long dsTagId, TagRequestBodyPut tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes given distributionset tag on given ID.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* to be deleted
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}")
|
||||||
|
void deleteDistributionSetTag(@Param("dsTagId") final Long dsTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a all assigned targets on the given distributionset tag id.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the ID of the distributionset tag to retrieve
|
||||||
|
* @return a list of targets
|
||||||
|
*/
|
||||||
|
@RequestLine("GET " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
|
||||||
|
DistributionSetsRest getAssignedDistributionSets(@Param("dsTagId") final Long dsTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the tag assignment all assigned targets will be unassigned and all
|
||||||
|
* unassigned targets will be assigned.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the ID of the distributionset tag to toggle
|
||||||
|
* @param assignedTargetRequestBodies
|
||||||
|
* a list of controller ids
|
||||||
|
* @return a list of assigned and unassigned targets
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/toggleTagAssignment")
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
DistributionSetTagAssigmentResultRest toggleTagAssignment(@Param("dsTagId") final Long dsTagId,
|
||||||
|
final List<AssignedDistributionSetRequestBody> assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign targets to a given distributionset tag id.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the ID of the distributionset tag to add the targets
|
||||||
|
* @param assignedTargetRequestBodies
|
||||||
|
* a list of controller ids
|
||||||
|
* @return a list of assigned targets
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TargetsRest assignDistributionSets(@Param("dsTagId") final Long dsTagId,
|
||||||
|
final List<AssignedDistributionSetRequestBody> assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unassign targets to a given distributionset tag id.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the ID of the distributionset tag to add the targets
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
|
||||||
|
void unassignDistributionSets(@Param("dsTagId") final Long dsTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unassign one target to a given distributionset tag id.
|
||||||
|
*
|
||||||
|
* @param dsTagId
|
||||||
|
* the ID of the distributionset tag to add the targets param
|
||||||
|
* @param dsId
|
||||||
|
* the distributionset id
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/{dsId}")
|
||||||
|
void unassignDistributionSet(@Param("dsTagId") final Long dsTagId, @Param("dsId") final Long dsId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||||
|
|
||||||
|
import feign.Headers;
|
||||||
|
import feign.Param;
|
||||||
|
import feign.RequestLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client binding for the Target resource of the management API.
|
||||||
|
*/
|
||||||
|
public interface TargetResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a single target based on the given ID.
|
||||||
|
*
|
||||||
|
* @param targetId
|
||||||
|
* the ID of the target to retrieve
|
||||||
|
* @return a deserialized java bean containing the attributes of the
|
||||||
|
* returned target
|
||||||
|
*/
|
||||||
|
@RequestLine("GET /rest/v1/targets/{targetId}")
|
||||||
|
TargetRest getTarget(@Param("targetId") final String targetId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paged query of targets resource.
|
||||||
|
*
|
||||||
|
* @param pagingOffsetParam
|
||||||
|
* of the paged query
|
||||||
|
* @param pagingLimitParam
|
||||||
|
* of the paged query
|
||||||
|
* @return paged list of target entries
|
||||||
|
*/
|
||||||
|
@RequestLine("GET /rest/v1/targets?offset={pagingOffsetParam}&limit={pagingLimitParam}")
|
||||||
|
TargetPagedList getTargets(@Param("pagingOffsetParam") int pagingOffsetParam,
|
||||||
|
@Param("pagingLimitParam") int pagingLimitParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paged query of targets resource with default offset and limit.
|
||||||
|
*
|
||||||
|
* @return paged list of target entries
|
||||||
|
*/
|
||||||
|
@RequestLine("GET /rest/v1/targets")
|
||||||
|
TargetPagedList getTargets();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes given target based on given ID.
|
||||||
|
*
|
||||||
|
* @param targetId
|
||||||
|
* to be deleted
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE /rest/v1/targets/{targetId}")
|
||||||
|
void deleteTarget(@Param("targetId") final String targetId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a list of targets.
|
||||||
|
*
|
||||||
|
* @param targets
|
||||||
|
* the request body java bean containing the necessary attributes
|
||||||
|
* for creating a target.
|
||||||
|
* @return the list of targets which have been created
|
||||||
|
*/
|
||||||
|
@RequestLine("POST /rest/v1/targets/")
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TargetsRest createTargets(List<TargetRequestBody> targets);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||||
|
|
||||||
|
import feign.Headers;
|
||||||
|
import feign.Param;
|
||||||
|
import feign.RequestLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client binding for the Target resource of the management API.
|
||||||
|
*/
|
||||||
|
public interface TargetTagResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a single target tag based on the given ID.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the ID of the target tag to retrieve
|
||||||
|
* @return a deserialized java bean containing the attributes of the
|
||||||
|
* returned target tag
|
||||||
|
*/
|
||||||
|
@RequestLine("GET " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}")
|
||||||
|
TagRest getTargetTag(@Param("targetTagId") Long targetTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a list of target tags.
|
||||||
|
*
|
||||||
|
* @param tags
|
||||||
|
* the tags to be created
|
||||||
|
* @return the created tag list
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING)
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TagsRest createTargetTag(List<TagRequestBodyPut> tags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update attributes of a target tag.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the target tag id to be updated
|
||||||
|
* @param tag
|
||||||
|
* the request body
|
||||||
|
* @return the updated target tag
|
||||||
|
*/
|
||||||
|
@RequestLine("PUT " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}")
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TagRest updateTagretTag(@Param("targetTagId") Long targetTagId, TagRequestBodyPut tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes given target tag on given ID.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* to be deleted
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}")
|
||||||
|
void deleteTargetTag(@Param("targetTagId") final Long targetTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a all assigned targets on the given target tag id.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the ID of the target tag to retrieve
|
||||||
|
* @return a list of targets
|
||||||
|
*/
|
||||||
|
@RequestLine("GET " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
|
||||||
|
TargetsRest getAssignedTargets(@Param("targetTagId") final Long targetTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the tag assignment all assigned targets will be unassigned and all
|
||||||
|
* unassigned targets will be assigned.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the ID of the target tag to toggle
|
||||||
|
* @param assignedTargetRequestBodies
|
||||||
|
* a list of controller ids
|
||||||
|
* @return a list of assigned and unassigned targets
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/toggleTagAssignment")
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TargetTagAssigmentResultRest toggleTagAssignment(@Param("targetTagId") final Long targetTagId,
|
||||||
|
final List<AssignedTargetRequestBody> assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign targets to a given target tag id.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the ID of the target tag to add the targets
|
||||||
|
* @param assignedTargetRequestBodies
|
||||||
|
* a list of controller ids
|
||||||
|
* @return a list of assigned targets
|
||||||
|
*/
|
||||||
|
@RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
TargetsRest assignTargets(@Param("targetTagId") final Long targetTagId,
|
||||||
|
final List<AssignedTargetRequestBody> assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unassign targets to a given target tag id.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the ID of the target tag to add the targets
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
|
||||||
|
void unassignTargets(@Param("targetTagId") final Long targetTagId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unassign one target to a given target tag id.
|
||||||
|
*
|
||||||
|
* @param targetTagId
|
||||||
|
* the ID of the target tag to add the targets param
|
||||||
|
* @param controllerId
|
||||||
|
* the controller id
|
||||||
|
*/
|
||||||
|
@RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||||
|
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/{controllerId}")
|
||||||
|
void unassignTarget(@Param("targetTagId") final Long targetTagId, @Param("controllerId") final String controllerId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.app.Start;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.context.annotation.Description;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
import feign.Feign;
|
||||||
|
import feign.Logger;
|
||||||
|
import feign.auth.BasicAuthRequestInterceptor;
|
||||||
|
import feign.jackson.JacksonDecoder;
|
||||||
|
import feign.jackson.JacksonEncoder;
|
||||||
|
|
||||||
|
@Features("Example Tests - Management RESTful API Client")
|
||||||
|
@Stories("DistrubutionSet Tag Resource")
|
||||||
|
public class DistributionSetTagTest {
|
||||||
|
|
||||||
|
private DistrubutionSetTagResource distrubutionSetTagResource;
|
||||||
|
|
||||||
|
private static List<AssignedDistributionSetRequestBody> assignedTargetRequestBodies;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void startupServer() {
|
||||||
|
SpringApplication.run(Start.class, new String[0]);
|
||||||
|
createTargetsAssignment();
|
||||||
|
assignedTargetRequestBodies.add(new AssignedDistributionSetRequestBody().setDistributionSetId(100L));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
this.distrubutionSetTagResource = createDistrubutionSetTagResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of distrubutionset tag by ID")
|
||||||
|
@Ignore
|
||||||
|
public void getDistributionSetTag() {
|
||||||
|
final TagsRest result = createDistributionSetTags(2);
|
||||||
|
|
||||||
|
assertThat(distrubutionSetTagResource.getDistributionSetTag(result.get(0).getTagId()).getName()).isEqualTo(
|
||||||
|
"Tag0");
|
||||||
|
|
||||||
|
deleteDistributionSets(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple update of a distrubutionset tag")
|
||||||
|
@Ignore
|
||||||
|
public void updateDistributionSetTag() {
|
||||||
|
final TagsRest created = createDistributionSetTags(10);
|
||||||
|
|
||||||
|
distrubutionSetTagResource.updateDistributionSetTag(created.get(0).getTagId(), new TagRequestBodyPut()
|
||||||
|
.setDescription("Test").setName("Test").setColour("Green"));
|
||||||
|
|
||||||
|
final TagRest targetTag = distrubutionSetTagResource.getDistributionSetTag(created.get(0).getTagId());
|
||||||
|
assertThat(targetTag.getName()).isEqualTo("Test");
|
||||||
|
assertThat(targetTag.getDescription()).isEqualTo("Test");
|
||||||
|
assertThat(targetTag.getColour()).isEqualTo("Green");
|
||||||
|
|
||||||
|
deleteDistributionSets(created);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of all assigned distrubutionsets by a distrubutionset tag.")
|
||||||
|
@Ignore
|
||||||
|
public void getDistributionSetByTagId() {
|
||||||
|
final TagsRest created = createDistributionSetTags(10);
|
||||||
|
distrubutionSetTagResource.assignDistributionSets(created.get(2).getTagId(), assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
final DistributionSetsRest distributionSetsRest = distrubutionSetTagResource
|
||||||
|
.getAssignedDistributionSets(created.get(2).getTagId());
|
||||||
|
assertThat(distributionSetsRest).hasSize(5);
|
||||||
|
|
||||||
|
distrubutionSetTagResource.unassignDistributionSets(created.get(2).getTagId());
|
||||||
|
deleteDistributionSets(created);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Toggle request to unassigned all assigned distrubutionset and assign all unassigned distrubutionset.")
|
||||||
|
@Ignore
|
||||||
|
public void toggleTagAssignment() {
|
||||||
|
final TagsRest created = createDistributionSetTags(10);
|
||||||
|
final Long id = created.get(2).getTagId();
|
||||||
|
|
||||||
|
distrubutionSetTagResource.assignDistributionSets(id, assignedTargetRequestBodies);
|
||||||
|
distrubutionSetTagResource.unassignDistributionSet(id, assignedTargetRequestBodies.get(0)
|
||||||
|
.getDistributionSetId());
|
||||||
|
|
||||||
|
DistributionSetTagAssigmentResultRest assigmentResultRest = distrubutionSetTagResource.toggleTagAssignment(id,
|
||||||
|
assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
final TagRest targetTag = distrubutionSetTagResource.getDistributionSetTag(created.get(2).getTagId());
|
||||||
|
assertThat(assigmentResultRest.getAssignedDistributionSets()).hasSize(1);
|
||||||
|
assertThat(assigmentResultRest.getUnassignedDistributionSets()).hasSize(0);
|
||||||
|
|
||||||
|
assigmentResultRest = distrubutionSetTagResource.toggleTagAssignment(id, assignedTargetRequestBodies);
|
||||||
|
assertThat(assigmentResultRest.getAssignedDistributionSets()).hasSize(0);
|
||||||
|
assertThat(assigmentResultRest.getUnassignedDistributionSets()).hasSize(5);
|
||||||
|
|
||||||
|
distrubutionSetTagResource.unassignDistributionSets(targetTag.getTagId());
|
||||||
|
deleteDistributionSets(created);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteDistributionSets(final List<TagRest> tags) {
|
||||||
|
for (final TagRest tag : tags) {
|
||||||
|
distrubutionSetTagResource.deleteDistributionSetTag(tag.getTagId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TagsRest createDistributionSetTags(final int number) {
|
||||||
|
|
||||||
|
final List<TagRequestBodyPut> tags = new ArrayList<>();
|
||||||
|
for (int i = 0; i < number; i++) {
|
||||||
|
tags.add(new TagRequestBodyPut().setDescription("Tag " + i).setName("Tag" + i).setColour("Red"));
|
||||||
|
}
|
||||||
|
|
||||||
|
final TagsRest result = distrubutionSetTagResource.createDistributionSetTags(tags);
|
||||||
|
|
||||||
|
assertThat(result).hasSize(number);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DistrubutionSetTagResource createDistrubutionSetTagResource() {
|
||||||
|
final DistrubutionSetTagResource distrubutionSetTagResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||||
|
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||||
|
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||||
|
.target(DistrubutionSetTagResource.class, "http://localhost:8080");
|
||||||
|
return distrubutionSetTagResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createTargetsAssignment() {
|
||||||
|
|
||||||
|
final List<DistributionSetRequestBodyPost> sets = new ArrayList<>();
|
||||||
|
assignedTargetRequestBodies = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
final DistributionSetRequestBodyPost bodyPost = (DistributionSetRequestBodyPost) new DistributionSetRequestBodyPost()
|
||||||
|
.setName("Ds" + i).setDescription("Ds" + i).setVersion("" + i);
|
||||||
|
sets.add(bodyPost);
|
||||||
|
}
|
||||||
|
|
||||||
|
final DistributionSetsRest result = createDistributionSetResource().createDistributionSets(sets);
|
||||||
|
for (final DistributionSetRest rest : result) {
|
||||||
|
assignedTargetRequestBodies.add(new AssignedDistributionSetRequestBody().setDistributionSetId(rest
|
||||||
|
.getDsId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DistributionSetResource createDistributionSetResource() {
|
||||||
|
final DistributionSetResource distributionSetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||||
|
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||||
|
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||||
|
.target(DistributionSetResource.class, "http://localhost:8080");
|
||||||
|
return distributionSetResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.app.Start;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.context.annotation.Description;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
import feign.Feign;
|
||||||
|
import feign.Logger;
|
||||||
|
import feign.auth.BasicAuthRequestInterceptor;
|
||||||
|
import feign.jackson.JacksonDecoder;
|
||||||
|
import feign.jackson.JacksonEncoder;
|
||||||
|
|
||||||
|
@Features("Example Tests - Management RESTful API Client")
|
||||||
|
@Stories("Target Tag Resource")
|
||||||
|
public class TargetTagTest {
|
||||||
|
|
||||||
|
private TargetTagResource targetTagResource;
|
||||||
|
|
||||||
|
private static List<AssignedTargetRequestBody> assignedTargetRequestBodies;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void startupServer() {
|
||||||
|
SpringApplication.run(Start.class, new String[0]);
|
||||||
|
createTargetsAssignment();
|
||||||
|
assignedTargetRequestBodies.add(new AssignedTargetRequestBody().setControllerId("NotExist"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
this.targetTagResource = createTargetTagResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of target tag by ID")
|
||||||
|
@Ignore
|
||||||
|
public void getTargetTag() {
|
||||||
|
final TagsRest result = createTargetTags(2);
|
||||||
|
|
||||||
|
assertThat(targetTagResource.getTargetTag(result.get(0).getTagId()).getName()).isEqualTo("Tag0");
|
||||||
|
|
||||||
|
deleteTargets(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple update of a target tag")
|
||||||
|
@Ignore
|
||||||
|
public void updateTargetTag() {
|
||||||
|
final TagsRest created = createTargetTags(10);
|
||||||
|
|
||||||
|
targetTagResource.updateTagretTag(created.get(0).getTagId(), new TagRequestBodyPut().setDescription("Test")
|
||||||
|
.setName("Test").setColour("Green"));
|
||||||
|
|
||||||
|
final TagRest targetTag = targetTagResource.getTargetTag(created.get(0).getTagId());
|
||||||
|
assertThat(targetTag.getName()).isEqualTo("Test");
|
||||||
|
assertThat(targetTag.getDescription()).isEqualTo("Test");
|
||||||
|
assertThat(targetTag.getColour()).isEqualTo("Green");
|
||||||
|
|
||||||
|
deleteTargets(created);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of all assigned targets by a target tag.")
|
||||||
|
@Ignore
|
||||||
|
public void getTargetsByTargetTagId() {
|
||||||
|
final TagsRest created = createTargetTags(10);
|
||||||
|
final Long tagId = created.get(2).getTagId();
|
||||||
|
targetTagResource.assignTargets(tagId, assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
final TagRest targetTag = targetTagResource.getTargetTag(tagId);
|
||||||
|
assertThat(targetTagResource.getAssignedTargets(tagId)).hasSize(5);
|
||||||
|
|
||||||
|
targetTagResource.unassignTargets(targetTag.getTagId());
|
||||||
|
deleteTargets(created);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Toggle request to unassigned all assigned targets and assign all unassigned targets.")
|
||||||
|
@Ignore
|
||||||
|
public void toggleTagAssignment() {
|
||||||
|
final TagsRest created = createTargetTags(10);
|
||||||
|
final Long id = created.get(2).getTagId();
|
||||||
|
|
||||||
|
targetTagResource.assignTargets(id, assignedTargetRequestBodies);
|
||||||
|
targetTagResource.unassignTarget(id, assignedTargetRequestBodies.get(0).getControllerId());
|
||||||
|
|
||||||
|
TargetTagAssigmentResultRest assigmentResultRest = targetTagResource.toggleTagAssignment(id,
|
||||||
|
assignedTargetRequestBodies);
|
||||||
|
|
||||||
|
final TagRest targetTag = targetTagResource.getTargetTag(created.get(2).getTagId());
|
||||||
|
assertThat(assigmentResultRest.getAssignedTargets()).hasSize(1);
|
||||||
|
assertThat(assigmentResultRest.getUnassignedTargets()).hasSize(0);
|
||||||
|
|
||||||
|
assigmentResultRest = targetTagResource.toggleTagAssignment(id, assignedTargetRequestBodies);
|
||||||
|
assertThat(assigmentResultRest.getAssignedTargets()).hasSize(0);
|
||||||
|
assertThat(assigmentResultRest.getUnassignedTargets()).hasSize(5);
|
||||||
|
|
||||||
|
targetTagResource.unassignTargets(targetTag.getTagId());
|
||||||
|
deleteTargets(created);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteTargets(final List<TagRest> tags) {
|
||||||
|
for (final TagRest tag : tags) {
|
||||||
|
targetTagResource.deleteTargetTag(tag.getTagId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TagsRest createTargetTags(final int number) {
|
||||||
|
|
||||||
|
final List<TagRequestBodyPut> tags = new ArrayList<>();
|
||||||
|
for (int i = 0; i < number; i++) {
|
||||||
|
tags.add(new TagRequestBodyPut().setDescription("Tag " + i).setName("Tag" + i).setColour("Red"));
|
||||||
|
}
|
||||||
|
|
||||||
|
final TagsRest result = targetTagResource.createTargetTag(tags);
|
||||||
|
|
||||||
|
assertThat(result).hasSize(number);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetTagResource createTargetTagResource() {
|
||||||
|
final TargetTagResource targetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||||
|
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||||
|
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||||
|
.target(TargetTagResource.class, "http://localhost:8080");
|
||||||
|
return targetResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createTargetsAssignment() {
|
||||||
|
|
||||||
|
final List<TargetRequestBody> targets = new ArrayList<>();
|
||||||
|
assignedTargetRequestBodies = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
|
||||||
|
targets.add(new TargetRequestBody().setControllerId("test" + i).setName("testDevice"));
|
||||||
|
}
|
||||||
|
|
||||||
|
final TargetsRest result = createTargetResource().createTargets(targets);
|
||||||
|
for (final TargetRest rest : result) {
|
||||||
|
assignedTargetRequestBodies.add(new AssignedTargetRequestBody().setControllerId(rest.getControllerId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TargetResource createTargetResource() {
|
||||||
|
final TargetResource targetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||||
|
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||||
|
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||||
|
.target(TargetResource.class, "http://localhost:8080");
|
||||||
|
return targetResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.mgmt.api.client;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.app.Start;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||||
|
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.context.annotation.Description;
|
||||||
|
|
||||||
|
import feign.Feign;
|
||||||
|
import feign.Logger;
|
||||||
|
import feign.auth.BasicAuthRequestInterceptor;
|
||||||
|
import feign.jackson.JacksonDecoder;
|
||||||
|
import feign.jackson.JacksonEncoder;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Example Tests - Management RESTful API Client")
|
||||||
|
@Stories("Target Resource")
|
||||||
|
public class TargetTest {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void startupServer() {
|
||||||
|
SpringApplication.run(Start.class, new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of target by ID")
|
||||||
|
@Ignore
|
||||||
|
public void getTarget() {
|
||||||
|
final TargetResource targetResource = createTargetResource();
|
||||||
|
final TargetsRest result = createTargets(targetResource, 1);
|
||||||
|
|
||||||
|
assertThat(targetResource.getTarget("test0").getName()).isEqualTo("testDevice");
|
||||||
|
|
||||||
|
deleteTargets(targetResource, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of all targets with defined page sizing information (i.e. offset and limit).")
|
||||||
|
@Ignore
|
||||||
|
public void getTargetsAsPagedListWithDefinedPageSizing() {
|
||||||
|
final TargetResource targetResource = createTargetResource();
|
||||||
|
final TargetsRest created = createTargets(targetResource, 20);
|
||||||
|
|
||||||
|
final TargetPagedList queryResult = targetResource.getTargets(0, 10);
|
||||||
|
|
||||||
|
assertThat(queryResult.getContent()).hasSize(10);
|
||||||
|
assertThat(queryResult.getTotal()).isEqualTo(20);
|
||||||
|
assertThat(queryResult.getSize()).isEqualTo(10);
|
||||||
|
|
||||||
|
deleteTargets(targetResource, created);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled as this runs not on CI environments.
|
||||||
|
@Test
|
||||||
|
@Description("Simple request of all targets with defualt paging parameters.")
|
||||||
|
@Ignore
|
||||||
|
public void getTargetsAsPagedListWithDefaultPageSizing() {
|
||||||
|
final TargetResource targetResource = createTargetResource();
|
||||||
|
final TargetsRest created = createTargets(targetResource, 20);
|
||||||
|
|
||||||
|
final TargetPagedList queryResult = targetResource.getTargets();
|
||||||
|
|
||||||
|
assertThat(queryResult.getContent()).hasSize(20);
|
||||||
|
assertThat(queryResult.getTotal()).isEqualTo(20);
|
||||||
|
assertThat(queryResult.getSize()).isEqualTo(20);
|
||||||
|
|
||||||
|
deleteTargets(targetResource, created);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteTargets(final TargetResource targetResource, final List<TargetRest> targets) {
|
||||||
|
for (final TargetRest targetRest : targets) {
|
||||||
|
targetResource.deleteTarget(targetRest.getControllerId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetsRest createTargets(final TargetResource targetResource, final int number) {
|
||||||
|
|
||||||
|
final List<TargetRequestBody> targets = new ArrayList<>();
|
||||||
|
for (int i = 0; i < number; i++) {
|
||||||
|
|
||||||
|
targets.add(new TargetRequestBody().setControllerId("test" + i).setName("testDevice"));
|
||||||
|
}
|
||||||
|
|
||||||
|
final TargetsRest result = targetResource.createTargets(targets);
|
||||||
|
|
||||||
|
assertThat(result).hasSize(number);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetResource createTargetResource() {
|
||||||
|
final TargetResource targetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||||
|
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||||
|
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||||
|
.target(TargetResource.class, "http://localhost:8080");
|
||||||
|
return targetResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
examples/pom.xml
Executable file → Normal file
1
examples/pom.xml
Executable file → Normal file
@@ -25,6 +25,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>hawkbit-device-simulator</module>
|
<module>hawkbit-device-simulator</module>
|
||||||
<module>hawkbit-example-app</module>
|
<module>hawkbit-example-app</module>
|
||||||
|
<module>hawkbit-mgmt-api-client</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
0
hawkbit-artifact-repository-mongo/README.md
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/README.md
Executable file → Normal file
1
hawkbit-artifact-repository-mongo/pom.xml
Executable file → Normal file
1
hawkbit-artifact-repository-mongo/pom.xml
Executable file → Normal file
@@ -41,7 +41,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>18.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TEST -->
|
<!-- TEST -->
|
||||||
|
|||||||
5
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java
Executable file → Normal file
5
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java
Executable file → Normal file
@@ -199,8 +199,8 @@ public class ArtifactStore implements ArtifactRepository {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String computeSHA1Hash(final InputStream stream, final FileOutputStream os, final String providedSHA1Sum)
|
private static String computeSHA1Hash(final InputStream stream, final FileOutputStream os,
|
||||||
throws NoSuchAlgorithmException, IOException {
|
final String providedSHA1Sum) throws NoSuchAlgorithmException, IOException {
|
||||||
String sha1Hash;
|
String sha1Hash;
|
||||||
// compute digest
|
// compute digest
|
||||||
final MessageDigest md = MessageDigest.getInstance("SHA-1");
|
final MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||||
@@ -240,6 +240,7 @@ public class ArtifactStore implements ArtifactRepository {
|
|||||||
* the sha1-hashes of the files to lookup.
|
* the sha1-hashes of the files to lookup.
|
||||||
* @return list of artfiacts
|
* @return list of artfiacts
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<DbArtifact> getArtifactsBySha1(final List<String> sha1Hashes) {
|
public List<DbArtifact> getArtifactsBySha1(final List<String> sha1Hashes) {
|
||||||
return map(gridFs.find(new Query().addCriteria(Criteria.where(SHA1).in(sha1Hashes))));
|
return map(gridFs.find(new Query().addCriteria(Criteria.where(SHA1).in(sha1Hashes))));
|
||||||
}
|
}
|
||||||
|
|||||||
0
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreAutoConfiguration.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreAutoConfiguration.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/GridFsArtifact.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/GridFsArtifact.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/resources/META-INF/spring.factories
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/main/resources/META-INF/spring.factories
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/TestConfiguration.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/TestConfiguration.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java
Executable file → Normal file
0
hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java
Executable file → Normal file
5
hawkbit-autoconfigure/pom.xml
Executable file → Normal file
5
hawkbit-autoconfigure/pom.xml
Executable file → Normal file
@@ -67,11 +67,6 @@
|
|||||||
<artifactId>hawkbit-rest-resource</artifactId>
|
<artifactId>hawkbit-rest-resource</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|||||||
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/amqp/AmqpAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/amqp/AmqpAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/RedisAutoConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/RedisAutoConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/ControllerPollAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/ControllerPollAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/DefaultPropertiesAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/DefaultPropertiesAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/eventbus/EventBusAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/eventbus/EventBusAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerThreadpoolProperties.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerThreadpoolProperties.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/EnableHawkbitManagedSecurityConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/EnableHawkbitManagedSecurityConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java
Executable file → Normal file
115
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java
Executable file → Normal file
115
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java
Executable file → Normal file
@@ -19,8 +19,6 @@ import javax.servlet.FilterConfig;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ExcludePathAwareShallowETagFilter;
|
import org.eclipse.hawkbit.ExcludePathAwareShallowETagFilter;
|
||||||
@@ -47,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||||
import org.springframework.boot.context.embedded.FilterRegistrationBean;
|
import org.springframework.boot.context.embedded.FilterRegistrationBean;
|
||||||
|
import org.springframework.boot.context.embedded.ServletListenerRegistrationBean;
|
||||||
import org.springframework.cache.Cache;
|
import org.springframework.cache.Cache;
|
||||||
import org.springframework.context.EnvironmentAware;
|
import org.springframework.context.EnvironmentAware;
|
||||||
import org.springframework.context.annotation.AdviceMode;
|
import org.springframework.context.annotation.AdviceMode;
|
||||||
@@ -68,9 +67,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
|||||||
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
|
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
||||||
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
|
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
|
||||||
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
|
import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
|
||||||
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
|
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
|
||||||
@@ -78,6 +75,7 @@ import org.springframework.security.web.authentication.preauth.RequestHeaderAuth
|
|||||||
import org.springframework.security.web.header.writers.frameoptions.StaticAllowFromStrategy;
|
import org.springframework.security.web.header.writers.frameoptions.StaticAllowFromStrategy;
|
||||||
import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter;
|
import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter;
|
||||||
import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter.XFrameOptionsMode;
|
import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter.XFrameOptionsMode;
|
||||||
|
import org.springframework.security.web.session.HttpSessionEventPublisher;
|
||||||
import org.vaadin.spring.security.VaadinSecurityContext;
|
import org.vaadin.spring.security.VaadinSecurityContext;
|
||||||
import org.vaadin.spring.security.annotation.EnableVaadinSecurity;
|
import org.vaadin.spring.security.annotation.EnableVaadinSecurity;
|
||||||
import org.vaadin.spring.security.web.VaadinDefaultRedirectStrategy;
|
import org.vaadin.spring.security.web.VaadinDefaultRedirectStrategy;
|
||||||
@@ -161,31 +159,35 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (securityConfiguration.getAnonymousEnabled()) {
|
if (securityConfiguration.getAnonymousEnabled()) {
|
||||||
LOG.info(
|
LOG.info("******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************");
|
||||||
"******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************");
|
|
||||||
final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
|
final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
|
||||||
"controllerAnonymousFilter", "anonymous", Collections.singletonList(
|
"controllerAnonymousFilter", "anonymous", Collections.singletonList(new SimpleGrantedAuthority(
|
||||||
new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS)));
|
SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS)));
|
||||||
anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
||||||
httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and()
|
httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and()
|
||||||
.securityContext().disable().anonymous().authenticationFilter(anoymousFilter);
|
.securityContext().disable().anonymous().authenticationFilter(anoymousFilter);
|
||||||
} else {
|
} else {
|
||||||
httpSec.addFilter(securityHeaderFilter).addFilter(securityTokenFilter)
|
httpSec.addFilter(securityHeaderFilter)
|
||||||
.addFilter(gatewaySecurityTokenFilter).antMatcher("/*/controller/**").anonymous().disable()
|
.addFilter(securityTokenFilter)
|
||||||
.authorizeRequests().anyRequest().authenticated().and().exceptionHandling()
|
.addFilter(gatewaySecurityTokenFilter)
|
||||||
.authenticationEntryPoint(new AuthenticationEntryPoint() {
|
.antMatcher("/*/controller/**")
|
||||||
@Override
|
.anonymous()
|
||||||
public void commence(final HttpServletRequest request, final HttpServletResponse response,
|
.disable()
|
||||||
final AuthenticationException authException) throws IOException, ServletException {
|
.authorizeRequests()
|
||||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
.anyRequest()
|
||||||
}
|
.authenticated()
|
||||||
}).and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
.and()
|
||||||
|
.exceptionHandling()
|
||||||
|
.authenticationEntryPoint(
|
||||||
|
(request, response, authException) -> response.setStatus(HttpStatus.UNAUTHORIZED
|
||||||
|
.value())).and().sessionManagement()
|
||||||
|
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see
|
||||||
* org.springframework.security.config.annotation.web.configuration.
|
* org.springframework.security.config.annotation.web.configuration.
|
||||||
* WebSecurityConfigurerAdapter
|
* WebSecurityConfigurerAdapter
|
||||||
@@ -194,8 +196,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.authenticationProvider(
|
auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration
|
||||||
new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs()));
|
.getRpTrustedIPs()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,12 +212,10 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
public FilterRegistrationBean dosFilter() {
|
public FilterRegistrationBean dosFilter() {
|
||||||
final FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
|
final FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
|
||||||
|
|
||||||
filterRegBean
|
filterRegBean.setFilter(new DosFilter(environment
|
||||||
.setFilter(
|
.getProperty("security.dos.filter.maxRead", Integer.class, 200), environment.getProperty(
|
||||||
new DosFilter(environment.getProperty("security.dos.filter.maxRead", Integer.class, 100),
|
"security.dos.filter.maxWrite", Integer.class, 50), environment
|
||||||
environment.getProperty("security.dos.filter.maxWrite", Integer.class, 10),
|
.getProperty("security.dos.filter.whitelist"), environment.getProperty("security.clients.blacklist"),
|
||||||
environment.getProperty("security.dos.filter.whitelist"), environment
|
|
||||||
.getProperty("security.clients.blacklist"),
|
|
||||||
environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
|
environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
|
||||||
filterRegBean.addUrlPatterns("/{tenant}/controller/v1/*", "/rest/*");
|
filterRegBean.addUrlPatterns("/{tenant}/controller/v1/*", "/rest/*");
|
||||||
return filterRegBean;
|
return filterRegBean;
|
||||||
@@ -301,8 +301,7 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
}, RequestHeaderAuthenticationFilter.class)
|
}, RequestHeaderAuthenticationFilter.class)
|
||||||
.addFilterAfter(
|
.addFilterAfter(
|
||||||
new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement),
|
new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement),
|
||||||
RequestHeaderAuthenticationFilter.class)
|
RequestHeaderAuthenticationFilter.class).authorizeRequests().anyRequest().authenticated()
|
||||||
.authorizeRequests().anyRequest().authenticated()
|
|
||||||
.antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
|
.antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
|
||||||
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**")
|
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**")
|
||||||
.hasAnyAuthority(SpPermission.SYSTEM_DIAG);
|
.hasAnyAuthority(SpPermission.SYSTEM_DIAG);
|
||||||
@@ -311,14 +310,12 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WebSecurityConfigurer} for external (management) access.
|
* {@link WebSecurityConfigurer} for external (management) access.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@Order(400)
|
@Order(400)
|
||||||
@EnableVaadinSecurity
|
@EnableVaadinSecurity
|
||||||
public static class UISecurityConfigurationAdapter extends WebSecurityConfigurerAdapter
|
public static class UISecurityConfigurationAdapter extends WebSecurityConfigurerAdapter implements EnvironmentAware {
|
||||||
implements EnvironmentAware {
|
|
||||||
|
|
||||||
private static final String XFRAME_OPTION_DENY = "DENY";
|
private static final String XFRAME_OPTION_DENY = "DENY";
|
||||||
private static final String XFRAME_OPTION_SAMEORIGIN = "SAMEORIGIN";
|
private static final String XFRAME_OPTION_SAMEORIGIN = "SAMEORIGIN";
|
||||||
@@ -370,6 +367,18 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener to redirect to login page after session timeout. Close the
|
||||||
|
* vaadin session, because it's is not possible to redirect in
|
||||||
|
* atmospehere.
|
||||||
|
*
|
||||||
|
* @return the servlet listener.
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
|
||||||
|
return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(final HttpSecurity http) throws Exception {
|
protected void configure(final HttpSecurity http) throws Exception {
|
||||||
|
|
||||||
@@ -379,9 +388,10 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
if (confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) && confAllowFromUri == null) {
|
if (confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) && confAllowFromUri == null) {
|
||||||
// if allow-from option is specified but no allowFromUri throw
|
// if allow-from option is specified but no allowFromUri throw
|
||||||
// exception
|
// exception
|
||||||
throw new IllegalStateException("hawkbit.server.security.xframe.option has been specified as ALLOW-FROM"
|
throw new IllegalStateException(
|
||||||
+ " but no hawkbit.server.security.xframe.option.allowfrom has been set, "
|
"hawkbit.server.security.xframe.option has been specified as ALLOW-FROM"
|
||||||
+ "please ensure to set allow from URIs");
|
+ " but no hawkbit.server.security.xframe.option.allowfrom has been set, "
|
||||||
|
+ "please ensure to set allow from URIs");
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround regex: we need to exclude the URL /UI/HEARTBEAT here
|
// workaround regex: we need to exclude the URL /UI/HEARTBEAT here
|
||||||
@@ -390,22 +400,23 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
// vaadin-forum:
|
// vaadin-forum:
|
||||||
// https://vaadin.com/forum#!/thread/3200565.
|
// https://vaadin.com/forum#!/thread/3200565.
|
||||||
HttpSecurity httpSec = http.regexMatcher("(?!.*HEARTBEAT)^.*\\/UI.*$")
|
HttpSecurity httpSec = http.regexMatcher("(?!.*HEARTBEAT)^.*\\/UI.*$")
|
||||||
// disable as CSRF is handled by Vaadin
|
// disable as CSRF is handled by Vaadin
|
||||||
.csrf().disable();
|
.csrf().disable();
|
||||||
|
|
||||||
if (springSecurityProperties.isRequireSsl()) {
|
if (springSecurityProperties.isRequireSsl()) {
|
||||||
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
|
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
|
||||||
} else {
|
} else {
|
||||||
LOG.info(
|
LOG.info("\"******************\\n** Requires HTTPS Security has been disabled for UI, should only use for developing purposes **\\n******************\"");
|
||||||
"\"******************\\n** Requires HTTPS Security has been disabled for UI, should only use for developing purposes **\\n******************\"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for UI integrator we allow frame integration on same origin
|
// for UI integrator we allow frame integration on same origin
|
||||||
httpSec.headers()
|
httpSec.headers()
|
||||||
.addHeaderWriter(confXframeOption.equals(XFAME_OPTION_ALLOW_FROM)
|
.addHeaderWriter(
|
||||||
? new XFrameOptionsHeaderWriter(new StaticAllowFromStrategy(new URI(confAllowFromUri)))
|
confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) ? new XFrameOptionsHeaderWriter(
|
||||||
: new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption)))
|
new StaticAllowFromStrategy(new URI(confAllowFromUri)))
|
||||||
.contentTypeOptions().xssProtection().httpStrictTransportSecurity().and()
|
: new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption)))
|
||||||
|
.contentTypeOptions().xssProtection().httpStrictTransportSecurity()
|
||||||
|
.and()
|
||||||
// UI
|
// UI
|
||||||
.authorizeRequests().antMatchers("/UI/login/**").permitAll().antMatchers("/UI/UIDL/**").permitAll()
|
.authorizeRequests().antMatchers("/UI/login/**").permitAll().antMatchers("/UI/UIDL/**").permitAll()
|
||||||
.anyRequest().authenticated().and()
|
.anyRequest().authenticated().and()
|
||||||
@@ -439,8 +450,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(final WebSecurity webSecurity) throws Exception {
|
public void configure(final WebSecurity webSecurity) throws Exception {
|
||||||
webSecurity.ignoring().antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**",
|
webSecurity.ignoring()
|
||||||
"/docs/**");
|
.antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**", "/docs/**");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,15 +482,15 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
http.csrf().disable();
|
http.csrf().disable();
|
||||||
http.anonymous().disable();
|
http.anonymous().disable();
|
||||||
|
|
||||||
http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN)
|
http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN).addFilterBefore(
|
||||||
.addFilterBefore(downloadIdAuthenticationFilter, FilterSecurityInterceptor.class);
|
downloadIdAuthenticationFilter, FilterSecurityInterceptor.class);
|
||||||
http.authorizeRequests().anyRequest().authenticated();
|
http.authorizeRequests().anyRequest().authenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.authenticationProvider(
|
auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration
|
||||||
new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs()));
|
.getRpTrustedIPs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -499,7 +510,7 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see org.vaadin.spring.security.web.authentication.
|
* @see org.vaadin.spring.security.web.authentication.
|
||||||
* SavedRequestAwareVaadinAuthenticationSuccessHandler
|
* SavedRequestAwareVaadinAuthenticationSuccessHandler
|
||||||
* #onAuthenticationSuccess(org.springframework.security.core.
|
* #onAuthenticationSuccess(org.springframework.security.core.
|
||||||
@@ -508,8 +519,8 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(final Authentication authentication) throws Exception {
|
public void onAuthenticationSuccess(final Authentication authentication) throws Exception {
|
||||||
if (authentication.getClass().equals(TenantUserPasswordAuthenticationToken.class)) {
|
if (authentication.getClass().equals(TenantUserPasswordAuthenticationToken.class)) {
|
||||||
systemManagement
|
systemManagement.getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant()
|
||||||
.getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant().toString());
|
.toString());
|
||||||
} else if (authentication.getClass().equals(UsernamePasswordAuthenticationToken.class)) {
|
} else if (authentication.getClass().equals(UsernamePasswordAuthenticationToken.class)) {
|
||||||
// TODO: MECS-1078 vaadin4spring-ext-security does not give us the
|
// TODO: MECS-1078 vaadin4spring-ext-security does not give us the
|
||||||
// fullyAuthenticatedToken
|
// fullyAuthenticatedToken
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.autoconfigure.swagger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
|
||||||
import springfox.documentation.builders.PathSelectors;
|
|
||||||
import springfox.documentation.schema.ModelRef;
|
|
||||||
import springfox.documentation.service.ApiInfo;
|
|
||||||
import springfox.documentation.service.ResponseMessage;
|
|
||||||
import springfox.documentation.spi.DocumentationType;
|
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Swagger configuration for RESTful SP server APIs.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableSwagger2
|
|
||||||
public class SwaggerApiDocAutoConfiguration {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the Springfox Docket, which generates the Information for the
|
|
||||||
* REST-Swagger-UI. Rest paths are: /rest/v1/. and ./controller/v1/.
|
|
||||||
*
|
|
||||||
* @see springfox.documentation.spring.web.plugins.Docket
|
|
||||||
*
|
|
||||||
* @return the v1 docket
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Docket customImplementation() {
|
|
||||||
return createDocket();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Predicate<String> selectApiPaths() {
|
|
||||||
return Predicates.or(PathSelectors.regex("/rest/v1/.*"), PathSelectors.regex("/.*/controller/v1/.*"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Docket createDocket() {
|
|
||||||
final List<ResponseMessage> authorizationMessages = globalAuhtorizationMessages();
|
|
||||||
return new Docket(DocumentationType.SWAGGER_2).select().paths(selectApiPaths()).build()
|
|
||||||
.useDefaultResponseMessages(true).globalResponseMessage(RequestMethod.GET, authorizationMessages)
|
|
||||||
.globalResponseMessage(RequestMethod.POST, authorizationMessages)
|
|
||||||
.globalResponseMessage(RequestMethod.PUT, authorizationMessages)
|
|
||||||
.globalResponseMessage(RequestMethod.DELETE, authorizationMessages).apiInfo(apiInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ResponseMessage> globalAuhtorizationMessages() {
|
|
||||||
final List<ResponseMessage> messageList = new ArrayList<>();
|
|
||||||
messageList.add(new ResponseMessage(200, "Request sucessfull", new ModelRef("com.")));
|
|
||||||
messageList.add(new ResponseMessage(400, "Bad Request - e.g. invalid parameters", null));
|
|
||||||
messageList.add(new ResponseMessage(401, "Unauthorized - The request requires user authentication.",
|
|
||||||
|
|
||||||
null));
|
|
||||||
messageList.add(
|
|
||||||
new ResponseMessage(403, "Forbidden - Insufficient permissions or data volume restriction applies.",
|
|
||||||
new ModelRef("ExceptionInfo")));
|
|
||||||
messageList.add(new ResponseMessage(405, "Method Not Allowed", null));
|
|
||||||
messageList.add(new ResponseMessage(406,
|
|
||||||
"Not Acceptable - In case accept header is specified and not application/json", null));
|
|
||||||
messageList.add(new ResponseMessage(429,
|
|
||||||
"Too many requests. The server will refuse further attemps and the client has to wait another second.",
|
|
||||||
null));
|
|
||||||
return messageList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ApiInfo apiInfo() {
|
|
||||||
return new ApiInfoBuilder().title("Software Provisioning API Descriptions").version(RestConstants.API_VERSION)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ui/UIAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ui/UIAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/PropertyHostnameResolverAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/PropertyHostnameResolverAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/ServerProperties.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/ServerProperties.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/WebMvcAutoConfiguration.java
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/WebMvcAutoConfiguration.java
Executable file → Normal file
1
hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories
Executable file → Normal file
1
hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories
Executable file → Normal file
@@ -3,7 +3,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|||||||
org.eclipse.hawkbit.autoconfigure.conf.DefaultPropertiesAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.conf.DefaultPropertiesAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.ui.UIAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.ui.UIAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.security.SecurityAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.security.SecurityAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.swagger.SwaggerApiDocAutoConfiguration,\
|
|
||||||
org.eclipse.hawkbit.autoconfigure.url.PropertyHostnameResolverAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.url.PropertyHostnameResolverAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.web.WebMvcAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.web.WebMvcAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.cache.CacheAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.cache.CacheAutoConfiguration,\
|
||||||
|
|||||||
0
hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties
Executable file → Normal file
0
hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties
Executable file → Normal file
0
hawkbit-cache-redis/pom.xml
Executable file → Normal file
0
hawkbit-cache-redis/pom.xml
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisProperties.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisProperties.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/annotation/EnableRedis.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/annotation/EnableRedis.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java
vendored
Executable file → Normal file
0
hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java
vendored
Executable file → Normal file
1
hawkbit-core/pom.xml
Executable file → Normal file
1
hawkbit-core/pom.xml
Executable file → Normal file
@@ -31,7 +31,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>18.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
|
|||||||
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/DistributedResourceBundleMessageSource.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/DistributedResourceBundleMessageSource.java
Executable file → Normal file
7
hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java
Executable file → Normal file
7
hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java
Executable file → Normal file
@@ -12,15 +12,14 @@ import java.net.URL;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve to reach the server url.
|
* Resolve to reach the server url.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface HostnameResolver {
|
public interface HostnameResolver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
URL resolveHostname();
|
URL resolveHostname();
|
||||||
|
|||||||
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreException.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreException.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/HashNotMatchException.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/HashNotMatchException.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifact.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifact.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifactHash.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifactHash.java
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/CacheConstants.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/CacheConstants.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadType.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadType.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenancyCacheManager.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenancyCacheManager.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java
vendored
Executable file → Normal file
0
hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java
vendored
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user