-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from Fraunhofer-AISEC/feature/example-ids-mul…
…tipart-uc Feature/example ids multipart uc
- Loading branch information
Showing
16 changed files
with
401 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...c/main/kotlin/de/fhg/aisec/ids/camel/processors/multipart/CertExposingEndpointStrategy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*- | ||
* ========================LICENSE_START================================= | ||
* camel-processors | ||
* %% | ||
* Copyright (C) 2023 Fraunhofer AISEC | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* =========================LICENSE_END================================== | ||
*/ | ||
package de.fhg.aisec.ids.camel.processors.multipart | ||
|
||
import org.apache.camel.Endpoint | ||
import org.apache.camel.component.http.HttpEndpoint | ||
import org.apache.camel.spi.EndpointStrategy | ||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Component | ||
|
||
@Component("certExposingEndpointStrategy") | ||
class CertExposingEndpointStrategy : EndpointStrategy { | ||
@Autowired | ||
private lateinit var certExposingHttpClientConfigurer: CertExposingHttpClientConfigurer | ||
|
||
override fun registerEndpoint(uri: String, endpoint: Endpoint): Endpoint { | ||
if (endpoint is HttpEndpoint && uri.startsWith("https")) { | ||
LOG.info("Configured endpoint with uri $uri") | ||
endpoint.httpClientConfigurer = certExposingHttpClientConfigurer | ||
} | ||
return endpoint | ||
} | ||
|
||
companion object { | ||
val LOG: Logger = LoggerFactory.getLogger(CertExposingEndpointStrategy::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This defines the tag used for docker-compose example YAML files in the current directory | ||
EXAMPLE_TAG=develop |
9 changes: 9 additions & 0 deletions
9
examples/src/main/resources/example-ids-multipart-uc/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# IDSCP2 communication examples | ||
|
||
This example demonstrates usage control between trusted connectors via the IDS Multipart protocol. | ||
|
||
### Usage | ||
|
||
First, start the server with the command `docker compose --profile server up`. | ||
|
||
Second, start the client using the command `docker compose --profile client up`. |
63 changes: 63 additions & 0 deletions
63
examples/src/main/resources/example-ids-multipart-uc/compose.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
version: '3' | ||
services: | ||
|
||
consumer-core: | ||
image: fraunhoferaisec/trusted-connector-core:${EXAMPLE_TAG:-develop} | ||
tty: true | ||
stdin_open: true | ||
command: [ "--class-path", "./jars/*", "de.fhg.aisec.ids.TrustedConnector", | ||
"--spring.config.location=/root/etc/application.yml" ] | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ../etc/application.yml:/root/etc/application.yml | ||
- ../deploy/allow-all-flows.pl:/root/deploy/allow-all-flows.pl | ||
- ../etc/settings.mapdb:/root/etc/settings.mapdb | ||
- ../etc/consumer-keystore.p12:/root/etc/keystore.p12 | ||
- ../etc/truststore.p12:/root/etc/truststore.p12 | ||
- ./example-multipart-uc-server.xml:/root/deploy/example-multipart-uc-server.xml | ||
- ./make-contract.xml:/root/deploy/make-contract.xml | ||
ports: | ||
- "8080:8080" | ||
networks: | ||
- ids-wide | ||
profiles: | ||
- server | ||
|
||
provider-core: | ||
image: fraunhoferaisec/trusted-connector-core:${EXAMPLE_TAG:-develop} | ||
tty: true | ||
stdin_open: true | ||
command: [ "--class-path", "./jars/*", "de.fhg.aisec.ids.TrustedConnector", | ||
"--spring.config.location=/root/etc/application.yml" ] | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ../etc/application.yml:/root/etc/application.yml | ||
- ../deploy/allow-all-flows.pl:/root/deploy/allow-all-flows.pl | ||
- ../etc/settings2.mapdb:/root/etc/settings.mapdb | ||
- ../etc/provider-keystore.p12:/root/etc/keystore.p12 | ||
- ../etc/truststore.p12:/root/etc/truststore.p12 | ||
- ./example-multipart-uc-client.xml:/root/deploy/example-multipart-uc-client.xml | ||
ports: | ||
- "8081:8080" | ||
networks: | ||
- ids-wide | ||
- provider-internal | ||
profiles: | ||
- client | ||
|
||
echo-server: | ||
image: jmalloc/echo-server@sha256:c461e7e54d947a8777413aaf9c624b4ad1f1bac5d8272475da859ae82c1abd7d | ||
environment: | ||
PORT: "80" | ||
LOG_HTTP_HEADERS: 1 | ||
LOG_HTTP_BODY: 1 | ||
networks: | ||
- provider-internal | ||
profiles: | ||
- client | ||
|
||
networks: | ||
ids-wide: | ||
driver: bridge | ||
provider-internal: | ||
driver: bridge |
96 changes: 96 additions & 0 deletions
96
examples/src/main/resources/example-ids-multipart-uc/example-multipart-uc-client.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:camel="http://camel.apache.org/schema/spring" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> | ||
|
||
<camel:sslContextParameters id="rootClientSslContext" certAlias="1"> | ||
<camel:keyManagers keyPassword="password"> | ||
<camel:keyStore resource="etc/keystore.p12" password="password" /> | ||
</camel:keyManagers> | ||
<camel:trustManagers> | ||
<camel:keyStore resource="etc/truststore.p12" password="password" /> | ||
</camel:trustManagers> | ||
</camel:sslContextParameters> | ||
|
||
<bean id="rootDaps" class="de.fhg.aisec.ids.idscp2.beans.AisecDapsDriverFactoryBean"> | ||
<property name="dapsUrl" value="https://daps-dev.aisec.fraunhofer.de/v4" /> | ||
<property name="dapsSslParameters" ref="rootClientSslContext" /> | ||
<property name="transportCertificatesParameters" ref="rootClientSslContext" /> | ||
</bean> | ||
|
||
<camelContext xmlns="http://camel.apache.org/schema/spring"> | ||
<errorHandler id="infErrorHandler" type="DeadLetterChannel" deadLetterUri="log:dead?level=ERROR"> | ||
<redeliveryPolicy maximumRedeliveries="-1" redeliveryDelay="1000" /> | ||
</errorHandler> | ||
|
||
<route errorHandlerRef="infErrorHandler"> | ||
<from uri="timer://contractRequest?repeatCount=1" /> | ||
<setProperty name="artifactUri"> | ||
<constant>https://example.com/some_artifact</constant> | ||
</setProperty> | ||
<process ref="contractRequestCreationProcessor" /> | ||
<process ref="idsMultiPartOutputProcessor" /> | ||
<to uri="https://consumer-core:28282/usageControl?sslContextParameters=#rootClientSslContext" /> | ||
<process ref="idsMultiPartInputProcessor" /> | ||
<process ref="idsMessageTypeExtractionProcessor" /> | ||
<choice> | ||
<when> | ||
<simple>${exchangeProperty.ids-type} == 'ContractResponseMessage'</simple> | ||
<log message="### Handle ContractResponseMessage ###" /> | ||
<process ref="contractResponseProcessor" /> | ||
<process ref="idsMultiPartOutputProcessor" /> | ||
<to uri="https://consumer-core:28282/usageControl?sslContextParameters=#rootClientSslContext" /> | ||
<process ref="idsMultiPartInputProcessor" /> | ||
<process ref="idsMessageTypeExtractionProcessor" /> | ||
<choice> | ||
<when> | ||
<simple>${exchangeProperty.ids-type} == 'MessageProcessedNotificationMessage'</simple> | ||
<log message="### Received MessageProcessedNotificationMessage, starting artifactRequestRoute... ###" /> | ||
<to uri="controlbus:route?routeId=artifactRequestRoute&action=start" /> | ||
</when> | ||
<otherwise> | ||
<log loggingLevel="ERROR" message="Expected MessageProcessedNotificationMessage, but received:\n${body}\n### Header: ###\n${headers[ids-header]}" /> | ||
<removeHeader name="ids-header" /> | ||
<setBody> | ||
<simple>${null}</simple> | ||
</setBody> | ||
</otherwise> | ||
</choice> | ||
</when> | ||
<otherwise> | ||
<log loggingLevel="ERROR" message="Expected ContractResponseMessage, but received:\n${body}\n### Header: ###\n${headers[ids-header]}" /> | ||
<removeHeader name="ids-header" /> | ||
<setBody> | ||
<simple>${null}</simple> | ||
</setBody> | ||
</otherwise> | ||
</choice> | ||
</route> | ||
|
||
<route id="artifactRequestRoute" autoStartup="false"> | ||
<from uri="timer://tenSecondsTimer?fixedRate=true&period=10000" /> | ||
<setProperty name="artifactUri"> | ||
<constant>https://example.com/some_artifact</constant> | ||
</setProperty> | ||
<process ref="artifactRequestCreationProcessor" /> | ||
<process ref="idsMultiPartOutputProcessor" /> | ||
<to uri="https://consumer-core:28282/usageControl?sslContextParameters=#rootClientSslContext" /> | ||
<process ref="idsMultiPartInputProcessor" /> | ||
<process ref="idsMessageTypeExtractionProcessor" /> | ||
<choice> | ||
<when> | ||
<simple>${exchangeProperty.ids-type} == 'ArtifactResponseMessage'</simple> | ||
<log message="### Handle ArtifactResponseMessage ###" /> | ||
<to uri="http://echo-server:80" /> | ||
</when> | ||
<otherwise> | ||
<log loggingLevel="ERROR" message="Expected ArtifactResponseMessage, but received:\n${body}\n### Header: ###\n${headers[ids-header]}" /> | ||
</otherwise> | ||
</choice> | ||
</route> | ||
|
||
</camelContext> | ||
|
||
</beans> |
Oops, something went wrong.