You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Kévin Sailly <ke...@gmail.com> on 2010/09/24 12:26:43 UTC

Re: troubles configuring http basic authentication on camel-jetty

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

Re: troubles configuring http basic authentication on camel-jetty

Posted by Kévin Sailly <ke...@gmail.com>.
Hello,

I have found out the solution using this beans and configuring them
correctly :
 
 <bean id="loginService"
class="org.eclipse.jetty.security.HashLoginService"> 

        <property name="name" value="royaume" /> 

        <property name="config" value="./etc/realm.properties" /> 

  </bean> 



  <bean id="konstraint" class="org.eclipse.jetty.http.security.Constraint"> 

        <property name="name" value="BASIC" /> 

        <property name="authenticate" value="true" /> 

        <property name="roles" value="myrole" /> 

  </bean> 

  

   <bean id="mappin" class="org.eclipse.jetty.security.ConstraintMapping"> 

        <property name="pathSpec" value="/*" /> 

        <property name="constraint" ref="konstraint" /> 

  </bean> 



  <bean id="sekurityHandler"
class="org.eclipse.jetty.security.ConstraintSecurityHandler"> 

        <property name="constraintMappings"> 

                <list> 

                        <ref bean="mappin"/> 

                </list> 

        </property>

        <property name="authenticator"> 

                <bean
class="org.eclipse.jetty.security.authentication.BasicAuthenticator" /> 

        </property> 

        <property name="loginService" ref="loginService" /> 

  </bean>

 
  
and using the appropriate realm.properties file with users,password, roles:
myuser:mypassword, myrole
...

Thanks,
Kévin


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

Re: troubles configuring http basic authentication on camel-jetty

Posted by metatech <me...@gmail.com>.
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.