Kevin,

Here is an example that works fine.
It uses Blueprint instead of Spring however.

I initially followed the instructions for camel-jetty on
http://camel.apache.org/jetty.html with the sample "camel-blueprint", but I
had the following error : 
Unable to start blueprint container for bundle camel-blueprint
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
validate xml
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute
'bean' is not allowed to appear in element 'ref'.

Then I had to define the Jetty LoginService (AKA realm) because of the
following error :
java.lang.IllegalStateException: No LoginService for
org.eclipse.jetty.security.authentication.BasicAuthenticator@c8158d in
org.eclipse.jetty.security.ConstraintSecurityHandler@1ff0777

Remark : I could not find a way to get rid of the full path to the
users.properties files, because for some reason the placeholder mechanism
does not work (the value does not replace its placeholder but is appended to
it).

Hope it helps,

metatech
==========================
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
        xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>

        <cm:property-placeholder persistent-id="org.apache.servicemix.examples">
                <cm:default-properties>
                        <cm:property name="prefix" value="Blueprint-Example" />
                </cm:default-properties>
        </cm:property-placeholder>

        <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
                <route>
                        <from
                                
uri="jetty:http://0.0.0.0:8192/PersonService?handlers=mySecurityHandler";
/>
                        <bean ref="myTransform" method="transform" />
                        <to uri="log:ExampleRouterBlueprint" />
                </route>
        </camelContext>

        <bean id="myTransform"
class="org.apache.servicemix.examples.camel.MyTransform">
                <property name="prefix" value="${prefix}" />
        </bean>

        
        <bean id="myLoginService"
class="org.eclipse.jetty.security.HashLoginService">
                <property name="name" value="MyRealm" />
                <property name="config"
                        
value="/data/software/apache-servicemix-4.3.0/etc/users.properties" />
                <property name="refreshInterval" value="0" />
        </bean>

        <bean id="myConstraint" 
class="org.eclipse.jetty.http.security.Constraint">
                <property name="name" value="BASIC" />
                <property name="roles">
                        <list>
                                <value>admin</value>
                        </list>
                </property>
                <property name="authenticate" value="true" />
        </bean>

        <bean id="myConstraintMapping"
class="org.eclipse.jetty.security.ConstraintMapping">
                <property name="constraint" ref="myConstraint" />
                <property name="pathSpec" value="/*" />
        </bean>

        <bean id="mySecurityHandler"
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
                <property name="authenticator">
                        <bean
class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
                </property>
                <property name="constraintMappings">
                        <list>
                                <ref component-id="myConstraintMapping" />
                        </list>
                </property>
                <property name="loginService" ref="myLoginService" />
                <property name="strict" value="false" />
        </bean>
</blueprint>


--
View this message in context: 
http://servicemix.396122.n5.nabble.com/troubles-configuring-http-basic-authentication-on-camel-jetty-tp2851353p4586669.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to