camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From souciance <souciance.eqdam.ras...@gmail.com>
Subject Re: http4 client fails basicAuth whilst http works
Date Thu, 07 Jul 2016 14:14:20 GMT
Hi,

What error do you get when you ran it with http4?

Best
Souciance

On Thu, Jul 7, 2016 at 4:09 PM, ianwatson [via Camel] <
ml-node+s465427n5784930h93@n5.nabble.com> wrote:

> Using the following routes it appears the http4 component does not work
> specifying the the authUsername/Password. Changing the component to http
> solves the issue, it appears therefore that this is a bug with http4.
>
> A workaround would be to use either the http component of set the
> Authorization header manually for example
> (setHeader("Authorization").constant("Basic aWFuOmlhbg=="))
>
> The code is below:
>
> from("direct://callRestEndpoint")
>                 .log(LoggingLevel.DEBUG, ">> Call REST")
>                 .setHeader("Content-Type").constant("application/json")
>                 .setHeader("Accept").constant("application/json")
>                 .setHeader("CamelHttpMethod").constant("POST")
>                 .inOut("*http4*://localhost:9191/rest/customerservice/enrich?authUsername=ian&authPassword=ian&authMethod=Basic")
>
>
>
>
>
>
> Sample code is below:
>
> Rest service:
>
> restConfiguration().host("localhost").component("jetty").port("9191").endpointProperty("handlers",
> "securityHandler");
>
> rest("/rest/customerservice")
>
> .post("/enrich").consumes("application/json").produces("application/json").id("rest-customerservice")
>
>             .to("direct://restservice");
>
> Security Handler config in XML:
>
> <bean id="constraint" class="org.eclipse.jetty.util.security.Constraint">
>     <property name="name" value="BASIC"/>
>     <property name="roles" value="ian"/>
>     <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="loginService"
> class="org.eclipse.jetty.security.HashLoginService">
>                 <constructor-arg type="java.lang.String" value="MyRealm"/>
>                 <constructor-arg type="java.lang.String"
> value="src/main/resources/realm.properties"/>
>         </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>
>             <property name="loginService" ref="loginService"></property>
>         </bean>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/http4-client-fails-basicAuth-whilst-http-works-tp5784930.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/http4-client-fails-basicAuth-whilst-http-works-tp5784930p5784932.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message