├── doc ├── binding │ ├── file.md │ ├── value.md │ ├── jsonpath+http.md │ ├── jadex.md │ ├── coap.md │ ├── mqtt.md │ └── akka.md ├── README.md ├── development │ └── README.md └── security │ └── README.md ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── wot-servient └── src │ ├── main │ ├── resources │ │ ├── reference.conf │ │ ├── jarcache.json │ │ └── project.properties │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ ├── wot │ │ ├── content │ │ │ ├── package-info.java │ │ │ ├── HtmlCodec.java │ │ │ ├── ContentCodecException.java │ │ │ └── CborCodec.java │ │ ├── package-info.java │ │ ├── binding │ │ │ ├── package-info.java │ │ │ ├── ProtocolClientException.java │ │ │ ├── ProtocolServerException.java │ │ │ ├── ProtocolClientNotImplementedException.java │ │ │ └── ProtocolServerNotImplementedException.java │ │ ├── thing │ │ │ ├── filter │ │ │ │ ├── package-info.java │ │ │ │ ├── ThingQueryException.java │ │ │ │ └── DiscoveryMethod.java │ │ │ ├── event │ │ │ │ ├── package-info.java │ │ │ │ └── EventState.java │ │ │ ├── action │ │ │ │ └── package-info.java │ │ │ ├── property │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── form │ │ │ │ └── package-info.java │ │ │ ├── security │ │ │ │ ├── package-info.java │ │ │ │ ├── NoSecurityScheme.java │ │ │ │ ├── PSKSecurityScheme.java │ │ │ │ └── PublicSecurityScheme.java │ │ │ ├── schema │ │ │ │ ├── package-info.java │ │ │ │ ├── AbstractDataSchema.java │ │ │ │ ├── NullSchema.java │ │ │ │ ├── NumberSchema.java │ │ │ │ ├── StringSchema.java │ │ │ │ ├── BooleanSchema.java │ │ │ │ ├── IntegerSchema.java │ │ │ │ ├── ArraySchema.java │ │ │ │ └── DataSchema.java │ │ │ ├── NoClientFactoryForSchemesConsumedThingException.java │ │ │ ├── ConsumedThingException.java │ │ │ └── NoFormForInteractionConsumedThingException.java │ │ ├── ServientConfigException.java │ │ ├── scripting │ │ │ ├── ScriptingException.java │ │ │ ├── ScriptingEngineException.java │ │ │ └── ScriptingManagerException.java │ │ ├── WotException.java │ │ ├── ServientException.java │ │ ├── ServientDiscoveryIgnore.java │ │ └── util │ │ │ └── LoggingUtil.java │ │ ├── ObjectBuilder.java │ │ ├── RefCountResourceException.java │ │ └── Futures.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── thing │ ├── schema │ ├── NullSchemaTest.java │ ├── NumberSchemaTest.java │ ├── ObjectSchemaTest.java │ ├── StringSchemaTest.java │ ├── BooleanSchemaTest.java │ ├── IntegerSchemaTest.java │ ├── ArraySchemaTest.java │ └── VariableDataSchemaTest.java │ ├── security │ └── NoSecuritySchemeTest.java │ └── filter │ └── ThingFilterTest.java ├── wot-servient-binding-coap └── src │ ├── main │ ├── resources │ │ └── reference.conf │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── coap │ │ ├── package-info.java │ │ └── resource │ │ ├── EventResource.java │ │ └── ObservePropertyResource.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── coap │ └── CoapProtocolClientFactoryTest.java ├── wot-servient-binding-akka ├── Makefile ├── README.md └── src │ └── main │ ├── resources │ └── reference.conf │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── akka │ └── AkkaProtocolPattern.java ├── wot-servient-binding-mqtt └── src │ ├── main │ ├── resources │ │ └── reference.conf │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── mqtt │ │ ├── package-info.java │ │ └── MqttProtocolException.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── mqtt │ └── MqttProtocolClientFactoryTest.java ├── wot-servient-examples ├── examples │ └── groovy-scripts │ │ ├── README.md │ │ ├── example-event-client.groovy │ │ └── example-dynamic.groovy └── src │ └── main │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── examples │ └── package-info.java ├── wot-servient-scripting-groovy └── src │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── org.codehaus.groovy.runtime.ExtensionModule │ └── groovy │ └── io │ └── github │ └── sanecity │ └── wot │ └── WotExtensions.groovy ├── wot-servient-binding-http └── src │ ├── main │ ├── resources │ │ └── reference.conf │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── http │ │ ├── package-info.java │ │ ├── route │ │ └── package-info.java │ │ ├── HttpsProtocolClientFactory.java │ │ ├── HttpProtocolClientFactory.java │ │ └── ContentResponseTransformer.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── http │ ├── HttpsProtocolClientFactoryTest.java │ ├── HttpProtocolClientFactoryTest.java │ └── ContentResponseTransformerTest.java ├── wot-servient-binding-jadex ├── README.md └── src │ ├── main │ ├── resources │ │ └── reference.conf │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── jadex │ │ ├── ThingsService.java │ │ └── ThingService.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── jadex │ └── JadexProtocolClientFactoryTest.java ├── Dockerfile ├── wot-servient-binding-websocket └── src │ ├── main │ ├── resources │ │ └── reference.conf │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── websocket │ │ ├── package-info.java │ │ ├── message │ │ ├── FinalResponse.java │ │ ├── SubscribeCompleteResponse.java │ │ ├── SubscribeErrorResponse.java │ │ ├── ClientErrorResponse.java │ │ ├── ServerErrorResponse.java │ │ ├── SubscribeNextResponse.java │ │ ├── ThingInteraction.java │ │ ├── InvokeActionResponse.java │ │ └── ThingInteractionWithContent.java │ │ └── handler │ │ └── codec │ │ └── TextWebSocketFrameEncoder.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── websocket │ └── WebsocketProtocolClientFactoryTest.java ├── wot-servient-integration-tests └── src │ └── test │ └── resources │ └── application.conf ├── .gitlab-ci.yml ├── wot-servient-cli ├── README.md └── src │ └── main │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── cli │ ├── CliShutdownException.java │ └── CliException.java ├── .gitlab-ci ├── Docker.gitlab-ci.yml └── Maven.gitlab-ci.yml ├── .github └── workflows │ └── maven.yml ├── LICENSE ├── wot-servient-binding-file ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── sanecity │ │ │ └── wot │ │ │ └── binding │ │ │ └── file │ │ │ ├── package-info.java │ │ │ └── FileProtocolClientFactory.java │ └── test │ │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── file │ │ └── FileProtocolClientFactoryTest.java └── pom.xml ├── wot-servient-binding-value ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── sanecity │ │ │ └── wot │ │ │ └── binding │ │ │ └── value │ │ │ ├── package-info.java │ │ │ ├── ValueProtocolClientFactory.java │ │ │ └── ValueProtocolClient.java │ └── test │ │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── value │ │ └── ValueProtocolClientFactoryTest.java └── pom.xml ├── wot-servient-binding-jsonpathhttp └── src │ ├── main │ └── java │ │ └── io │ │ └── github │ │ └── sanecity │ │ └── wot │ │ └── binding │ │ └── jsonpathhttp │ │ ├── package-info.java │ │ └── JsonpathHttpProtocolClientFactory.java │ └── test │ └── java │ └── io │ └── github │ └── sanecity │ └── wot │ └── binding │ └── jsonpathhttp │ └── JsonpathHttpProtocolClientFactoryTest.java ├── coverage-jacoco.sh ├── .gitignore └── .run └── Whole project.run.xml /doc/binding/file.md: -------------------------------------------------------------------------------- 1 | # File Binding 2 | 3 | Reads Thing Descriptions and property values from files. -------------------------------------------------------------------------------- /doc/binding/value.md: -------------------------------------------------------------------------------- 1 | # Value Binding 2 | 3 | This binding reads values directly from the Thing Description. -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sane-city/wot-servient/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /wot-servient/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | servers = null 4 | client-factories = null 5 | credentials {} 6 | } 7 | } -------------------------------------------------------------------------------- /wot-servient-binding-coap/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | coap { 4 | bind-port = 5683 5 | addresses = [] # example value: ["coap://127.0.0.1:5683"] 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /wot-servient-binding-akka/Makefile: -------------------------------------------------------------------------------- 1 | package: 2 | cd ../ && mvn -DskipTests clean install 3 | mvn -DskipTests clean package 4 | 5 | docker: 6 | docker build -t git.informatik.uni-hamburg.de:4567/bornholdt/sane-node-akka:wot-akka . 7 | -------------------------------------------------------------------------------- /wot-servient-binding-mqtt/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | mqtt { 4 | broker = "tcp://iot.eclipse.org" 5 | # username = "myusername" 6 | # password = "mysecretpassword" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /doc/binding/jsonpath+http.md: -------------------------------------------------------------------------------- 1 | # JSONPath+HTTP Binding 2 | 3 | This binding is based on the [HTTP binding](http.md). 4 | It allows you to apply JSON queries on the results given by the HTTP binding. 5 | This allows you to create Things based on complex JSON objects. -------------------------------------------------------------------------------- /wot-servient-examples/examples/groovy-scripts/README.md: -------------------------------------------------------------------------------- 1 | The examples contained in this directory can be used with the CLI of WoT Servient. 2 | 3 | **Example:** 4 | ```bash 5 | wot-servient counter.groovy 6 | wot-servient --clientonly counter-client.groovy 7 | ``` -------------------------------------------------------------------------------- /wot-servient-scripting-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule: -------------------------------------------------------------------------------- 1 | moduleName=Groovy Extensions 2 | moduleVersion=1.0.0 3 | extensionClasses=io.github.sanecity.wot.WotExtensions io.github.sanecity.wot.thing.ExposedThingExtensions -------------------------------------------------------------------------------- /wot-servient-binding-http/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | http { 4 | bind-host = "0.0.0.0" 5 | bind-port = 8080 6 | addresses = [] # example value: ["http://127.0.0.1:8080"] 7 | security { 8 | scheme = null 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /wot-servient/src/main/resources/jarcache.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Content-Location": "http://www.w3.org/2019/wot/td/v1", 4 | "X-Classpath": "w3c-wot-td-context.jsonld", 5 | "Content-Type": "application/ld+json" 6 | }, 7 | { 8 | "Content-Location": "https://www.w3.org/2019/wot/td/v1", 9 | "X-Classpath": "w3c-wot-td-context.jsonld", 10 | "Content-Type": "application/ld+json" 11 | } 12 | ] -------------------------------------------------------------------------------- /wot-servient-binding-jadex/README.md: -------------------------------------------------------------------------------- 1 | This module uses [Jadex](https://www.activecomponents.org/#/project/news) to connect distributed nodes running the WoT 2 | implementation. 3 | 4 | Jadex built-in discovery function is used. In addition, Jadex allows interaction of nodes that do not have a direct 5 | connection (e.g. nodes behind NAT). 6 | 7 | ## Examples 8 | 9 | Examples can be found in the `io.github.sanecity.wot.examples` package. -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM kubeless/unzip AS build 2 | 3 | ADD ./wot-servient-*.zip . 4 | 5 | RUN unzip -qq ./wot-servient-*.zip && \ 6 | rm ./wot-servient-*.zip 7 | 8 | FROM openjdk:11-jre-slim 9 | 10 | RUN mkdir /usr/local/share/wot-servient && \ 11 | ln -s ../share/wot-servient/bin/wot-servient /usr/local/bin/wot-servient 12 | 13 | COPY --from=build ./wot-servient-* /usr/local/share/wot-servient/ 14 | 15 | # http coap 16 | EXPOSE 8080 5683 17 | 18 | ENTRYPOINT ["wot-servient"] 19 | -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | servers = [ 4 | "io.github.sanecity.wot.binding.websocket.WebsocketProtocolServer", 5 | ] 6 | 7 | client-factories = [ 8 | "io.github.sanecity.wot.binding.websocket.WebsocketProtocolClientFactory", 9 | ] 10 | 11 | websocket { 12 | bind-host = "0.0.0.0" 13 | bind-port = 8081 14 | addresses = [] # example value: ["ws://127.0.0.1:8081"] 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /wot-servient-binding-jadex/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | jadex { 4 | jcc = false // GUI 5 | jccweb = false 6 | chat = false 7 | cli = false 8 | debugfutures = true 9 | // relayaddresses = "https://sane1.informatik.uni-hamburg.de" 10 | // catalogawareness.platformurls = "ws://ssp1@sane1.informatik.uni-hamburg.de:80" 11 | // networknames = "SANE" 12 | // networksecrets = "SANESANESANE" 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /wot-servient-integration-tests/src/test/resources/application.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | coap { 4 | # let OS select a free port. See: https://git.informatik.uni-hamburg.de/sane-public/wot-servient/issues/15 5 | bind-port = 0 6 | } 7 | 8 | http { 9 | # let OS select a free port. 10 | bind-port = 0 11 | } 12 | 13 | mqtt { 14 | broker = "tcp://localhost:1883" # change to "localhost" to run tests locally 15 | # username = "myusername" 16 | # password = "mysecretpassword" 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /doc/binding/jadex.md: -------------------------------------------------------------------------------- 1 | # Jadex Binding 2 | 3 | Uses [Jadex](https://www.activecomponents.org/) for the interaction with Things. 4 | Jadex enables the development of distributed service-based applications. 5 | The protocol client and server share an Jadex Platform. 6 | 7 | ## Configuration 8 | 9 | To add Websocket support to the Servient, `"io.github.sanecity.wot.binding.jadex.JadexProtocolServer"` must be added to Config parameter `wot.servient.servers` 10 | and 11 | `"io.github.sanecity.wot.binding.jadex.JadexProtocolClientFactory"` must be added to parameter 12 | `wot.servient.client-factories`. -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - local: /.gitlab-ci/Maven.gitlab-ci.yml # we have to use our own template, since GitLab's template uses JDK8, but we need JDK11 3 | # - template: Dependency-Scanning.gitlab-ci.yml 4 | # - template: Code-Quality.gitlab-ci.yml 5 | - local: /.gitlab-ci/Docker.gitlab-ci.yml 6 | # - template: License-Management.gitlab-ci.yml 7 | # - template: SAST.gitlab-ci.yml 8 | 9 | #license_management: 10 | # variables: 11 | # MAVEN_CLI_OPTS: -DskipTests 12 | # LM_JAVA_VERSION: 11 13 | # 14 | #sast: 15 | # variables: 16 | # MAVEN_CLI_OPTS: -DskipTests 17 | # SAST_JAVA_VERSION: 11 18 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # SANE Web of Things Servient Documentation 2 | 3 | Welcome to [SANE Web of Things Servient](https://github.com/sane-city/wot-servient) Documentation. 4 | 5 | ## Overview 6 | 7 | [**Protocol Bindings**](binding/README.md)
Information about the different supported protocols for communication with Things (HTTP, CoAP, MQTT, etc.). 8 | 9 | [**Security Schemes**](security/README.md)
Information about the different supported security schemes for communication with Things (Basic, Bearer, OAuth, PSK, etc.). 10 | 11 | [**Development**](development/README.md)
Information for developers about conventions and workflows (release new version, etc.). -------------------------------------------------------------------------------- /wot-servient-cli/README.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | ### Builds 4 | 5 | The current version of the CLI can be downloaded from the following address: https://git.informatik.uni-hamburg.de/sane-public/wot-servient/-/jobs/artifacts/master/download?job=build-dist 6 | 7 | Show help: 8 | ```bash 9 | bin/wot-servient -h 10 | ``` 11 | 12 | Execute all WoT scripts from the current directory 13 | ```bash 14 | bin/wot-servient 15 | ``` 16 | 17 | ## Docker 18 | 19 | Show help: 20 | ```bash 21 | docker run --rm -ti sanecity/wot-servient -h 22 | ``` 23 | 24 | Execute all WoT scripts from the directory `./wot-scripts` 25 | ```bash 26 | docker run --rm -ti -v ./wot-scripts:/wot-servient/ sanecity/wot-servient 27 | ``` -------------------------------------------------------------------------------- /wot-servient-binding-akka/README.md: -------------------------------------------------------------------------------- 1 | This module uses [Akka](https://akka.io/) to connect different distributed nodes running the WoT implementation. 2 | 3 | For the discovery the cluster function of Akka is used. 4 | This extension also enables interaction with Things via HTTP. 5 | 6 | ## Examples 7 | 8 | Examples can be found in the `io.github.sanecity.wot.examples` package. 9 | 10 | ## Other stuff 11 | 12 | cd /sane-node-akka mvn clean install cd ./wot-akka mvn -DskipTests clean install mvn -DskipTests clean package 13 | 14 | java -cp ./target/wot-akka-1.0-SNAPSHOT.jar -Dconfig.file=/opt/application.conf io.github.sanecity.examples.Klimabotschafter 15 | 16 | docker build -t git.informatik.uni-hamburg.de:4567/bornholdt/sane-node-akka:wot-akka . 17 | 18 | docker run -ti --rm -P git.informatik.uni-hamburg.de:4567/bornholdt/sane-node-akka:wot-akka io.github.sanecity.wot.examples.Klimabotschafter -------------------------------------------------------------------------------- /.gitlab-ci/Docker.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | .docker: &docker 2 | stage: .post 3 | # Official docker image. 4 | image: docker:latest 5 | services: 6 | - docker:dind 7 | before_script: 8 | - docker login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" $CI_REGISTRY 9 | tags: 10 | - docker 11 | 12 | docker-build-master: 13 | <<: *docker 14 | script: 15 | - docker build --pull --tag "$CI_REGISTRY_IMAGE" . 16 | # minimal test 17 | - docker run --rm "$CI_REGISTRY_IMAGE" --help 18 | - docker push "$CI_REGISTRY_IMAGE" 19 | only: 20 | - master 21 | 22 | docker-build: 23 | <<: *docker 24 | script: 25 | - docker build --pull --tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . 26 | # minimal test 27 | - docker run --rm "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" --help 28 | - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" 29 | except: 30 | - master -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | services: 18 | mosquitto: 19 | image: eclipse-mosquitto:1.6 20 | ports: 21 | - 1883:1883 22 | 23 | steps: 24 | - uses: actions/checkout@v2 25 | - name: Set up JDK 11 26 | uses: actions/setup-java@v2 27 | with: 28 | java-version: '11' 29 | distribution: 'adopt' 30 | - name: Cache Maven packages 31 | uses: actions/cache@v2.1.6 32 | with: 33 | path: ~/.m2 34 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 35 | restore-keys: ${{ runner.os }}-m2 36 | - name: Build with Maven 37 | run: ./mvnw -B verify --file pom.xml 38 | -------------------------------------------------------------------------------- /doc/binding/coap.md: -------------------------------------------------------------------------------- 1 | # CoAP Binding 2 | 3 | Uses the Constrained Application Protocol for interaction with Things. 4 | 5 | ## Configuration 6 | 7 | To add CoAP support to the Servient, `"io.github.sanecity.wot.binding.coap.CoapProtocolServer"` must be added to Config parameter `wot.servient.servers` and 8 | `"io.github.sanecity.wot.binding.coap.CoapProtocolClientFactory"` must be added to parameter 9 | `wot.servient.client-factories`. 10 | 11 | All configurations associated with COAP Binding are located in the `wot.servient.coap` namespace: 12 | 13 | | Parameter | Explanation | Default Value | 14 | |-------------------|---------------|---------------| 15 | | `bind-port` | Port that CoAP server should listen on.
A port number of `0` means that the port number is automatically allocated. | `5683` | 16 | | `addresses` | List of URLs, which are used in the Thing Description as accessible addresses. If no addresses are specified, the service automatically determines its local addresses. However, it may be necessary to set the address manually, for example when using Docker. | `[]` | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019-2022 Heiko Bornholdt 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 15 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 18 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 19 | OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /wot-servient/src/main/resources/project.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2022 Heiko Bornholdt 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in all 12 | # copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | # OR OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | version=${project.version} (${git.commit.id.abbrev}) -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket; -------------------------------------------------------------------------------- /wot-servient-examples/src/main/java/io/github/sanecity/wot/examples/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Examples for using the WoT Servient. 24 | */ 25 | package io.github.sanecity.wot.examples; -------------------------------------------------------------------------------- /wot-servient-binding-coap/src/main/java/io/github/sanecity/wot/binding/coap/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Thing Interaction support for CoAP. 24 | */ 25 | package io.github.sanecity.wot.binding.coap; -------------------------------------------------------------------------------- /wot-servient-binding-http/src/main/java/io/github/sanecity/wot/binding/http/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Thing Interaction support for HTTP. 24 | */ 25 | package io.github.sanecity.wot.binding.http; -------------------------------------------------------------------------------- /wot-servient-binding-mqtt/src/main/java/io/github/sanecity/wot/binding/mqtt/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Thing Interaction support for MQTT. 24 | */ 25 | package io.github.sanecity.wot.binding.mqtt; -------------------------------------------------------------------------------- /wot-servient-binding-file/src/main/java/io/github/sanecity/wot/binding/file/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Thing Interaction support for local files. 24 | */ 25 | package io.github.sanecity.wot.binding.file; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/content/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Provides an extensible interface for processing data in various formats. 24 | */ 25 | package io.github.sanecity.wot.content; -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/FinalResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | public interface FinalResponse { 25 | } 26 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * W3C Web of Things (WoT) implementation in Java.
See also: https://www.w3.org/TR/wot-architecture/ 24 | */ 25 | package io.github.sanecity.wot; -------------------------------------------------------------------------------- /wot-servient-binding-http/src/main/java/io/github/sanecity/wot/binding/http/route/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Defines the different endpoints for the HTTP server. 24 | */ 25 | package io.github.sanecity.wot.binding.http.route; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/binding/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Provides an extensible interface for exposing and consuming things using various protocols. 24 | */ 25 | package io.github.sanecity.wot.binding; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/filter/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Includes several implementations for filtering things in the discovery process. 24 | */ 25 | package io.github.sanecity.wot.thing.filter; -------------------------------------------------------------------------------- /wot-servient-binding-value/src/main/java/io/github/sanecity/wot/binding/value/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Thing Interaction support for values stored in Thing Descriptions. 24 | */ 25 | package io.github.sanecity.wot.binding.value; -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2022 Heiko Bornholdt 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in all 12 | # copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | # OR OTHER DEALINGS IN THE SOFTWARE. 21 | # 22 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 23 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 24 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/event/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Everything that belongs to Web of Thing Events.
See also: https://www.w3.org/TR/wot-architecture/#events 24 | */ 25 | package io.github.sanecity.wot.thing.event; -------------------------------------------------------------------------------- /doc/development/README.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | ## Release new version 4 | 5 | ```bash 6 | rm -f release.properties 7 | mvn clean -DskipTests -Darguments=-DskipTests release:prepare 8 | ``` 9 | 10 | **An additional call of `mvn release:perform` is not necessary!** 11 | 12 | Wait for GitLab CI to finish build tasks and select "Keep" on job artifact. 13 | 14 | Add Release Notes to git Tag on [GitLab](https://git.informatik.uni-hamburg.de/sane-public/wot-servient/-/tags). 15 | 16 | Add Asset to Release 17 | 18 | ```bash 19 | curl --request POST \ 20 | --header "PRIVATE-TOKEN: s3cr3tPassw0rd" \ 21 | --data name="wot-servient-1.2.zip" \ 22 | --data url="https://git.informatik.uni-hamburg.de/sane-public/wot-servient/-/jobs/artifacts/1.2/raw/wot-servient-1.2.zip?job=maven-deploy" \ 23 | "https://git.informatik.uni-hamburg.de/api/v4/projects/2707/releases/1.2/assets/links" 24 | ``` 25 | 26 | ## Build dist 27 | 28 | ```bash 29 | mvn -DskipTests -pl wot-servient-cli -am package 30 | # wot-servient-cli/target/wot-servient-*.zip generated 31 | ``` 32 | 33 | ## Build and Push Docker Image 34 | 35 | ```bash 36 | docker build -t git.informatik.uni-hamburg.de:4567/sane-public/wot-servient:latest . 37 | docker push git.informatik.uni-hamburg.de:4567/sane-public/wot-servient:latest 38 | ``` 39 | 40 | ## Code Style 41 | 42 | We use a custom Java code style for which is described in the following file (IntelliJ IDEA only) [SANE.xml](../SANE.xml). -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/action/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Everything that belongs to Web of Thing Actions.
See also: https://www.w3.org/TR/wot-architecture/#actions 24 | */ 25 | package io.github.sanecity.wot.thing.action; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/property/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Everything that belongs to Web of Thing Events.
See also: https://www.w3.org/TR/wot-architecture/#events 24 | */ 25 | package io.github.sanecity.wot.thing.property; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Includes classes for defining and interacting with Things.
See also: 24 | * https://www.w3.org/TR/wot-architecture/#sec-web-thing 25 | */ 26 | package io.github.sanecity.wot.thing; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/form/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Everything that belongs to Web of Thing Forms.
See also: https://www.w3.org/TR/wot-architecture/#sec-hypermedia-forms 24 | */ 25 | package io.github.sanecity.wot.thing.form; 26 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/security/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Security relevant stuff to Things.
See also: https://www.w3.org/TR/wot-thing-description/#sec-security-vocabulary-definition 24 | */ 25 | package io.github.sanecity.wot.thing.security; -------------------------------------------------------------------------------- /wot-servient-binding-jsonpathhttp/src/main/java/io/github/sanecity/wot/binding/jsonpathhttp/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Thing Interaction support for HTTP with support for manipulation of return values using JSON 24 | * queries. 25 | */ 26 | package io.github.sanecity.wot.binding.jsonpathhttp; -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | /** 23 | * Describes the schema of data used in Thing Interaction.
See also: 24 | * https://www.w3.org/TR/wot-thing-description/#sec-data-schema-vocabulary-definition 25 | */ 26 | package io.github.sanecity.wot.thing.schema; -------------------------------------------------------------------------------- /wot-servient-binding-akka/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | wot { 2 | servient { 3 | akka { 4 | system-name = "wot" 5 | ask-timeout = 60s 6 | discover-timeout = 5s 7 | 8 | // log-config-on-start = "on" 9 | 10 | # use SLF4J as logger 11 | # https://doc.akka.io/docs/akka/current/logging.html#slf4j 12 | loggers = ["akka.event.slf4j.Slf4jLogger"] 13 | # Options: OFF, ERROR, WARNING, INFO, DEBUG 14 | loglevel = "WARNING" 15 | logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" 16 | 17 | actor { 18 | provider = "cluster" 19 | 20 | serialization-bindings { 21 | "io.github.sanecity.wot.binding.akka.Message" = jackson-json 22 | } 23 | } 24 | 25 | remote { 26 | artery { 27 | transport = tcp 28 | canonical.hostname = "127.0.0.1" 29 | canonical.port = 25520 30 | } 31 | } 32 | 33 | cluster { 34 | seed-nodes = [ 35 | "akka://wot@127.0.0.1:25520", 36 | ] 37 | 38 | # auto downing is NOT safe for production deployments. 39 | # you may want to use it during development, read more about it in the docs. 40 | auto-down-unreachable-after = 10s 41 | 42 | # silence the logging of cluster events at info level 43 | log-info = off 44 | 45 | jmx.multi-mbeans-in-same-jvm = on 46 | } 47 | 48 | extensions = ["akka.cluster.pubsub.DistributedPubSub"] 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/ObjectBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity; 23 | 24 | /** 25 | * This interface helps to implement the Builder 26 | * Pattern. 27 | * 28 | * @param 29 | */ 30 | public interface ObjectBuilder { 31 | T build(); 32 | } 33 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/content/HtmlCodec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.content; 23 | 24 | /** 25 | * (De)serializes data in HTML format. 26 | */ 27 | public class HtmlCodec extends TextCodec { 28 | @Override 29 | public String getMediaType() { 30 | return "text/html"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /wot-servient-cli/src/main/java/io/github/sanecity/wot/cli/CliShutdownException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.cli; 23 | 24 | /** 25 | * This exception is thrown when the command line interface should terminate. 26 | */ 27 | public class CliShutdownException extends RuntimeException { 28 | public CliShutdownException() { 29 | super(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /doc/binding/mqtt.md: -------------------------------------------------------------------------------- 1 | # MQTT Binding 2 | 3 | This binding uses a Message Queuing Telemetry Transport broker to interact with Things. 4 | 5 | The Thing Descriptions of all exposed Things are published as retainable messages on the Broker. The topic corresponds to the Thing Description. 6 | 7 | ## Configuration 8 | 9 | To add MQTT support to the Servient, `"io.github.sanecity.wot.binding.mqtt.MqttProtocolServer"` must be added to Config parameter `wot.servient.servers` and 10 | `"io.github.sanecity.wot.binding.mqtt.MqttProtocolClientFactory"` must be added to parameter 11 | `wot.servient.client-factories`. 12 | 13 | All configurations associated with MQTT Binding are located in the `wot.servient.mqtt` namespace: 14 | 15 | | Parameter | Explanation | Default Value | 16 | |---------------|---------------|---------------| 17 | | `broker` | Address of broker to connect to, specified as a URI | `"tcp://iot.eclipse.org"` 18 | | `username` | The username for the connection | | 19 | | `password` | The password for the connection | | 20 | | `client-id` | A client identifier that is unique on the broker being connected to | randomly generated value | 21 | 22 | ### Example 23 | ```hocon 24 | wot { 25 | servient { 26 | servers = [ 27 | "io.github.sanecity.wot.binding.mqtt.MqttProtocolServer", 28 | ] 29 | 30 | client-factories = [ 31 | "io.github.sanecity.wot.binding.mqtt.MqttProtocolClientFactory", 32 | ] 33 | 34 | mqtt { 35 | broker = "tcp://iot.eclipse.org" 36 | username = "" 37 | password = "" 38 | } 39 | } 40 | } 41 | ``` -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/ServientConfigException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot; 23 | 24 | /** 25 | * A ServientConfigException is thrown by the {@link ServientConfig} when errors occur. 26 | */ 27 | public class ServientConfigException extends ServientException { 28 | public ServientConfigException(Exception cause) { 29 | super(cause); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/scripting/ScriptingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.scripting; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | public abstract class ScriptingException extends ServientException { 27 | public ScriptingException(String message) { 28 | super(message); 29 | } 30 | 31 | public ScriptingException(Throwable cause) { 32 | super(cause); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /doc/security/README.md: -------------------------------------------------------------------------------- 1 | # Security Schemes Bindings 2 | 3 | Here you will find information about the security schemes supported by the WoT Servient. 4 | Security schemes are intended to restrict interaction with Things to authorized clients. 5 | Various mechanisms are available for authorization. 6 | 7 | Further information can be found in [W3C Web of Things Security Ontology](https://www.w3.org/2019/wot/security). 8 | 9 | The [Protocol Bindings](../binding/README.md) section describes which protocol supports which authentication mechanism. 10 | In addition, the page for each protocol describes how the server can be configured for the desired authentication mechanism. 11 | 12 | This page describes which credentials have to be defined for the different mechanisms in the service. 13 | 14 | ## Define Credentials 15 | 16 | All credentials are located in the parameter `wot.credentials`. This parameter contains a map with the Thing IDs as keys and 17 | the respective credentials for each Thing. 18 | 19 | ### Example 20 | ```hocon 21 | wot { 22 | servient { 23 | ... 24 | credentials { 25 | counter { 26 | username = "foo" 27 | password = "bar" 28 | } 29 | temperatur { 30 | token = "pu7eevaeH4Ie" 31 | } 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ## basic 38 | 39 | | Parameter | Explanation | 40 | |-----------|-------------| 41 | | `username` | The username used for basic authentification. 42 | | `password` | The password used for basic authentification. 43 | 44 | 45 | ## bearer 46 | 47 | | Parameter | Explanation | 48 | |-----------|-------------| 49 | | `token` | The token used for bearer authentification. -------------------------------------------------------------------------------- /wot-servient-binding-http/src/test/java/io/github/sanecity/wot/binding/http/HttpsProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.http; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class HttpsProtocolClientFactoryTest { 29 | @Test 30 | public void getScheme() { 31 | assertEquals("https", new HttpsProtocolClientFactory().getScheme()); 32 | } 33 | } -------------------------------------------------------------------------------- /wot-servient-binding-mqtt/src/test/java/io/github/sanecity/wot/binding/mqtt/MqttProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.mqtt; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class MqttProtocolClientFactoryTest { 29 | @Test 30 | public void getScheme() { 31 | assertEquals("mqtt", new MqttProtocolClientFactory(null).getScheme()); 32 | } 33 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/scripting/ScriptingEngineException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.scripting; 23 | 24 | /** 25 | * A ScriptingEngineException is thrown by Implementations of {@link ScriptingEngine} when errors 26 | * occur. 27 | */ 28 | @SuppressWarnings({ "java:S110" }) 29 | class ScriptingEngineException extends ScriptingException { 30 | public ScriptingEngineException(Throwable cause) { 31 | super(cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /wot-servient-binding-jadex/src/main/java/io/github/sanecity/wot/binding/jadex/ThingsService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.jadex; 23 | 24 | import jadex.bridge.IExternalAccess; 25 | import jadex.commons.future.IFuture; 26 | 27 | /** 28 | * Defines the Jadex Service interface for the exposing and no longer exposing of Things. 29 | */ 30 | public interface ThingsService { 31 | IFuture expose(String id); 32 | 33 | IFuture destroy(String id); 34 | } 35 | -------------------------------------------------------------------------------- /wot-servient-cli/src/main/java/io/github/sanecity/wot/cli/CliException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.cli; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | /** 27 | * A CliException is thrown by the {@link Cli} when errors occur. 28 | */ 29 | class CliException extends ServientException { 30 | public CliException(String message) { 31 | super(message); 32 | } 33 | 34 | public CliException(Throwable cause) { 35 | super(cause); 36 | } 37 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/RefCountResourceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity; 23 | 24 | /** 25 | * A RefCountResourceException is thrown by the {@link RefCountResource} when errors occur. 26 | */ 27 | public class RefCountResourceException extends Exception { 28 | public RefCountResourceException(String message) { 29 | super(message); 30 | } 31 | 32 | public RefCountResourceException(Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /wot-servient-binding-mqtt/src/main/java/io/github/sanecity/wot/binding/mqtt/MqttProtocolException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.mqtt; 23 | 24 | /** 25 | * A MqttProtocolException is thrown by mqtt binding when errors occur. 26 | */ 27 | class MqttProtocolException extends Exception { 28 | public MqttProtocolException(String message) { 29 | super(message); 30 | } 31 | 32 | public MqttProtocolException(Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/WotException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot; 23 | 24 | /** 25 | * A WotException is thrown by {@link Wot} implementations when errors occur. 26 | */ 27 | public class WotException extends Exception { 28 | public WotException(String message) { 29 | super(message); 30 | } 31 | 32 | public WotException(Throwable cause) { 33 | super(cause); 34 | } 35 | 36 | public WotException() { 37 | super(); 38 | } 39 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/NoClientFactoryForSchemesConsumedThingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing; 23 | 24 | import java.util.Set; 25 | 26 | @SuppressWarnings({ "java:S110" }) 27 | class NoClientFactoryForSchemesConsumedThingException extends ConsumedThingException { 28 | public NoClientFactoryForSchemesConsumedThingException(String title, Set schemes) { 29 | super("'" + title + "': Missing ClientFactory for schemes '" + schemes + "'"); 30 | } 31 | } -------------------------------------------------------------------------------- /coverage-jacoco.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # 5 | # Copyright (c) 2019-2022 Heiko Bornholdt 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 21 | # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 23 | # OR OTHER DEALINGS IN THE SOFTWARE. 24 | # 25 | inputs="" 26 | for D in *; do 27 | if [ -d "${D}" ]; then 28 | jac="$D/target/site/jacoco/jacoco.csv" 29 | if [ -f "$jac" ]; then 30 | inputs="$inputs $jac" 31 | fi 32 | fi 33 | done 34 | 35 | # sum csv values and output as: 36 | # 10 / 20 instructions covered 37 | # 50,00 % covered 38 | awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' $inputs 39 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/ServientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot; 23 | 24 | /** 25 | * A ServientException is thrown by the {@link Servient} when errors occur. 26 | */ 27 | public class ServientException extends WotException { 28 | public ServientException(String message) { 29 | super(message); 30 | } 31 | 32 | public ServientException(Throwable cause) { 33 | super(cause); 34 | } 35 | 36 | public ServientException() { 37 | super(); 38 | } 39 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/content/ContentCodecException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.content; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | /** 27 | * If errors occur during (de)serialization, this exception is thrown. 28 | */ 29 | public class ContentCodecException extends ServientException { 30 | public ContentCodecException(String message) { 31 | super(message); 32 | } 33 | 34 | public ContentCodecException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/NullSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class NullSchemaTest { 29 | @Test 30 | public void getType() { 31 | assertEquals("null", new NullSchema().getType()); 32 | } 33 | 34 | @Test 35 | public void getClassType() { 36 | assertEquals(Object.class, new NullSchema().getClassType()); 37 | } 38 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/ConsumedThingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | /** 27 | * A ConsumedThingException is thrown by {@link ConsumedThing} when errors occur. 28 | */ 29 | public class ConsumedThingException extends ServientException { 30 | public ConsumedThingException(String message) { 31 | super(message); 32 | } 33 | 34 | public ConsumedThingException(Throwable cause) { 35 | super(cause); 36 | } 37 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/filter/ThingQueryException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.filter; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | /** 27 | * This exception is thrown when an invalid query is attempted to be used. 28 | */ 29 | public class ThingQueryException extends ServientException { 30 | public ThingQueryException(Throwable cause) { 31 | super(cause); 32 | } 33 | 34 | public ThingQueryException(String message) { 35 | super(message); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wot-servient-binding-coap/src/main/java/io/github/sanecity/wot/binding/coap/resource/EventResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.coap.resource; 23 | 24 | import io.github.sanecity.wot.thing.event.ExposedThingEvent; 25 | 26 | /** 27 | * Endpoint for interaction with a {@link io.github.sanecity.wot.thing.event.ThingEvent}. 28 | */ 29 | public class EventResource extends AbstractSubscriptionResource { 30 | public EventResource(String name, ExposedThingEvent event) { 31 | super(name, name, event.observer()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/scripting/ScriptingManagerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.scripting; 23 | 24 | /** 25 | * A ScriptingManagerException is thrown by {@link ScriptingManager} when errors occur. 26 | */ 27 | @SuppressWarnings({ "java:S110" }) 28 | class ScriptingManagerException extends ScriptingException { 29 | public ScriptingManagerException(String message) { 30 | super(message); 31 | } 32 | 33 | public ScriptingManagerException(Throwable cause) { 34 | super(cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/NumberSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class NumberSchemaTest { 29 | @Test 30 | public void getType() { 31 | assertEquals("number", new NumberSchema().getType()); 32 | } 33 | 34 | @Test 35 | public void getClassType() { 36 | assertEquals(Number.class, new NumberSchema().getClassType()); 37 | } 38 | } -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/ObjectSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class ObjectSchemaTest { 29 | @Test 30 | public void getType() { 31 | assertEquals("string", new StringSchema().getType()); 32 | } 33 | 34 | @Test 35 | public void getClassType() { 36 | assertEquals(String.class, new StringSchema().getClassType()); 37 | } 38 | } -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/StringSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class StringSchemaTest { 29 | @Test 30 | public void getType() { 31 | assertEquals("string", new StringSchema().getType()); 32 | } 33 | 34 | @Test 35 | public void getClassType() { 36 | assertEquals(String.class, new StringSchema().getClassType()); 37 | } 38 | } -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/BooleanSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class BooleanSchemaTest { 29 | @Test 30 | public void getType() { 31 | assertEquals("boolean", new BooleanSchema().getType()); 32 | } 33 | 34 | @Test 35 | public void getClassType() { 36 | assertEquals(Boolean.class, new BooleanSchema().getClassType()); 37 | } 38 | } -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/IntegerSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class IntegerSchemaTest { 29 | @Test 30 | public void getType() { 31 | assertEquals("integer", new IntegerSchema().getType()); 32 | } 33 | 34 | @Test 35 | public void getClassType() { 36 | assertEquals(Integer.class, new IntegerSchema().getClassType()); 37 | } 38 | } -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/ArraySchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import java.util.List; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class ArraySchemaTest { 31 | @Test 32 | public void getType() { 33 | assertEquals("array", new ArraySchema().getType()); 34 | } 35 | 36 | @Test 37 | public void getClassType() { 38 | assertEquals(List.class, new ArraySchema().getClassType()); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/binding/ProtocolClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | /** 27 | * A ProtocolClientException is thrown by {@link ProtocolClient} implementations when errors occur. 28 | */ 29 | public class ProtocolClientException extends ServientException { 30 | public ProtocolClientException(String message) { 31 | super(message); 32 | } 33 | 34 | public ProtocolClientException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /doc/binding/akka.md: -------------------------------------------------------------------------------- 1 | # Akka Binding 2 | 3 | Uses [Akka](https://akka.io/) for the interaction with Things. 4 | Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala. 5 | The protocol client and server share an ActorSystem. 6 | 7 | The actor system created by this binding uses [Akka Cluster](https://doc.akka.io/docs/akka/current/typed/cluster.html) by default. 8 | 9 | ## Configuration 10 | 11 | To add Akka support to the Servient, `"io.github.sanecity.wot.binding.akka.AkkaProtocolServer"` must be added to Config parameter `wot.servient.servers` and 12 | `"io.github.sanecity.wot.binding.akka.AkkaProtocolClientFactory"` must be added to parameter 13 | `wot.servient.client-factories`. 14 | 15 | All configurations associated with Akka Binding are located in the `wot.servient.akka` namespace: 16 | 17 | | Parameter | Explanation | Default Value | 18 | |-------------------|---------------|---------------| 19 | | `system-name` | Name of the ActorSystem. | `"wot"` 20 | | `ask-timeout` | Time how long Akka should wait for answers before the request fails. | `60s` 21 | | `discover-timeout` | Time how long Akka should wait for answers from a Thing Discovery before the Discovery is considered finished. | `5s` 22 | 23 | All parameters in this namespace are passed directly to Akka and are used to configure the underlying actor system (e.g. the parameter 24 | `wot.servient.akka.actor.provider` is passed as `akka.actor.provider` to the ActorSystem). 25 | 26 | This documentation only lists the configuration parameters relevant for the WoT Servient. For the general configuration of Akka, please refer to the Akka 27 | Documentation: https://doc.akka.io/docs/akka/current/general/configuration.html#custom-application-conf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # https://raw.githubusercontent.com/github/gitignore/master/Java.gitignore 3 | # 4 | 5 | # Compiled class file 6 | *.class 7 | 8 | # Log file 9 | *.log 10 | 11 | # BlueJ files 12 | *.ctxt 13 | 14 | # Mobile Tools for Java (J2ME) 15 | .mtj.tmp/ 16 | 17 | # Package Files # 18 | *.jar 19 | *.war 20 | *.nar 21 | *.ear 22 | *.zip 23 | *.tar.gz 24 | *.rar 25 | 26 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 27 | hs_err_pid* 28 | 29 | # 30 | # https://raw.githubusercontent.com/github/gitignore/master/Maven.gitignore 31 | # 32 | 33 | target/ 34 | pom.xml.tag 35 | pom.xml.releaseBackup 36 | pom.xml.versionsBackup 37 | pom.xml.next 38 | release.properties 39 | dependency-reduced-pom.xml 40 | buildNumber.properties 41 | .mvn/timing.properties 42 | 43 | # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) 44 | !/.mvn/wrapper/maven-wrapper.jar 45 | 46 | # 47 | # https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore 48 | # 49 | 50 | # General 51 | .DS_Store 52 | .AppleDouble 53 | .LSOverride 54 | 55 | # Icon must end with two \r 56 | Icon 57 | 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | # 79 | # Own Rules 80 | # 81 | 82 | # IntelliJ IDEA 83 | .idea/ 84 | *.iml 85 | 86 | # eclipse 87 | 88 | .settings 89 | .classpath 90 | .project 91 | .gradle 92 | 93 | # Jadex 94 | settings_* 95 | 96 | # own 97 | Californium.properties 98 | -------------------------------------------------------------------------------- /wot-servient-binding-file/src/main/java/io/github/sanecity/wot/binding/file/FileProtocolClientFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.file; 23 | 24 | import io.github.sanecity.wot.binding.ProtocolClientFactory; 25 | 26 | /** 27 | * Creates new {@link FileProtocolClient} instances. 28 | */ 29 | public class FileProtocolClientFactory implements ProtocolClientFactory { 30 | @Override 31 | public String getScheme() { 32 | return "file"; 33 | } 34 | 35 | @Override 36 | public FileProtocolClient getClient() { 37 | return new FileProtocolClient(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wot-servient-examples/examples/groovy-scripts/example-event-client.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | wot.fetch('http://localhost:8080/EventSource').thenAccept { td -> 23 | println('=== TD ===') 24 | println(td.toJson(true)) 25 | println('==========') 26 | 27 | def source = wot.consume(td) 28 | 29 | source.events.onchange.observer().subscribe( 30 | { x -> println('onNext: ' + x) }, 31 | { e -> println('onError: ' + e) }, 32 | { -> println('onCompleted') } 33 | ) 34 | println('Subscribed') 35 | }.join() 36 | 37 | println('Press ENTER to exit the client') 38 | System.in.read() -------------------------------------------------------------------------------- /wot-servient-binding-value/src/main/java/io/github/sanecity/wot/binding/value/ValueProtocolClientFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.value; 23 | 24 | import io.github.sanecity.wot.binding.ProtocolClientFactory; 25 | 26 | /** 27 | * Creates new {@link ValueProtocolClient} instances. 28 | */ 29 | public class ValueProtocolClientFactory implements ProtocolClientFactory { 30 | @Override 31 | public String getScheme() { 32 | return "value"; 33 | } 34 | 35 | @Override 36 | public ValueProtocolClient getClient() { 37 | return new ValueProtocolClient(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/SubscribeCompleteResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | public class SubscribeCompleteResponse extends AbstractServerMessage implements FinalResponse { 27 | private SubscribeCompleteResponse() { 28 | super(); 29 | } 30 | 31 | public SubscribeCompleteResponse(String id) { 32 | super(id); 33 | } 34 | 35 | @Override 36 | public Content toContent() { 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wot-servient-binding-coap/src/main/java/io/github/sanecity/wot/binding/coap/resource/ObservePropertyResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.coap.resource; 23 | 24 | import io.github.sanecity.wot.thing.property.ExposedThingProperty; 25 | 26 | /** 27 | * Endpoint for subscribing to value changes for a {@link io.github.sanecity.wot.thing.property.ThingProperty}. 28 | */ 29 | public class ObservePropertyResource extends AbstractSubscriptionResource { 30 | public ObservePropertyResource(String name, ExposedThingProperty property) { 31 | super("observable", name, property.observer()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/NoFormForInteractionConsumedThingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing; 23 | 24 | import io.github.sanecity.wot.thing.form.Operation; 25 | 26 | @SuppressWarnings({ "java:S110" }) 27 | class NoFormForInteractionConsumedThingException extends ConsumedThingException { 28 | public NoFormForInteractionConsumedThingException(String title, Operation op) { 29 | super("'" + title + "' has no form for interaction '" + op + "'"); 30 | } 31 | 32 | public NoFormForInteractionConsumedThingException(String message) { 33 | super(message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /wot-servient-binding-http/src/main/java/io/github/sanecity/wot/binding/http/HttpsProtocolClientFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.http; 23 | 24 | /** 25 | * Creates new {@link HttpProtocolClient} instances that allow consuming Things via HTTPS. 26 | */ 27 | public class HttpsProtocolClientFactory extends HttpProtocolClientFactory { 28 | public HttpsProtocolClientFactory() { 29 | super(); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "HttpsClient"; 35 | } 36 | 37 | @Override 38 | public String getScheme() { 39 | return "https"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/content/CborCodec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.content; 23 | 24 | import com.fasterxml.jackson.databind.ObjectMapper; 25 | import com.fasterxml.jackson.dataformat.cbor.CBORFactory; 26 | 27 | /** 28 | * (De)serializes data in CBOR format. 29 | */ 30 | public class CborCodec extends JsonCodec { 31 | private final ObjectMapper mapper = new ObjectMapper(new CBORFactory()); 32 | 33 | @Override 34 | public String getMediaType() { 35 | return "application/cbor"; 36 | } 37 | 38 | @Override 39 | protected ObjectMapper getMapper() { 40 | return mapper; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /wot-servient-examples/examples/groovy-scripts/example-dynamic.groovy: -------------------------------------------------------------------------------- 1 | def thing = wot.produce([title: 'DynamicThing']) 2 | 3 | /* 4 | * Copyright (c) 2019-2022 Heiko Bornholdt 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 22 | * OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | // manually add Interactions 25 | thing 26 | .addAction('addProperty', 27 | { input, options -> 28 | println('Adding Property') 29 | thing.addProperty('dynProperty', [type: 'string'], 'available') 30 | }) 31 | .addAction( 32 | "remProperty", 33 | { input, options -> 34 | println('Removing Property') 35 | thing.removeProperty('dynProperty') 36 | }) 37 | 38 | thing.expose() -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/binding/ProtocolServerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding; 23 | 24 | import io.github.sanecity.wot.ServientException; 25 | 26 | /** 27 | * A ProtocolServerException is thrown by {@link ProtocolServer} implementations when errors occur. 28 | */ 29 | public class ProtocolServerException extends ServientException { 30 | public ProtocolServerException(String message) { 31 | super(message); 32 | } 33 | 34 | public ProtocolServerException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | public ProtocolServerException() { 39 | super(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/SubscribeErrorResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | public class SubscribeErrorResponse extends AbstractServerMessage implements FinalResponse { 27 | private final Throwable error; 28 | 29 | private SubscribeErrorResponse() { 30 | super(); 31 | error = null; 32 | } 33 | 34 | @Override 35 | public Content toContent() { 36 | return null; 37 | } 38 | 39 | public Throwable getError() { 40 | return error; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /wot-servient-binding-jsonpathhttp/src/main/java/io/github/sanecity/wot/binding/jsonpathhttp/JsonpathHttpProtocolClientFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.jsonpathhttp; 23 | 24 | import io.github.sanecity.wot.binding.ProtocolClientFactory; 25 | 26 | /** 27 | * Creates new {@link JsonpathHttpProtocolClient} instances. 28 | */ 29 | public class JsonpathHttpProtocolClientFactory implements ProtocolClientFactory { 30 | @Override 31 | public String getScheme() { 32 | return "jsonpath+http"; 33 | } 34 | 35 | @Override 36 | public JsonpathHttpProtocolClient getClient() { 37 | return new JsonpathHttpProtocolClient(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/AbstractDataSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | abstract class AbstractDataSchema implements DataSchema { 25 | @Override 26 | public int hashCode() { 27 | return getType().hashCode(); 28 | } 29 | 30 | @Override 31 | public boolean equals(Object obj) { 32 | if (this == obj) { 33 | return true; 34 | } 35 | if (obj == null) { 36 | return false; 37 | } 38 | if (!(obj instanceof DataSchema)) { 39 | return false; 40 | } 41 | return getType().equals(((DataSchema) obj).getType()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /wot-servient-binding-http/src/main/java/io/github/sanecity/wot/binding/http/HttpProtocolClientFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.http; 23 | 24 | import io.github.sanecity.wot.binding.ProtocolClientFactory; 25 | 26 | /** 27 | * Creates new {@link HttpProtocolClient} instances. 28 | */ 29 | public class HttpProtocolClientFactory implements ProtocolClientFactory { 30 | @Override 31 | public String toString() { 32 | return "HttpClient"; 33 | } 34 | 35 | @Override 36 | public String getScheme() { 37 | return "http"; 38 | } 39 | 40 | @Override 41 | public HttpProtocolClient getClient() { 42 | return new HttpProtocolClient(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /.run/Whole project.run.xml: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 25 | 33 | 34 | 36 | 37 | -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/handler/codec/TextWebSocketFrameEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.handler.codec; 23 | 24 | import io.netty.channel.ChannelHandlerContext; 25 | import io.netty.handler.codec.MessageToMessageEncoder; 26 | import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; 27 | 28 | import java.util.List; 29 | 30 | public class TextWebSocketFrameEncoder extends MessageToMessageEncoder { 31 | @Override 32 | protected void encode(ChannelHandlerContext ctx, String text, List out) { 33 | TextWebSocketFrame frame = new TextWebSocketFrame(text); 34 | out.add(frame); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/Futures.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity; 23 | 24 | import io.reactivex.rxjava3.core.Observable; 25 | 26 | import java.util.concurrent.CompletableFuture; 27 | 28 | public class Futures { 29 | private Futures() { 30 | // factory class 31 | } 32 | 33 | public static Observable toObservable(CompletableFuture future) { 34 | return Observable.create(source -> future.whenComplete((result, e) -> { 35 | if (e == null) { 36 | source.onNext(result); 37 | source.onComplete(); 38 | } 39 | else { 40 | source.onError(e); 41 | } 42 | })); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/binding/ProtocolClientNotImplementedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding; 23 | 24 | /** 25 | * This exception is thrown when the a {@link ProtocolClient} implementation does not support a 26 | * requested functionality. 27 | */ 28 | @SuppressWarnings({ "java:S110" }) 29 | public class ProtocolClientNotImplementedException extends ProtocolClientException { 30 | public ProtocolClientNotImplementedException(Class clazz, String operation) { 31 | super(clazz.getSimpleName() + " does not implement '" + operation + "'"); 32 | } 33 | 34 | public ProtocolClientNotImplementedException(String message) { 35 | super(message); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/binding/ProtocolServerNotImplementedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding; 23 | 24 | /** 25 | * This exception is thrown when the a {@link ProtocolServer} implementation does not support a 26 | * requested functionality. 27 | */ 28 | @SuppressWarnings({ "java:S110" }) 29 | public class ProtocolServerNotImplementedException extends ProtocolServerException { 30 | public ProtocolServerNotImplementedException(Class clazz, String operation) { 31 | super(clazz.getSimpleName() + " does not implement '" + operation + "'"); 32 | } 33 | 34 | public ProtocolServerNotImplementedException(String message) { 35 | super(message); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wot-servient-binding-akka/src/main/java/io/github/sanecity/wot/binding/akka/AkkaProtocolPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.akka; 23 | 24 | import akka.actor.ActorRef; 25 | import akka.actor.ActorSelection; 26 | import akka.pattern.Patterns; 27 | 28 | import java.time.Duration; 29 | import java.util.concurrent.CompletionStage; 30 | 31 | public class AkkaProtocolPattern { 32 | public CompletionStage ask(ActorRef actor, Object message, Duration timeout) { 33 | return Patterns.ask(actor, message, timeout); 34 | } 35 | 36 | public CompletionStage ask(ActorSelection selection, Object message, Duration timeout) { 37 | return Patterns.ask(selection, message, timeout); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/NullSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | /** 25 | * Describes data of type null. 26 | */ 27 | public class NullSchema extends AbstractDataSchema { 28 | public static final String TYPE = "null"; 29 | public static final Class CLASS_TYPE = Object.class; 30 | 31 | @Override 32 | public String getType() { 33 | return TYPE; 34 | } 35 | 36 | @Override 37 | public Class getClassType() { 38 | return CLASS_TYPE; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "NullSchema{}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wot-servient-binding-coap/src/test/java/io/github/sanecity/wot/binding/coap/CoapProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.coap; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.hamcrest.CoreMatchers.instanceOf; 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class CoapProtocolClientFactoryTest { 31 | @Test 32 | public void getScheme() { 33 | assertEquals("coap", new CoapProtocolClientFactory().getScheme()); 34 | } 35 | 36 | @Test 37 | public void getClient() { 38 | assertThat(new CoapProtocolClientFactory().getClient(), instanceOf(CoapProtocolClient.class)); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient-binding-file/src/test/java/io/github/sanecity/wot/binding/file/FileProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.file; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.hamcrest.CoreMatchers.instanceOf; 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class FileProtocolClientFactoryTest { 31 | @Test 32 | public void getScheme() { 33 | assertEquals("file", new FileProtocolClientFactory().getScheme()); 34 | } 35 | 36 | @Test 37 | public void getClient() { 38 | assertThat(new FileProtocolClientFactory().getClient(), instanceOf(FileProtocolClient.class)); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient-binding-http/src/test/java/io/github/sanecity/wot/binding/http/HttpProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.http; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.hamcrest.CoreMatchers.instanceOf; 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class HttpProtocolClientFactoryTest { 31 | @Test 32 | public void getScheme() { 33 | assertEquals("http", new HttpProtocolClientFactory().getScheme()); 34 | } 35 | 36 | @Test 37 | public void getClient() { 38 | assertThat(new HttpProtocolClientFactory().getClient(), instanceOf(HttpProtocolClient.class)); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient-binding-value/src/test/java/io/github/sanecity/wot/binding/value/ValueProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.value; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.hamcrest.CoreMatchers.instanceOf; 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class ValueProtocolClientFactoryTest { 31 | @Test 32 | public void getScheme() { 33 | assertEquals("value", new ValueProtocolClientFactory().getScheme()); 34 | } 35 | 36 | @Test 37 | public void getClient() { 38 | assertThat(new ValueProtocolClientFactory().getClient(), instanceOf(ValueProtocolClient.class)); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/NumberSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | /** 25 | * Describes data of type number. 26 | */ 27 | public class NumberSchema extends AbstractDataSchema { 28 | public static final String TYPE = "number"; 29 | public static final Class CLASS_TYPE = Number.class; 30 | 31 | @Override 32 | public String getType() { 33 | return TYPE; 34 | } 35 | 36 | @Override 37 | public Class getClassType() { 38 | return CLASS_TYPE; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "NumberSchema{}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/StringSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | /** 25 | * Describes data of type string. 26 | */ 27 | public class StringSchema extends AbstractDataSchema { 28 | public static final String TYPE = "string"; 29 | public static final Class CLASS_TYPE = String.class; 30 | 31 | @Override 32 | public String getType() { 33 | return TYPE; 34 | } 35 | 36 | @Override 37 | public Class getClassType() { 38 | return CLASS_TYPE; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "StringSchema{}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/BooleanSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | /** 25 | * Describes data of type boolean. 26 | */ 27 | public class BooleanSchema extends AbstractDataSchema { 28 | public static final String TYPE = "boolean"; 29 | public static final Class CLASS_TYPE = Boolean.class; 30 | 31 | @Override 32 | public String getType() { 33 | return TYPE; 34 | } 35 | 36 | @Override 37 | public Class getClassType() { 38 | return CLASS_TYPE; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "BooleanSchema{}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/IntegerSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | /** 25 | * Describes data of type integer. 26 | */ 27 | public class IntegerSchema extends AbstractDataSchema { 28 | public static final String TYPE = "integer"; 29 | public static final Class CLASS_TYPE = Integer.class; 30 | 31 | @Override 32 | public String getType() { 33 | return TYPE; 34 | } 35 | 36 | @Override 37 | public Class getClassType() { 38 | return CLASS_TYPE; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "IntegerSchema{}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/ClientErrorResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | public class ClientErrorResponse extends AbstractServerMessage { 27 | private final String reason; 28 | 29 | private ClientErrorResponse() { 30 | this.reason = null; 31 | } 32 | 33 | public ClientErrorResponse(AbstractClientMessage message, String reason) { 34 | super(message); 35 | this.reason = reason; 36 | } 37 | 38 | public String getReason() { 39 | return reason; 40 | } 41 | 42 | @Override 43 | public Content toContent() { 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/ServerErrorResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | public class ServerErrorResponse extends AbstractServerMessage { 27 | private final String reason; 28 | 29 | private ServerErrorResponse() { 30 | this.reason = null; 31 | } 32 | 33 | public ServerErrorResponse(AbstractClientMessage message, String reason) { 34 | super(message); 35 | this.reason = reason; 36 | } 37 | 38 | public String getReason() { 39 | return reason; 40 | } 41 | 42 | @Override 43 | public Content toContent() { 44 | return null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/security/NoSecuritySchemeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.security; 23 | 24 | import org.junit.jupiter.api.Nested; 25 | import org.junit.jupiter.api.Test; 26 | 27 | import static org.junit.jupiter.api.Assertions.assertEquals; 28 | 29 | class NoSecuritySchemeTest { 30 | @Nested 31 | class Equals { 32 | @Test 33 | void shouldAlwaysReturnTrue() { 34 | assertEquals(new NoSecurityScheme(), new NoSecurityScheme()); 35 | } 36 | } 37 | 38 | @Nested 39 | class HashCode { 40 | @Test 41 | void shouldAlwaysReturnSameHashCode() { 42 | assertEquals(new NoSecurityScheme().hashCode(), new NoSecurityScheme().hashCode()); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/test/java/io/github/sanecity/wot/binding/websocket/WebsocketProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.hamcrest.CoreMatchers.instanceOf; 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class WebsocketProtocolClientFactoryTest { 31 | @Test 32 | public void getScheme() { 33 | assertEquals("ws", new WebsocketProtocolClientFactory().getScheme()); 34 | } 35 | 36 | @Test 37 | public void getClient() { 38 | assertThat(new WebsocketProtocolClientFactory().getClient(), instanceOf(WebsocketProtocolClient.class)); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/ArraySchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import java.util.List; 25 | 26 | /** 27 | * Describes data of type Array. 28 | */ 29 | public class ArraySchema extends AbstractDataSchema { 30 | public static final String TYPE = "array"; 31 | public static final Class CLASS_TYPE = List.class; 32 | 33 | @Override 34 | public String getType() { 35 | return TYPE; 36 | } 37 | 38 | @Override 39 | public Class getClassType() { 40 | return CLASS_TYPE; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "ArraySchema{}"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /wot-servient-binding-jadex/src/main/java/io/github/sanecity/wot/binding/jadex/ThingService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.jadex; 23 | 24 | import jadex.commons.future.IFuture; 25 | 26 | /** 27 | * Defines the Jadex Service interface for interaction with a Thing. 28 | */ 29 | public interface ThingService { 30 | /** 31 | * Return Thing as string because Jadex is not able to (de)serialize it properly without 32 | * additional adjustments. 33 | * 34 | * @return 35 | */ 36 | IFuture get(); 37 | 38 | IFuture readProperties(); 39 | 40 | IFuture readProperty(String name); 41 | 42 | IFuture writeProperty(String name, JadexContent content); 43 | 44 | String getThingServiceId(); 45 | } 46 | -------------------------------------------------------------------------------- /.gitlab-ci/Maven.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: maven:3.6.1-jdk-11 2 | 3 | variables: 4 | MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" 5 | MAVEN_CLI_OPTS: "-s ci_settings.xml --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" 6 | 7 | cache: 8 | paths: 9 | - .m2/repository 10 | 11 | maven-verify: 12 | stage: test 13 | services: 14 | - eclipse-mosquitto:1.6 # for mqtt client/server tests 15 | before_script: 16 | - sed -i 's/localhost/eclipse-mosquitto/g' wot-servient-integration-tests/src/test/resources/application.conf 17 | script: 18 | - 'mvn $MAVEN_CLI_OPTS verify sonar:sonar' 19 | - mv wot-servient-cli/target/wot-servient-*.zip . 20 | after_script: 21 | - '/bin/bash coverage-jacoco.sh' 22 | coverage: '/\d+.\d+ \% covered/' 23 | except: 24 | - master 25 | - /^\d+\.\d+/ 26 | artifacts: 27 | reports: 28 | junit: 29 | - "*/target/surefire-reports/TEST-*.xml" 30 | - "*/target/failsafe-reports/TEST-*.xml" 31 | paths: 32 | - "wot-servient-*.zip" 33 | 34 | maven-deploy: 35 | stage: deploy 36 | services: 37 | - eclipse-mosquitto:1.6 # for mqtt client/server tests 38 | before_script: 39 | - sed -i 's/localhost/eclipse-mosquitto/g' wot-servient-integration-tests/src/test/resources/application.conf 40 | script: 41 | - 'mvn $MAVEN_CLI_OPTS deploy sonar:sonar' 42 | - mv wot-servient-cli/target/wot-servient-*.zip . 43 | after_script: 44 | - '/bin/bash coverage-jacoco.sh' 45 | coverage: '/\d+.\d+ \% covered/' 46 | only: 47 | - master 48 | - /^\d+\.\d+/ 49 | artifacts: 50 | reports: 51 | junit: 52 | - "*/target/surefire-reports/TEST-*.xml" 53 | - "*/target/failsafe-reports/TEST-*.xml" 54 | paths: 55 | - "wot-servient-*.zip" 56 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/ServientDiscoveryIgnore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot; 23 | 24 | import io.github.sanecity.wot.binding.ProtocolClientFactory; 25 | import io.github.sanecity.wot.binding.ProtocolServer; 26 | 27 | import java.lang.annotation.ElementType; 28 | import java.lang.annotation.Retention; 29 | import java.lang.annotation.RetentionPolicy; 30 | import java.lang.annotation.Target; 31 | 32 | /** 33 | * If no {@link ProtocolServer} or {@link ProtocolClientFactory} are specified in the config, {@link 34 | * ServientConfig} searches the classpath for suitable classes. This annotation excludes the 35 | * respective class from the search. 36 | */ 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Target(ElementType.TYPE) 39 | public @interface ServientDiscoveryIgnore { 40 | } 41 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/filter/DiscoveryMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.filter; 23 | 24 | import io.github.sanecity.wot.Servient; 25 | import io.github.sanecity.wot.binding.ProtocolClient; 26 | 27 | /** 28 | * Defines "Where" to search for things during a discovery process. 29 | */ 30 | public enum DiscoveryMethod { 31 | /** 32 | * Uses the discovery mechanisms provided by all {@link ProtocolClient} implementations to 33 | * consider all available Things. 34 | */ 35 | ANY, 36 | 37 | /** 38 | * Searches only on the local {@link Servient}. 39 | */ 40 | LOCAL, 41 | 42 | /** 43 | * Is used together with a URL to search in a specific Thing Directory. 44 | */ 45 | DIRECTORY, 46 | 47 | // MULTICAST 48 | } 49 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/util/LoggingUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package io.github.sanecity.wot.util; 24 | 25 | /** 26 | * Utility class for logging-related operations. 27 | */ 28 | public class LoggingUtil { 29 | private LoggingUtil() { 30 | // util class 31 | } 32 | 33 | /** 34 | * Cleans obj from line breaks and returns them as \n or \r. 35 | * 36 | * @param obj the object to be cleaned 37 | * @return cleaned string 38 | */ 39 | public static String sanitizeLogArg(final Object obj) { 40 | if (obj != null) { 41 | return obj.toString() 42 | .replace("\n", "\\n") 43 | .replace("\r", "\\r"); 44 | } 45 | else { 46 | return null; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /wot-servient-binding-jsonpathhttp/src/test/java/io/github/sanecity/wot/binding/jsonpathhttp/JsonpathHttpProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.jsonpathhttp; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.hamcrest.CoreMatchers.instanceOf; 27 | import static org.hamcrest.MatcherAssert.assertThat; 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | public class JsonpathHttpProtocolClientFactoryTest { 31 | @Test 32 | public void getScheme() { 33 | assertEquals("jsonpath+http", new JsonpathHttpProtocolClientFactory().getScheme()); 34 | } 35 | 36 | @Test 37 | public void getClient() { 38 | assertThat(new JsonpathHttpProtocolClientFactory().getClient(), instanceOf(JsonpathHttpProtocolClient.class)); 39 | } 40 | } -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/SubscribeNextResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | import java.util.Objects; 27 | 28 | public class SubscribeNextResponse extends AbstractServerMessage { 29 | private final Content next; 30 | 31 | private SubscribeNextResponse() { 32 | super(); 33 | next = null; 34 | } 35 | 36 | public SubscribeNextResponse(String id, Content next) { 37 | super(id); 38 | this.next = Objects.requireNonNull(next); 39 | } 40 | 41 | @Override 42 | public Content toContent() { 43 | return next; 44 | } 45 | 46 | public Content getNext() { 47 | return next; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /wot-servient-scripting-groovy/src/main/groovy/io/github/sanecity/wot/WotExtensions.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot 23 | 24 | import com.fasterxml.jackson.databind.ObjectMapper 25 | import io.github.sanecity.wot.Wot 26 | import io.github.sanecity.wot.thing.ConsumedThing 27 | import io.github.sanecity.wot.thing.ExposedThing 28 | import io.github.sanecity.wot.thing.Thing 29 | 30 | class WotExtensions { 31 | private static final ObjectMapper JSON_MAPPER = new ObjectMapper() 32 | 33 | static ExposedThing produce(Wot self, Map map) { 34 | def thing = JSON_MAPPER.convertValue(map, Thing.class) 35 | return self.produce(thing) 36 | } 37 | 38 | static ConsumedThing consume(Wot self, Map map) { 39 | def thing = JSON_MAPPER.convertValue(map, Thing.class) 40 | return self.consume(thing) 41 | } 42 | } -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/ThingInteraction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import java.util.Objects; 25 | 26 | public abstract class ThingInteraction extends AbstractClientMessage { 27 | protected final String thingId; 28 | protected final String name; 29 | 30 | protected ThingInteraction() { 31 | this.thingId = null; 32 | this.name = null; 33 | } 34 | 35 | public ThingInteraction(String thingId, String name) { 36 | this.thingId = Objects.requireNonNull(thingId); 37 | this.name = Objects.requireNonNull(name); 38 | } 39 | 40 | public String getThingId() { 41 | return thingId; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/event/EventState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.event; 23 | 24 | import io.reactivex.rxjava3.subjects.PublishSubject; 25 | import io.reactivex.rxjava3.subjects.Subject; 26 | 27 | import java.util.Optional; 28 | 29 | /** 30 | * This class represented the container for the subject of a {@link ThingEvent}. The subject is used 31 | * as a resource for new values and observers of the event. 32 | */ 33 | public class EventState { 34 | private final Subject> subject; 35 | 36 | public EventState() { 37 | this(PublishSubject.create()); 38 | } 39 | 40 | EventState(Subject> subject) { 41 | this.subject = subject; 42 | } 43 | 44 | public Subject> getSubject() { 45 | return subject; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/schema/DataSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import com.fasterxml.jackson.annotation.JsonIgnore; 25 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 26 | import io.github.sanecity.wot.thing.action.ThingAction; 27 | import io.github.sanecity.wot.thing.property.ThingProperty; 28 | 29 | /** 30 | * Defines the type of data. Used e.g. to define which input and output values a {@link ThingAction} 31 | * has or of which type a {@link ThingProperty} is.
See also: https://www.w3.org/TR/wot-thing-description/#sec-data-schema-vocabulary-definition 32 | * 33 | * @param 34 | */ 35 | @JsonIgnoreProperties(ignoreUnknown = true) 36 | public interface DataSchema { 37 | String getType(); 38 | 39 | @JsonIgnore 40 | Class getClassType(); 41 | } 42 | -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/filter/ThingFilterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.filter; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 28 | 29 | public class ThingFilterTest { 30 | @Test 31 | public void testEquals() { 32 | ThingFilter filterA = new ThingFilter().setMethod(DiscoveryMethod.ANY); 33 | ThingFilter filterB = new ThingFilter().setMethod(DiscoveryMethod.ANY); 34 | ThingFilter filterC = new ThingFilter().setMethod(DiscoveryMethod.LOCAL); 35 | 36 | assertEquals(filterA, filterB); 37 | assertEquals(filterB, filterA); 38 | assertNotEquals(filterA, filterC); 39 | assertNotEquals(filterC, filterA); 40 | } 41 | } -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/InvokeActionResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | import java.util.Objects; 27 | 28 | public class InvokeActionResponse extends AbstractServerMessage implements FinalResponse { 29 | private final Content value; 30 | 31 | private InvokeActionResponse() { 32 | super(); 33 | value = null; 34 | } 35 | 36 | public InvokeActionResponse(String id, Content value) { 37 | super(id); 38 | this.value = Objects.requireNonNull(value); 39 | } 40 | 41 | @Override 42 | public Content toContent() { 43 | return getValue(); 44 | } 45 | 46 | public Content getValue() { 47 | return value; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /wot-servient/src/test/java/io/github/sanecity/wot/thing/schema/VariableDataSchemaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.schema; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | public class VariableDataSchemaTest { 29 | @Test 30 | public void testEquals() { 31 | VariableDataSchema schema1 = new VariableDataSchema.Builder().setType("string").build(); 32 | VariableDataSchema schema2 = new VariableDataSchema.Builder().setType("string").build(); 33 | 34 | assertEquals(schema1, schema2); 35 | } 36 | 37 | @Test 38 | public void builder() { 39 | VariableDataSchema schema = new VariableDataSchema.Builder() 40 | .setType("string") 41 | .build(); 42 | 43 | assertEquals("string", schema.getType()); 44 | } 45 | } -------------------------------------------------------------------------------- /wot-servient-binding-http/src/main/java/io/github/sanecity/wot/binding/http/ContentResponseTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.http; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | import spark.ResponseTransformer; 26 | 27 | /** 28 | * Transformer for automatic conversion of {@link Content} objects to {@link String} objects. Used 29 | * by Spark HTTP server. 30 | */ 31 | public class ContentResponseTransformer implements ResponseTransformer { 32 | @Override 33 | public String render(Object model) { 34 | if (model instanceof Content) { 35 | Content content = (Content) model; 36 | return new String(content.getBody()); 37 | } 38 | else if (model != null) { 39 | return model.toString(); 40 | } 41 | else { 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wot-servient-binding-jadex/src/test/java/io/github/sanecity/wot/binding/jadex/JadexProtocolClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.jadex; 23 | 24 | import com.typesafe.config.ConfigFactory; 25 | import org.junit.jupiter.api.Test; 26 | 27 | import static org.hamcrest.CoreMatchers.instanceOf; 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | import static org.junit.jupiter.api.Assertions.assertEquals; 30 | 31 | public class JadexProtocolClientFactoryTest { 32 | @Test 33 | public void getSchemeShouldReturnCorrectScheme() { 34 | assertEquals("jadex", new JadexProtocolClientFactory(ConfigFactory.load()).getScheme()); 35 | } 36 | 37 | @Test 38 | public void getClientShouldReturnJadexClient() { 39 | assertThat(new JadexProtocolClientFactory(ConfigFactory.load()).getClient(), instanceOf(JadexProtocolClient.class)); 40 | } 41 | } -------------------------------------------------------------------------------- /wot-servient-binding-websocket/src/main/java/io/github/sanecity/wot/binding/websocket/message/ThingInteractionWithContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.websocket.message; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | 26 | import java.util.Objects; 27 | 28 | public abstract class ThingInteractionWithContent extends ThingInteraction { 29 | protected Content value; 30 | 31 | public ThingInteractionWithContent(String thingId, String name, Content value) { 32 | super(thingId, name); 33 | this.value = Objects.requireNonNull(value); 34 | } 35 | 36 | public ThingInteractionWithContent() { 37 | super(); 38 | this.value = null; 39 | } 40 | 41 | public Content getValue() { 42 | return value; 43 | } 44 | 45 | public void setValue(Content value) { 46 | this.value = value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/security/NoSecurityScheme.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.security; 23 | 24 | /** 25 | * A security configuration corresponding to identified by the term nosec (i.e., "scheme": "nosec"), 26 | * indicating there is no authentication or other mechanism required to access the resource.
See 27 | * also: https://www.w3.org/2019/wot/security#nosecurityscheme 28 | */ 29 | public class NoSecurityScheme implements SecurityScheme { 30 | @Override 31 | public int hashCode() { 32 | return 42; 33 | } 34 | 35 | @Override 36 | public boolean equals(Object o) { 37 | if (this == o) { 38 | return true; 39 | } 40 | return o != null && getClass() == o.getClass(); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "NoSecurityScheme{}"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /wot-servient-binding-file/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 23 | 24 | 25 | wot-servient-parent 26 | io.github.sane-city 27 | 1.16-SNAPSHOT 28 | 29 | 4.0.0 30 | 31 | wot-servient-binding-file 32 | 33 | 34 | 35 | io.github.sane-city 36 | wot-servient 37 | ${project.version} 38 | compile 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /wot-servient-binding-value/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 23 | 24 | 25 | wot-servient-parent 26 | io.github.sane-city 27 | 1.16-SNAPSHOT 28 | 29 | 4.0.0 30 | 31 | wot-servient-binding-value 32 | 33 | 34 | 35 | io.github.sane-city 36 | wot-servient 37 | ${project.version} 38 | compile 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /wot-servient-binding-value/src/main/java/io/github/sanecity/wot/binding/value/ValueProtocolClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.value; 23 | 24 | import io.github.sanecity.wot.binding.ProtocolClient; 25 | import io.github.sanecity.wot.content.Content; 26 | import io.github.sanecity.wot.thing.form.Form; 27 | 28 | import java.util.concurrent.CompletableFuture; 29 | 30 | import static java.util.concurrent.CompletableFuture.completedFuture; 31 | 32 | /** 33 | * Allows consuming Things via values stored in Thing Descriptions. 34 | */ 35 | public class ValueProtocolClient implements ProtocolClient { 36 | @Override 37 | public CompletableFuture readResource(Form form) { 38 | String href = form.getHref(); 39 | String value = href.replace("value:/", ""); 40 | 41 | Content content = new Content("text/plain", value.getBytes()); 42 | return completedFuture(content); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/security/PSKSecurityScheme.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.security; 23 | 24 | import com.fasterxml.jackson.annotation.JsonInclude; 25 | 26 | /** 27 | * Pre-shared key authentication security configuration identified by the term psk (i.e., "scheme": 28 | * "psk").
See also: https://www.w3.org/2019/wot/security#psksecurityscheme 29 | */ 30 | public class PSKSecurityScheme implements SecurityScheme { 31 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 32 | private final String identity; 33 | 34 | public PSKSecurityScheme(String identity) { 35 | this.identity = identity; 36 | } 37 | 38 | public String getIdentity() { 39 | return identity; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "PSKSecurityScheme{" + 45 | "identity='" + identity + '\'' + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /wot-servient/src/main/java/io/github/sanecity/wot/thing/security/PublicSecurityScheme.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.thing.security; 23 | 24 | import com.fasterxml.jackson.annotation.JsonInclude; 25 | 26 | /** 27 | * Raw public key asymmetric key security configuration identified by the term public (i.e., 28 | * "scheme": "public").
See also: https://www.w3.org/2019/wot/security#publicsecurityscheme 29 | */ 30 | public class PublicSecurityScheme implements SecurityScheme { 31 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 32 | private final String identity; 33 | 34 | public PublicSecurityScheme(String identity) { 35 | this.identity = identity; 36 | } 37 | 38 | public String getIdentity() { 39 | return identity; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "PublicSecurityScheme{" + 45 | "identity='" + identity + '\'' + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /wot-servient-binding-http/src/test/java/io/github/sanecity/wot/binding/http/ContentResponseTransformerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2022 Heiko Bornholdt 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | * OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | package io.github.sanecity.wot.binding.http; 23 | 24 | import io.github.sanecity.wot.content.Content; 25 | import org.junit.jupiter.api.Test; 26 | 27 | import static org.junit.jupiter.api.Assertions.assertEquals; 28 | import static org.junit.jupiter.api.Assertions.assertNull; 29 | 30 | public class ContentResponseTransformerTest { 31 | @Test 32 | public void renderContent() { 33 | Content content = new Content("application/json", "Hallo Welt".getBytes()); 34 | 35 | assertEquals("Hallo Welt", new ContentResponseTransformer().render(content)); 36 | } 37 | 38 | @Test 39 | public void renderObject() { 40 | assertEquals("1337", new ContentResponseTransformer().render(1337)); 41 | } 42 | 43 | @Test 44 | public void renderNull() { 45 | assertNull(new ContentResponseTransformer().render(null)); 46 | } 47 | } --------------------------------------------------------------------------------