<?xml version="1.0" encoding="UTF-8"?><!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ 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.
--><blueprintxmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:camel="http://camel.apache.org/schema/blueprint"xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint-2.17.1.xsd"><beanid="kcAdapterConfig"class="org.keycloak.representations.adapters.config.AdapterConfig"><propertyname="realm"value="demo"/><propertyname="resource"value="admin-camel-endpoint"/><propertyname="bearerOnly"value="true"/><propertyname="authServerUrl"value="http://localhost:8080/auth" /><propertyname="sslRequired"value="EXTERNAL"/></bean><beanid="keycloakAuthenticator"class="org.keycloak.adapters.jetty.KeycloakJettyAuthenticator"><propertyname="adapterConfig"ref="kcAdapterConfig"/></bean><beanid="constraint"class="org.eclipse.jetty.util.security.Constraint"><propertyname="name"value="Customers"/><propertyname="roles"><list><value>admin</value></list></property><propertyname="authenticate"value="true"/><propertyname="dataConstraint"value="0"/></bean><beanid="constraintMapping"class="org.eclipse.jetty.security.ConstraintMapping"><propertyname="constraint"ref="constraint"/><propertyname="pathSpec"value="/*"/></bean><beanid="securityHandler"class="org.eclipse.jetty.security.ConstraintSecurityHandler"><propertyname="authenticator"ref="keycloakAuthenticator" /><propertyname="constraintMappings"><list><refcomponent-id="constraintMapping" /></list></property><propertyname="authMethod"value="BASIC"/><propertyname="realmName"value="does-not-matter"/></bean><beanid="securityHandlerRest"class="org.eclipse.jetty.security.ConstraintSecurityHandler"><propertyname="authenticator"ref="keycloakAuthenticator" /><propertyname="constraintMappings"><list><refcomponent-id="constraintMapping" /></list></property><propertyname="authMethod"value="BASIC"/><propertyname="realmName"value="does-not-matter"/></bean><!--we need 2 independent instance of sessionHandler, since jetty will try to start both--><beanid="sessionHandler"class="org.keycloak.adapters.jetty.spi.WrappingSessionHandler"><propertyname="handler"ref="securityHandler" /></bean><beanid="sessionHandlerRest"class="org.keycloak.adapters.jetty.spi.WrappingSessionHandler"><propertyname="handler"ref="securityHandlerRest" /></bean><beanid="helloProcessor"class="org.keycloak.example.CamelHelloProcessor" /><camelContextid="blueprintContext"trace="false"xmlns="http://camel.apache.org/schema/blueprint"><restConfigurationcomponent="jetty"contextPath="/restdsl"port="8484"><!--the link with Keycloak security handlers happens here--><endpointPropertykey="handlers"value="sessionHandlerRest"></endpointProperty><endpointPropertykey="matchOnUriPrefix"value="true"></endpointProperty></restConfiguration><restpath="/hello" ><description>Hello rest service</description><geturi="/{id}"outType="java.lang.String"><description>Just an helllo</description><touri="direct:justDirect" /></get></rest><routeid="justDirect"><fromuri="direct:justDirect"/><processref="helloProcessor" /><logmessage="RestDSL correctly invoked ${body}"/><setBody><constant>(__This second sentence is returned from a Camel RestDSL endpoint__)</constant></setBody></route><routeid="httpBridge"><!--note that we are passing to the endoint the security handlers we have defined above--><fromuri="jetty:http://0.0.0.0:8383/admin-camel-endpoint?handlers=sessionHandler&matchOnUriPrefix=true" /><processref="helloProcessor" /><logmessage="The message from camel endpoint contains ${body}"/></route></camelContext></blueprint>