-
Notifications
You must be signed in to change notification settings - Fork 12
/
clearing-house-routes.xml
170 lines (160 loc) · 8.92 KB
/
clearing-house-routes.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?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
https://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
https://camel.apache.org/schema/spring/camel-spring.xsd">
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
<camel:sslContextParameters id="rootServerSslContext" 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="jetty" class="org.apache.camel.component.jetty9.JettyHttpComponent9">
<property name="sslSocketConnectorProperties">
<map>
<entry key="needClientAuth" value="true"/>
</map>
</property>
</bean>
<bean name="rootDaps" class="de.fhg.aisec.ids.idscp2.beans.AisecDapsDriverFactoryBean">
<property name="dapsUrl" value="${connector.daps-url}"/>
<property name="dapsSslParameters" ref="rootServerSslContext"/>
<property name="transportCertificatesParameters" ref="rootServerSslContext"/>
</bean>
<bean name="attestationConfig" class="de.fhg.aisec.ids.idscp2.beans.AttestationConfigFactoryBean">
<property name="expectedRaSuite" value="Dummy2|Dummy"/>
<property name="supportedRaSuite" value="Dummy2|Dummy"/>
</bean>
<bean name="idscp2Config" class="de.fhg.aisec.ids.idscp2.beans.Idscp2ConfigurationFactoryBean">
<property name="attestationConfig" ref="attestationConfig"/>
<property name="dapsDriver" ref="rootDaps"/>
<property name="handshakeTimeoutDelay" value="10000"/>
</bean>
<bean name="tlsConfig" class="de.fhg.aisec.ids.idscp2.beans.NativeTlsConfigurationBuilderFactoryBean">
<property name="sslParameters" ref="rootServerSslContext"/>
</bean>
<!-- Routes -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<restConfiguration scheme="https" component="jetty" host="0.0.0.0" port="9999" bindingMode="off">
<endpointProperty key="sslContextParameters" value="#rootServerSslContext"/>
</restConfiguration>
<rest id="CH_REST">
<post path="/messages/query/{pid}" id="CH_QUERY_PID">
<to uri="direct:multipart" />
</post>
<post path="/messages/query/{pid}/{id}" id="CH_QUERY_PID_ID">
<to uri="direct:multipart" />
</post>
<post path="/messages/log/{pid}" id="CH_LOG_PID">
<to uri="direct:multipart" />
</post>
<post path="/process/{pid}" id="CH_CREATE_PID">
<to uri="direct:multipart" />
</post>
</rest>
<route id="CH_MULTIPART_ROUTE">
<from uri="direct:multipart"/>
<onException>
<exception>java.io.IOException</exception>
<exception>java.lang.SecurityException</exception>
<exception>java.lang.IllegalArgumentException</exception>
<handled>
<constant>true</constant>
</handled>
<transform><simple>${exception.message}</simple></transform>
<log message="### Handle ${exception.class} ###"/>
<log message="### Got ${exception.stacktrace} ###"/>
<removeHeader name="ids-header"/>
<removeHeader name="ids-protocol"/>
<removeHeader name="pid"/>
<removeHeader name="id"/>
<choice>
<when>
<simple>${exception.class} == 'java.lang.SecurityException' || ${exception.class} == 'java.lang.IllegalArgumentException'</simple>
<setHeader name="CamelHttpResponseCode"><simple>401</simple></setHeader>
</when>
<when>
<simple>${exception.class} == 'java.io.IOException' || ${exception.class} == 'java.lang.RuntimeException'</simple>
<setHeader name="CamelHttpResponseCode"><simple>400</simple></setHeader>
</when>
<otherwise>
<setHeader name="CamelHttpResponseCode"><simple>500</simple></setHeader>
<transform><constant>Internal Server Error</constant></transform>
</otherwise>
</choice>
</onException>
<process ref="idsMultiPartInputProcessor" />
<setHeader name="ids-protocol"><simple>idsMultipart</simple></setHeader>
<process ref="chInputValidationProcessor" />
<process ref="chSharedSecretProcessor" />
<to uri="http://logging-service:8000/?bridgeEndpoint=true&throwExceptionOnFailure=false" />
<process ref="chOutputProcessor" />
<process ref="idsMultiPartOutputProcessor" />
</route>
<route id="CH_IDSCP2_ROUTE">
<from uri="idscp2server://0.0.0.0:29292?idscp2Configuration=#idscp2Config&secureChannelConfigurationBuilder=#tlsConfig&useIdsMessages=true&copyHeadersRegex=%28ch-ids-%5Ba-z%5D%2A%7CContent-Type%29"/>
<onException>
<exception>java.io.IOException</exception>
<exception>java.lang.RuntimeException</exception>
<exception>java.lang.SecurityException</exception>
<exception>java.lang.IllegalArgumentException</exception>
<handled>
<constant>true</constant>
</handled>
<log message="### Handle ${exception.class} ###"/>
<removeHeader name="ids-header"/>
<removeHeader name="ids-protocol"/>
<removeHeader name="pid"/>
<removeHeader name="id"/>
<process ref="chExceptionProcessor"/>
</onException>
<process ref="idsMessageTypeExtractionProcessor"/>
<setHeader name="ids-protocol"><simple>idscp2</simple></setHeader>
<choice>
<when>
<simple>${exchangeProperty.ids-type} == 'RequestMessage'</simple>
<log message="### Handle RequestMessage ###"/>
<setHeader name="CamelHttpMethod"><simple>POST</simple></setHeader>
<setHeader name="CamelHttpPath"><simple>/process/${headers.ch-ids-pid}</simple></setHeader>
<process ref="chInputValidationProcessor"/>
<process ref="chSharedSecretProcessor" />
<to uri="http://logging-service:8000/?bridgeEndpoint=true&throwExceptionOnFailure=false" />
<process ref="chOutputProcessor" />
</when>
<when>
<simple>${exchangeProperty.ids-type} == 'QueryMessage'</simple>
<log message="### Handle QueryMessage ###"/>
<setHeader name="CamelHttpMethod"><simple>POST</simple></setHeader>
<setHeader name="CamelHttpPath"><simple>/messages/query/${headers.ch-ids-pid}</simple></setHeader>
<process ref="chInputValidationProcessor"/>
<process ref="chSharedSecretProcessor" />
<to uri="http://logging-service:8000/?bridgeEndpoint=true&throwExceptionOnFailure=false" />
<process ref="chOutputProcessor" />
</when>
<when>
<simple>${exchangeProperty.ids-type} == 'LogMessage'</simple>
<log message="### Handle LogMessage ###"/>
<setHeader name="CamelHttpMethod"><simple>POST</simple></setHeader>
<setHeader name="CamelHttpPath"><simple>/messages/log/${headers.ch-ids-pid}</simple></setHeader>
<process ref="chInputValidationProcessor"/>
<process ref="chSharedSecretProcessor" />
<to uri="http://logging-service:8000/?bridgeEndpoint=true&throwExceptionOnFailure=false" />
<process ref="chOutputProcessor" />
</when>
<otherwise>
<log loggingLevel="ERROR" message="### Server received unexpected message (otherwise branch):\n${body}\n### Header: ###\n${headers[idscp2-header]}"/>
<setBody><simple>${null}</simple></setBody>
</otherwise>
</choice>
<removeHeader name="ids-protocol"/>
<removeHeader name="pid"/>
<removeHeader name="id"/>
</route>
</camelContext>
</beans>