title: Apache Camel 2.14 Rest DSL Security
body: <p>I would like to use the new Rest DSL in Apache Camel 2.14 to create a rest interface. I would like to use the Jetty component and I have a basic example setup like this: </p>
  
  <p><strong>Spring Security Configuration</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:spring-security="http://www.springframework.org/schema/security"
         xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/spring-security http://camel.apache.org/schema/spring-security/camel-spring-security.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"&gt;
  
  
  &lt;spring-security:http auto-config="true" use-expressions="true" &gt;
      &lt;spring-security:intercept-url pattern="/**" access="isFullyAuthenticated()"/&gt;
      &lt;spring-security:http-basic&gt;&lt;/spring-security:http-basic&gt;
  &lt;/spring-security:http&gt;
  
  &lt;bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"&gt;
      &lt;property name="allowIfAllAbstainDecisions" value="true"/&gt;
      &lt;property name="decisionVoters"&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.security.access.vote.RoleVoter"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  
  &lt;spring-security:authentication-manager alias="authenticationManager"&gt;
      &lt;spring-security:authentication-provider user-service-ref="userDetailsService"/&gt;
  &lt;/spring-security:authentication-manager&gt;
  
  
  &lt;spring-security:user-service id="userDetailsService"&gt;
      &lt;spring-security:user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN"/&gt;
      &lt;spring-security:user name="user" password="user" authorities="ROLE_USER"/&gt;
  &lt;/spring-security:user-service&gt;
  
  
  &lt;authorizationPolicy id="admin" access="ROLE_ADMIN"
                       authenticationManager="authenticationManager"
                       accessDecisionManager="accessDecisionManager"
                       xmlns="http://camel.apache.org/schema/spring-security"/&gt;
  
  &lt;authorizationPolicy id="user" access="ROLE_USER"
                       xmlns="http://camel.apache.org/schema/spring-security"/&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Camel Route Configuration</strong></p>
  
  <pre><code>restConfiguration().component("jetty").host("0.0.0.0").port(24999).bindingMode(RestBindingMode.json).dataFormatProperty("prettyPrint", "true");
  
      rest("address").description("Contains services for addresses").
              consumes("application/json").
              produces("application/json").
              get().      
              route().policy("admin").
              to("bean:restAddressApi?method=queryAddress").endRest();
  </code></pre>
  
  <p>When I try to access this protected URL using wget with this:</p>
  
  <pre><code> wget --http-user=admin --http-password=admin http://localhost:24999/address/
  </code></pre>
  
  <p>Then I get this error in the console:</p>
  
  <pre><code>org.apache.camel.CamelAuthorizationException: Cannot find the Authentication instance.. Exchange[Message: [Body is null]]
  at org.apache.camel.component.spring.security.SpringSecurityAuthorizationPolicy.beforeProcess(SpringSecurityAuthorizationPolicy.java:72)
  at org.apache.camel.component.spring.security.SpringSecurityAuthorizationPolicy$AuthorizeDelegateProcess.process(SpringSecurityAuthorizationPolicy.java:120)
  at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
  at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:416)
  at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
  at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
  at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
  at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
  at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:150)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
  at org.eclipse.jetty.server.handler.ResourceHandler.handle(ResourceHandler.java:406)
  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
  at org.eclipse.jetty.server.Server.handle(Server.java:370)
  at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
  at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
  at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
  at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
  at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
  at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
  at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
  at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
  at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>What am I missing in my config to get this working? </p>