[ 
https://issues.apache.org/jira/browse/CAMEL-14843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17075828#comment-17075828
 ] 

Gerald Kallas commented on CAMEL-14843:
---------------------------------------

Added the list of roles. Now it works like a charm.
{code:java}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";
           
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";>

   <bean id="constraint" class="org.eclipse.jetty.util.security.Constraint">
      <property name="name" value="BASIC"/>
      <property name="authenticate" value="true"/>
      <property name="roles">
         <list>
            <value>hello</value>
         </list>
      </property>
   </bean>

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

   <bean id="securityHandler" 
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
      <property name="loginService">
         <bean class="org.eclipse.jetty.security.HashLoginService">
            <property name="config" 
value="/opt/apache-karaf/etc/hello.properties"/>
            <property name="hotReload" value="true"/>
         </bean>
      </property>
      <property name="authenticator">
         <bean 
class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
      </property>
      <property name="constraintMappings">
         <list>
            <ref component-id="constraintMapping"/>
         </list>
      </property>
   </bean>

   <camelContext id="WEBISP001" 
xmlns="http://camel.apache.org/schema/blueprint";>

      <route id="WEBISP001">
         <from uri="jetty:http://0.0.0.0:8182/hello?handlers=securityHandler"/>
         <log message="hello request body: ${in.body}"/>
      </route>

   </camelContext>
</blueprint>
{code}
[~davsclaus] may be worth a documentation update because something in Jetty9 
has changed?

> Outdated documentation for camel-jetty Basic Authentication
> -----------------------------------------------------------
>
>                 Key: CAMEL-14843
>                 URL: https://issues.apache.org/jira/browse/CAMEL-14843
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 3.0.1
>            Reporter: Gerald Kallas
>            Priority: Major
>
> The documentation for camel-jetty seems to be outdated as the HTTP Basic 
> Authentication sample doesn't work as described. See the route below.
> I followed the documentation
> [https://camel.apache.org/components/latest/jetty-component.html]
> 2 observations
>  * Unresolved requirements: [[WEBISP001.xml [264](R 264.12)] 
> osgi.wiring.package; (osgi.wiring.package=org.eclipse.jetty.http.security)]
>  * org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'bean' is 
> not allowed to appear in element 'ref'.
> The documentation should be updated to provide a working configuration for 
> Camel 3.x
> {code:java}
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 
> https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";
>    xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";>
>    <bean id="constraint" class="org.eclipse.jetty.http.security.Constraint">
>       <property name="name" value="BASIC"/>
>       <property name="roles" value="tracker-users"/>
>       <property name="authenticate" value="true"/>
>    </bean>
>    <bean id="constraintMapping" 
> class="org.eclipse.jetty.security.ConstraintMapping">
>       <property name="constraint" ref="constraint"/>
>       <property name="pathSpec" value="/*"/>
>    </bean>
>    <bean id="securityHandler" 
> class="org.eclipse.jetty.security.ConstraintSecurityHandler">
>       <property name="authenticator">
>          <bean 
> class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
>       </property>
>       <property name="constraintMappings">
>          <list>
>             <ref bean="constraintMapping"/>
>          </list>
>       </property>
>    </bean>
>    <camelContext id="WEBISP001" 
> xmlns="http://camel.apache.org/schema/blueprint";>
>       <route id="WEBISP001">
>          <from uri="jetty:http://0.0.0.0:8182/hello"; />
>          <log message="hello request body: ${in.body}" />
>       </route>
>    </camelContext>
>  </blueprint>
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to