Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Message Headers

Name

Type

Description

org.apache.camel.restlet.auth.login

String

Login name for basic authentication. It is set on the IN message by application and get filtered before Restlet Request header by Camel.

org.apache.camel.restlet.auth.password

String

Password name for basic authentication. It is set on the IN message by application and get filtered before Restlet Request header by Camel.

org.restlet.*

String, Map  

Attributes of a Restlet message that get propagated to Camel IN headers.

...

Camel will store the Restlet response from the external server on the OUT body. All headers from the IN message will be copied to the OUT message so headers is preserved during routing.

Samples

Restlet Endpoint with Authentication

This sample starts a Restlet consumer endpoint that listens POST requests on http://localhost:8080Image Added. The route looks like follow. The consumer invokes a processor that creates a response to echo the request body and the value of header "id".

Wiki Markup
{snippet:id=consumer_route|lang=java|url=activemq/camel/trunk/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java}

The restletRealmRef in URI query is an option to lookup a Realm Map in the registry. If this option is specified, the Restlet consumer will use the information to authenticate user logins. Only authenticated requests can access the resources. In this sample, we create a Spring application context that serves as a registry. The bean ID of the Realm Map should match the restletRealmRef.

Wiki Markup
{snippet:id=realm|lang=xml|url=activemq/camel/trunk/camel-restlet/src/test/resources/org/apache/camel/component/restlet/camel-context.xml}

The sample starts a direct endpoint that sends requests to the server on http://localhost:8080Image Added (i.e. our Restlet consumer endpoint).

Wiki Markup
{snippet:id=producer_route|lang=java|url=activemq/camel/trunk/camel-restlet/src/test/java/org/apache/camel/component/restlet/route/TestRouteBuilder.java}

That is all we need. We are ready to send a request and try out the Restlet component. The sample client sends a request to "direct:start-auth" endpoint with the following headers. Notice that org.apache.camel.restlet.auth.login and org.apache.camel.restlet.auth.password will not be propagated as Restlet header.

  • org.apache.camel.restlet.auth.login (internally used by Camel)
  • org.apache.camel.restlet.auth.password (internally used by Camel)
  • id ("application" header)
Wiki Markup
{snippet:id=auth_request|lang=java|url=activemq/camel/trunk/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java}

The sample client will get a response:

Code Block

received [<order foo='1'/>] as an order id = 89531