I've had similar problems
(http://camel.465427.n5.nabble.com/Rest-DSL-how-to-configure-SSL-Basic-Auth-for-Jetty-component-td5758003.html)
and therefore created a github project
(https://github.com/RovoMe/CamelMultipleJettyComponents/tree/rest-dsl) to
test Camel's REST-DSL with SSL/Basic Auth configured for a Jetty Server. 

There are currently a couple of issues to keep in mind:

1) On specifying a security handler (for basic auth), this handler must be
added only once to a route! This has a short mentioning in the component
docs - but may be skiped easily! This was somehow no issue before Camel
2.14.0.
(http://camel.465427.n5.nabble.com/Issue-using-multiple-services-broadcast-via-JettyComponent-td5757958.html)
2) Setting a security handler via .componentProperty("handler",
"springBeanNameOfSecurityHandler") ignores the handler and therefore wont
even ask for the user credentials.
3) Having multiple HTTP operations defined within the same route and a
security handler defined via .endpointProperty("handlers",
"springBeanNameOfSecurityHandler") will try to initialize the handler for
each HTTP operation and therefore yield the problem described in 1)
4) I still have no clue on how to directly add a handler to the
JettyHttpComponent to avoid these multiple additions problem (which
furthermore does raise some unclear exception)

The example project linked above contains 3 route-classes: the first two
route classes simply define a Jetty endpoint via the services.properties
where the first route declares a basic authentication handler for Jetty
which is simply added via ...&handlers=#jettyAuthHandler&... to the
endpoint. As this handler is only allowed to be added once for the same port
the other routes must not add this handler. 

Route3 defines a REST route using Camels REST-DSL. Post and Delete
operations are currently disabled as they only work if the handlers endpoint
property configuration in Route3 is removed. You can though achieve global
basic auth handling by activating route1 (but still disable the endpoint
property specifications for handlers in Route3)

Currently the first two routes are disabled. To enable them simply remove
the comment declaration from ServicesSpringConfig. On enabling route1 make
sure to comment out the .endpointProperty("handlers", "jettyAuthHandler")
specification in Route3.

This project still lacks proper unit-tests, but you can test the behavior if
you simply run ServicesApp as a console application and point your browser
to https://localhost:8383/api/v1/serviceN where N should be replace by 1, 2
or 3 depending on which services you have enabled. If you have enabled the
basic auth handler you should be asked for user credentials (user=admin;
pw=secret)

Hope this helps and Claus or Willem can have a look at those issues



--
View this message in context: 
http://camel.465427.n5.nabble.com/Rest-DSL-with-jetty-and-SSL-tp5767572p5767688.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to