You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2017/01/25 16:19:49 UTC

svn commit: r1005583 [2/2] - in /websites/production/camel/content: book-component-appendix.html book-in-one-page.html cache/main.pageCache jetty.html

Modified: websites/production/camel/content/jetty.html
==============================================================================
--- websites/production/camel/content/jetty.html (original)
+++ websites/production/camel/content/jetty.html Wed Jan 25 16:19:48 2017
@@ -107,8 +107,8 @@
 ]]></script>
 </div></div><p><strong>XML DSL</strong>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
-    &lt;from uri=&quot;direct:start&quot;/&gt;
-    &lt;to uri=&quot;jetty://http://www.google.com&quot;/&gt;
+  &lt;from uri=&quot;direct:start&quot;/&gt;
+  &lt;to uri=&quot;jetty://http://www.google.com&quot;/&gt;
 &lt;route&gt;
 ]]></script>
 </div></div><h3 id="Jetty-ConsumerExample">Consumer Example</h3><p>In this sample we define a route that exposes a HTTP service at <code><a shape="rect" class="external-link" href="http://localhost:8080/myapp/myservice" rel="nofollow">http://localhost:8080/myapp/myservice</a></code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -144,8 +144,8 @@ from(&quot;jetty:&quot; + serverUri)
 ]]></script>
 </div></div>If a client sends an HTTP request, <code><a shape="rect" class="external-link" href="http://serverUri?one=hello" rel="nofollow">http://serverUri?one=hello</a></code>, the Jetty component will copy the HTTP request parameter, <strong><code>one</code></strong> to the exchange's <strong><code>in.header</code></strong>. We can then use the <strong><code>simple</code></strong> language to route exchanges that contain this header to a specific endpoint and all others to another. If we used a language more powerful than <a shape="rect" href="simple.html">Simple,</a> e.g., <a shape="rect" href="el.html">EL</a> or <a shape="rect" href="ognl.html">OGNL</a>, then we can also test for the parameter value and route based on the header value as well.<h3 id="Jetty-SessionSupport">Session Support</h3><p>The session support option, <strong><code>sessionSupport</code></strong>, can be used to enable a <strong><code>HttpSession</code></strong> object and access the session object while pro
 cessing the exchange.</p><p>For example, the following route enables sessions:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
-    &lt;from uri=&quot;jetty:http://0.0.0.0/myapp/myservice/?sessionSupport=true&quot;/&gt;
-    &lt;processRef ref=&quot;myCode&quot;/&gt;
+  &lt;from uri=&quot;jetty:http://0.0.0.0/myapp/myservice/?sessionSupport=true&quot;/&gt;
+  &lt;processRef ref=&quot;myCode&quot;/&gt;
 &lt;route&gt;
 ]]></script>
 </div></div><p>The <strong><code>myCode</code></strong> <a shape="rect" href="processor.html">Processor</a> can be instantiated by a Spring <strong><code>bean</code></strong> element:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -154,7 +154,7 @@ from(&quot;jetty:&quot; + serverUri)
 </div></div><p>Where the processor implementation can access the <strong><code>HttpSession</code></strong> as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[public void process(Exchange exchange) throws Exception {
     HttpSession session = exchange.getIn(HttpMessage.class).getRequest().getSession();
-    ...
+    // ...
 }
 ]]></script>
 </div></div><h3 id="Jetty-SSLSupport(HTTPS)">SSL Support (HTTPS)</h3><h5 id="Jetty-UsingtheJSSEConfigurationUtility">Using the JSSE Configuration Utility</h5><p>From <strong>Camel 2.8</strong>: the&#160;<strong><code>camel-jetty</code></strong> component supports SSL/TLS configuration through the <a shape="rect" href="camel-configuration-utilities.html">Camel JSSE Configuration Utility</a>.&#160; This utility greatly decreases the amount of component specific code you need to write and is configurable at the endpoint and component levels.&#160; The following examples demonstrate how to use the utility with the Jetty component.</p><h6 id="Jetty-Programmaticconfigurationofthecomponent">Programmatic configuration of the component</h6><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -173,112 +173,105 @@ JettyComponent jettyComponent = getConte
 jettyComponent.setSslContextParameters(scp);
 ]]></script>
 </div></div><h6 id="Jetty-SpringDSLbasedconfigurationofendpoint">Spring DSL based configuration of endpoint</h6><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[...
-  &lt;camel:sslContextParameters
-      id=&quot;sslContextParameters&quot;&gt;
-    &lt;camel:keyManagers
-        keyPassword=&quot;keyPassword&quot;&gt;
-      &lt;camel:keyStore
-          resource=&quot;/users/home/server/keystore.jks&quot;
-          password=&quot;keystorePassword&quot;/&gt;
-    &lt;/camel:keyManagers&gt;
-  &lt;/camel:sslContextParameters&gt;...
-...
-  &lt;to uri=&quot;jetty:https://127.0.0.1/mail/?sslContextParametersRef=sslContextParameters&quot;/&gt;
-...
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;camel:sslContextParameters id=&quot;sslContextParameters&quot;&gt;
+  &lt;camel:keyManagers keyPassword=&quot;keyPassword&quot;&gt;
+    &lt;camel:keyStore resource=&quot;/users/home/server/keystore.jks&quot; password=&quot;keystorePassword&quot;/&gt;
+  &lt;/camel:keyManagers&gt;
+&lt;/camel:sslContextParameters&gt;
+
+&lt;to uri=&quot;jetty:https://127.0.0.1/mail/?sslContextParametersRef=sslContextParameters&quot;/&gt;
 ]]></script>
 </div></div><h5 id="Jetty-ConfiguringJettyDirectly">Configuring Jetty Directly</h5><p>Jetty provides SSL support out of the box. To enable Jetty to run in SSL mode, simply format the URI using the <strong><code>https://</code></strong> prefix.</p><p><strong>Example</strong>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;from uri=&quot;jetty:https://0.0.0.0/myapp/myservice/&quot;/&gt;
 ]]></script>
-</div></div><p>Jetty also needs to know where to load your keystore from and what passwords to use in order to load the correct SSL certificate. Set the following JVM System Properties:</p><p><strong>Before Camel 2.3</strong>:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Property</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>jetty.ssl.keystore</code></td><td colspan="1" rowspan="1" class="confluenceTd">Specifies the location of the Java&#160;<strong><code>keystore</code></strong> file, which contains the Jetty server's own&#160;<strong><code>X.509</code></strong> certificate in a <em>key entry</em>. A key entry stores the&#160;<strong><code>X.509</code></strong> certificate (effectively, the <em>public key</em>) and also its associated private key.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>jetty.ssl.
 password</code></td><td colspan="1" rowspan="1" class="confluenceTd">The store password, which is required to access the&#160;<strong><code>keystore</code></strong> file (this is the same password that is supplied to the <strong><code>keystore</code></strong> command's <strong><code>-storepass</code></strong> option).</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>jetty.ssl.keypassword</code></td><td colspan="1" rowspan="1" class="confluenceTd">The key password, which is used to access the certificate's key entry in the&#160;<strong><code>keystore</code></strong> (this is the same password that is supplied to the <strong><code>keystore</code></strong> command's <strong><code>-keypass</code></strong> option).</td></tr></tbody></table></div><p>&#160;</p><p><strong>From Camel 2.3</strong>:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Property</th><th colspan="1" rowspan="1" class="confluenceTh
 ">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>org.eclipse.jetty.ssl.keystore</code></td><td colspan="1" rowspan="1" class="confluenceTd">Specifies the location of the Java&#160;<strong><code>keystore</code></strong> file, which contains the Jetty server's own&#160;<strong><code>X.509</code></strong> certificate in a <em>key entry</em>. A key entry stores the&#160;<strong><code>X.509</code></strong> certificate (effectively, the <em>public key</em>) and also its associated private key.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>org.eclipse.jetty.ssl.password</code></td><td colspan="1" rowspan="1" class="confluenceTd">The store password, which is required to access the&#160;<strong><code>keystore</code></strong> file (this is the same password that is supplied to the&#160;<strong><code>keystore</code></strong> command's&#160;<strong><code>keystore</code></strong> option).</td></tr><tr><td colspan="1" rowspan="1" class="confl
 uenceTd"><code>org.eclipse.jetty.ssl.keypassword</code></td><td colspan="1" rowspan="1" class="confluenceTd">The key password, which is used to access the certificate's key entry in the&#160;<strong><code>keystore</code></strong> (this is the same password that is supplied to the&#160;<strong><code>keystore</code></strong> command's&#160;<strong><code>keystore</code></strong> option).</td></tr></tbody></table></div><p>For details of how to configure SSL on a Jetty endpoint, read the following <a shape="rect" class="external-link" href="http://www.eclipse.org/jetty/documentation/current/configuring-ssl.html" rel="nofollow">Jetty documentation</a>.</p><p>Some SSL properties aren't exposed directly by Camel. However, Camel does expose the underlying <strong><code>SslSocketConnector</code></strong>, which will allow you to set properties like&#160;<strong><code>needClientAuth</code></strong> for mutual authentication requiring a client certificate or&#160;<strong><code>wantClientAuth</c
 ode></strong> for mutual authentication where a client doesn't need a certificate but can have one.</p><p>There's a slight difference between the various Camel versions:</p><p><strong>Up to Camel 2.2</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Jetty also needs to know where to load your keystore from and what passwords to use in order to load the correct SSL certificate. Set the following JVM System Properties:</p><p><strong>Before Camel 2.3</strong>:</p><div class="confluenceTableSmall"><div class="table-wrap">
+ <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Property</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jetty.ssl.keystore</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the location of the Java&#160;<strong><code>keystore</code></strong> file, which contains the Jetty server's own&#160;<strong><code>X.509</code></strong> certificate in a <em>key entry</em>. A key entry stores the&#160;<strong><code>X.509</code></strong> certificate (effectively, the <em>public key</em>) and also its associated private key.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jetty.ssl.password</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The store password, which is required to access the&#160;<strong><code>keystore</code></strong> file (this is the same password that is supplied t
 o the <strong><code>keystore</code></strong> command's <strong><code>-storepass</code></strong> option).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jetty.ssl.keypassword</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The key password, which is used to access the certificate's key entry in the&#160;<strong><code>keystore</code></strong> (this is the same password that is supplied to the <strong><code>keystore</code></strong> command's <strong><code>-keypass</code></strong> option).</p></td></tr></tbody></table>
+</div></div><p>&#160;</p><p><strong>From Camel 2.3</strong>:</p><div class="confluenceTableSmall"><div class="table-wrap">
+ <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Property</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.eclipse.jetty.ssl.keystore</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the location of the Java&#160;<strong><code>keystore</code></strong> file, which contains the Jetty server's own&#160;<strong><code>X.509</code></strong> certificate in a <em>key entry</em>. A key entry stores the&#160;<strong><code>X.509</code></strong> certificate (effectively, the <em>public key</em>) and also its associated private key.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.eclipse.jetty.ssl.password</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The store password, which is required to access the&#160;<strong><code>keystore</code></strong> file (this is the same pas
 sword that is supplied to the&#160;<strong><code>keystore</code></strong> command's&#160;<strong><code>keystore</code></strong> option).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.eclipse.jetty.ssl.keypassword</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The key password, which is used to access the certificate's key entry in the&#160;<strong><code>keystore</code></strong> (this is the same password that is supplied to the&#160;<strong><code>keystore</code></strong> command's&#160;<strong><code>keystore</code></strong> option).</p></td></tr></tbody></table>
+</div></div><p>For details of how to configure SSL on a Jetty endpoint, read the following <a shape="rect" class="external-link" href="http://www.eclipse.org/jetty/documentation/current/configuring-ssl.html" rel="nofollow">Jetty documentation</a>. Some SSL properties aren't exposed directly by Camel. However, Camel does expose the underlying <strong><code>SslSocketConnector</code></strong>, which will allow you to set properties like&#160;<strong><code>needClientAuth</code></strong> for mutual authentication requiring a client certificate or&#160;<strong><code>wantClientAuth</code></strong> for mutual authentication where a client doesn't need a certificate but can have one.</p><p>There's a slight difference between the various Camel versions:</p><p><strong>Up to Camel 2.2</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;jetty&quot; class=&quot;org.apache.camel.component.jetty.JettyHttpComponent&quot;&gt;
-    &lt;property name=&quot;sslSocketConnectors&quot;&gt;
-        &lt;map&gt;
-            &lt;entry key=&quot;8043&quot;&gt;
-                &lt;bean class=&quot;org.mortbay.jetty.security.SslSocketConnector&quot;&gt;
-                    &lt;property name=&quot;password&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;keystore&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;truststore&quot;value=&quot;...&quot;/&gt;
-                &lt;/bean&gt;
-            &lt;/entry&gt;
-        &lt;/map&gt;
-    &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
+  &lt;property name=&quot;sslSocketConnectors&quot;&gt;
+    &lt;map&gt;
+      &lt;entry key=&quot;8043&quot;&gt;
+        &lt;bean class=&quot;org.mortbay.jetty.security.SslSocketConnector&quot;&gt;
+          &lt;property name=&quot;password&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;keystore&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;truststore&quot;value=&quot;...&quot;/&gt;
+        &lt;/bean&gt;
+      &lt;/entry&gt;
+    &lt;/map&gt;
+  &lt;/property&gt;
+&lt;/bean&gt;]]></script>
 </div></div><p><strong>Camel 2.3, 2.4</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;jetty&quot; class=&quot;org.apache.camel.component.jetty.JettyHttpComponent&quot;&gt;
-    &lt;property name=&quot;sslSocketConnectors&quot;&gt;
-        &lt;map&gt;
-            &lt;entry key=&quot;8043&quot;&gt;
-                &lt;bean class=&quot;org.eclipse.jetty.server.ssl.SslSocketConnector&quot;&gt;
-                    &lt;property name=&quot;password&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;keystore&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;truststore&quot;value=&quot;...&quot;/&gt;
-                &lt;/bean&gt;
-            &lt;/entry&gt;
-        &lt;/map&gt;
-    &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
+  &lt;property name=&quot;sslSocketConnectors&quot;&gt;
+    &lt;map&gt;
+      &lt;entry key=&quot;8043&quot;&gt;
+        &lt;bean class=&quot;org.eclipse.jetty.server.ssl.SslSocketConnector&quot;&gt;
+          &lt;property name=&quot;password&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;keystore&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;truststore&quot;value=&quot;...&quot;/&gt;
+        &lt;/bean&gt;
+      &lt;/entry&gt;
+    &lt;/map&gt;
+  &lt;/property&gt;
+&lt;/bean&gt;]]></script>
 </div></div><p>From <strong>Camel 2.5</strong>: we switch to use&#160;<strong><code>SslSelectChannelConnector *</code></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;jetty&quot; class=&quot;org.apache.camel.component.jetty.JettyHttpComponent&quot;&gt;
-    &lt;property name=&quot;sslSocketConnectors&quot;&gt;
-        &lt;map&gt;
-            &lt;entry key=&quot;8043&quot;&gt;
-                &lt;bean class=&quot;org.eclipse.jetty.server.ssl.SslSelectChannelConnector&quot;&gt;
-                    &lt;property name=&quot;password&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;keystore&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
-                    &lt;property name=&quot;truststore&quot;value=&quot;...&quot;/&gt;
-                &lt;/bean&gt;
-            &lt;/entry&gt;
-        &lt;/map&gt;
-    &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
+  &lt;property name=&quot;sslSocketConnectors&quot;&gt;
+    &lt;map&gt;
+      &lt;entry key=&quot;8043&quot;&gt;
+        &lt;bean class=&quot;org.eclipse.jetty.server.ssl.SslSelectChannelConnector&quot;&gt;
+          &lt;property name=&quot;password&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;keystore&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
+          &lt;property name=&quot;truststore&quot;value=&quot;...&quot;/&gt;
+        &lt;/bean&gt;
+      &lt;/entry&gt;
+    &lt;/map&gt;
+  &lt;/property&gt;
+&lt;/bean&gt;]]></script>
 </div></div><p>The value you use as keys in the above map is the port you configure Jetty to listen on.</p><h4 id="Jetty-ConfiguringGeneralSSLProperties">Configuring General SSL Properties</h4><p>From<strong> Camel 2.5</strong>: instead of a per port number specific SSL socket connector (as shown above) you can now configure general properties which applies for all SSL socket connectors (which is not explicit configured as above with the port number as entry).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;jetty&quot; class=&quot;org.apache.camel.component.jetty.JettyHttpComponent&quot;&gt;
-    &lt;property name=&quot;sslSocketConnectorProperties&quot;&gt;
-        &lt;map&gt;
-            &lt;entry key=&quot;password&quot;value=&quot;...&quot;/&gt;
-            &lt;entry key=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
-            &lt;entry key=&quot;keystore&quot;value=&quot;...&quot;/&gt;
-            &lt;entry key=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
-            &lt;entry key=&quot;truststore&quot;value=&quot;...&quot;/&gt;
-        &lt;/map&gt;
-    &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
+  &lt;property name=&quot;sslSocketConnectorProperties&quot;&gt;
+    &lt;map&gt;
+      &lt;entry key=&quot;password&quot;value=&quot;...&quot;/&gt;
+      &lt;entry key=&quot;keyPassword&quot;value=&quot;...&quot;/&gt;
+      &lt;entry key=&quot;keystore&quot;value=&quot;...&quot;/&gt;
+      &lt;entry key=&quot;needClientAuth&quot;value=&quot;...&quot;/&gt;
+      &lt;entry key=&quot;truststore&quot;value=&quot;...&quot;/&gt;
+    &lt;/map&gt;
+  &lt;/property&gt;
+&lt;/bean&gt;]]></script>
 </div></div><h4 id="Jetty-HowtoObtainAReferencetotheX509Certificate">How to Obtain A Reference to the&#160;<code>X509Certificate</code></h4><p>Jetty stores a reference to the certificate in the&#160;<strong><code>HttpServletRequest</code></strong> which you can access from code as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
 X509Certificate cert = (X509Certificate) req.getAttribute(&quot;javax.servlet.request.X509Certificate&quot;)
 ]]></script>
 </div></div><h4 id="Jetty-ConfiguringGeneralHTTPProperties">Configuring General HTTP Properties</h4><p>From<strong> Camel 2.5</strong>: instead of a per port number specific HTTP socket connector (as shown above) you can now configure general properties which applies for all HTTP socket connectors (which is not explicit configured as above with the port number as entry).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;jetty&quot; class=&quot;org.apache.camel.component.jetty.JettyHttpComponent&quot;&gt;
-    &lt;property name=&quot;socketConnectorProperties&quot;&gt;
-        &lt;map&gt;
-            &lt;entry key=&quot;acceptors&quot; value=&quot;4&quot;/&gt;
-            &lt;entry key=&quot;maxIdleTime&quot; value=&quot;300000&quot;/&gt;
-        &lt;/map&gt;
-    &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
+  &lt;property name=&quot;socketConnectorProperties&quot;&gt;
+    &lt;map&gt;
+      &lt;entry key=&quot;acceptors&quot; value=&quot;4&quot;/&gt;
+      &lt;entry key=&quot;maxIdleTime&quot; value=&quot;300000&quot;/&gt;
+    &lt;/map&gt;
+  &lt;/property&gt;
+&lt;/bean&gt;]]></script>
 </div></div><h4 id="Jetty-HowtoGettheValueofTheX-Forwarded-ForHTTPHeaderUsingHttpServletRequest.getRemoteAddr()">How to Get the Value of The <code>X-Forwarded-For</code> HTTP Header Using <code>HttpServletRequest.getRemoteAddr()</code></h4><p>If the HTTP requests are handled by an Apache server and forwarded to Jetty with <strong><code>mod_proxy</code></strong>, the original client IP address is in the&#160;<strong><code>X-Forwarded-For</code></strong> header and the&#160;<strong><code>HttpServletRequest.getRemoteAddr()</code></strong> will return the address of the Apache proxy.</p><p>Jetty has a forwarded property which takes the value from&#160;<strong><code>X-Forwarded-For</code></strong> and places it in the&#160;<strong><code>HttpServletRequest remoteAddr</code></strong> property.&#160; This property is not available directly through the endpoint configuration but it can be easily added using the&#160;<strong><code>socketConnectors</code></strong> property:</p><div class="code
  panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;jetty&quot; class=&quot;org.apache.camel.component.jetty.JettyHttpComponent&quot;&gt;
-    &lt;property name=&quot;socketConnectors&quot;&gt;
-        &lt;map&gt;
-            &lt;entry key=&quot;8080&quot;&gt;
-                &lt;bean class=&quot;org.eclipse.jetty.server.nio.SelectChannelConnector&quot;&gt;
-                    &lt;property name=&quot;forwarded&quot; value=&quot;true&quot;/&gt;
-                &lt;/bean&gt;
-            &lt;/entry&gt;
-        &lt;/map&gt;
-    &lt;/property&gt;
+  &lt;property name=&quot;socketConnectors&quot;&gt;
+    &lt;map&gt;
+      &lt;entry key=&quot;8080&quot;&gt;
+        &lt;bean class=&quot;org.eclipse.jetty.server.nio.SelectChannelConnector&quot;&gt;
+          &lt;property name=&quot;forwarded&quot; value=&quot;true&quot;/&gt;
+        &lt;/bean&gt;
+      &lt;/entry&gt;
+    &lt;/map&gt;
+  &lt;/property&gt;
 &lt;/bean&gt;]]></script>
 </div></div><p>This is particularly useful when an existing Apache server handles TLS connections for a domain and proxies them to application servers internally.</p><h3 id="Jetty-DefaultBehaviorforReturningHTTPStatusCodes">Default Behavior for Returning HTTP Status Codes</h3><p>The default behavior of HTTP status codes is defined by the <strong><code>org.apache.camel.component.http.DefaultHttpBinding</code></strong> class, which handles how a response is written and also sets the HTTP status code. If the exchange was processed successfully, the&#160;<strong><code>200</code></strong> HTTP status code is returned. If the exchange failed with an exception, the&#160;<strong><code>500</code></strong> HTTP status code is returned, and the stacktrace is returned in the body. If you want to specify which HTTP status code to return, set the code in the <strong><code>Exchange.HTTP_RESPONSE_CODE</code></strong> header of the&#160;<strong><code>OUT</code></strong> message.</p><h3 id="Jetty-Cus
 tomizingHttpBinding">Customizing&#160;<code>HttpBinding</code></h3><p>By default, Camel uses the <strong><code>org.apache.camel.component.http.DefaultHttpBinding</code></strong> to handle how a response is written. If you like, you can customize this behavior either by implementing your own <strong><code>HttpBinding</code></strong> class or by extending <strong><code>DefaultHttpBinding</code></strong> and overriding the appropriate methods.</p><p>The following example shows how to customize the <strong><code>DefaultHttpBinding</code></strong> in order to change how exceptions are returned:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
@@ -300,59 +293,62 @@ public class MyHttpBinding extends Defau
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;bean id=&quot;mybinding&quot;class=&quot;com.mycompany.MyHttpBinding&quot;/&gt;
 ]]></script>
 </div></div><p>And then we can reference this binding when we define the route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;&lt;from uri=&quot;jetty:http://0.0.0.0:8080/myapp/myservice?httpBindingRef=mybinding&quot;/&gt;&lt;to uri=&quot;bean:doSomething&quot;/&gt;&lt;/route&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+  &lt;from uri=&quot;jetty:http://0.0.0.0:8080/myapp/myservice?httpBindingRef=mybinding&quot;/&gt;
+  &lt;to uri=&quot;bean:doSomething&quot;/&gt;
+&lt;/route&gt;
 ]]></script>
 </div></div><h3 id="Jetty-JettyHandlersandSecurityConfiguration">Jetty Handlers and Security Configuration</h3><p>You can configure a list of Jetty handlers on the endpoint, which can be useful for enabling advanced Jetty security features. These handlers are configured in Spring XML as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;-- Jetty Security handling --&gt;
 &lt;bean id=&quot;userRealm&quot; class=&quot;org.mortbay.jetty.plus.jaas.JAASUserRealm&quot;&gt;
-    &lt;property name=&quot;name&quot; value=&quot;tracker-users&quot;/&gt;
-    &lt;property name=&quot;loginModuleName&quot; value=&quot;ldaploginmodule&quot;/&gt;
+  &lt;property name=&quot;name&quot; value=&quot;tracker-users&quot;/&gt;
+  &lt;property name=&quot;loginModuleName&quot; value=&quot;ldaploginmodule&quot;/&gt;
 &lt;/bean&gt;
 
 &lt;bean id=&quot;constraint&quot; class=&quot;org.mortbay.jetty.security.Constraint&quot;&gt;
-    &lt;property name=&quot;name&quot; value=&quot;BASIC&quot;/&gt;
-    &lt;property name=&quot;roles&quot; value=&quot;tracker-users&quot;/&gt;
-    &lt;property name=&quot;authenticate&quot; value=&quot;true&quot;/&gt;
+  &lt;property name=&quot;name&quot; value=&quot;BASIC&quot;/&gt;
+  &lt;property name=&quot;roles&quot; value=&quot;tracker-users&quot;/&gt;
+  &lt;property name=&quot;authenticate&quot; value=&quot;true&quot;/&gt;
 &lt;/bean&gt;
 
 &lt;bean id=&quot;constraintMapping&quot; class=&quot;org.mortbay.jetty.security.ConstraintMapping&quot;&gt;
-    &lt;property name=&quot;constraint&quot; ref=&quot;constraint&quot;/&gt;
-    &lt;property name=&quot;pathSpec&quot; value=&quot;/*&quot;/&gt;
+  &lt;property name=&quot;constraint&quot; ref=&quot;constraint&quot;/&gt;
+  &lt;property name=&quot;pathSpec&quot; value=&quot;/*&quot;/&gt;
 &lt;/bean&gt;
 
 &lt;bean id=&quot;securityHandler&quot; class=&quot;org.mortbay.jetty.security.SecurityHandler&quot;&gt;
-    &lt;property name=&quot;userRealm&quot; ref=&quot;userRealm&quot;/&gt;
-    &lt;property name=&quot;constraintMappings&quot; ref=&quot;constraintMapping&quot;/&gt;
+  &lt;property name=&quot;userRealm&quot; ref=&quot;userRealm&quot;/&gt;
+  &lt;property name=&quot;constraintMappings&quot; ref=&quot;constraintMapping&quot;/&gt;
 &lt;/bean&gt;
 ]]></script>
 </div></div><p>From<strong> Camel 2.3</strong>: you can configure a list of Jetty handlers as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;-- Jetty Security handling --&gt;
 &lt;bean id=&quot;constraint&quot; class=&quot;org.eclipse.jetty.http.security.Constraint&quot;&gt;
-    &lt;property name=&quot;name&quot; value=&quot;BASIC&quot;/&gt;
-    &lt;property name=&quot;roles&quot; value=&quot;tracker-users&quot;/&gt;
-    &lt;property name=&quot;authenticate&quot; value=&quot;true&quot;/&gt;
+  &lt;property name=&quot;name&quot; value=&quot;BASIC&quot;/&gt;
+  &lt;property name=&quot;roles&quot; value=&quot;tracker-users&quot;/&gt;
+  &lt;property name=&quot;authenticate&quot; value=&quot;true&quot;/&gt;
 &lt;/bean&gt;
 
 &lt;bean id=&quot;constraintMapping&quot; class=&quot;org.eclipse.jetty.security.ConstraintMapping&quot;&gt;
-    &lt;property name=&quot;constraint&quot; ref=&quot;constraint&quot;/&gt;
-    &lt;property name=&quot;pathSpec&quot; value=&quot;/*&quot;/&gt;
+  &lt;property name=&quot;constraint&quot; ref=&quot;constraint&quot;/&gt;
+  &lt;property name=&quot;pathSpec&quot; value=&quot;/*&quot;/&gt;
 &lt;/bean&gt;
 
 &lt;bean id=&quot;securityHandler&quot; class=&quot;org.eclipse.jetty.security.ConstraintSecurityHandler&quot;&gt;
-    &lt;property name=&quot;authenticator&quot;&gt;
-        &lt;bean class=&quot;org.eclipse.jetty.security.authentication.BasicAuthenticator&quot;/&gt;
-    &lt;/property&gt;
-    &lt;property name=&quot;constraintMappings&quot;&gt;
-        &lt;list&gt;
-            &lt;ref bean=&quot;constraintMapping&quot;/&gt;
-        &lt;/list&gt;
-    &lt;/property&gt;
+  &lt;property name=&quot;authenticator&quot;&gt;
+    &lt;bean class=&quot;org.eclipse.jetty.security.authentication.BasicAuthenticator&quot;/&gt;
+  &lt;/property&gt;
+  &lt;property name=&quot;constraintMappings&quot;&gt;
+    &lt;list&gt;
+      &lt;ref bean=&quot;constraintMapping&quot;/&gt;
+    &lt;/list&gt;
+  &lt;/property&gt;
 &lt;/bean&gt;
 ]]></script>
 </div></div><p>You can then define the endpoint as:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;jetty:http://0.0.0.0:9080/myservice?handlers=securityHandler&quot;)
 ]]></script>
-</div></div><p>If you need more handlers, set the <strong><code>handlers</code></strong> option equal to a comma-separated list of bean IDs.</p><h3 id="Jetty-HowtoReturnaCustomHTTP500ReplyMessage">How to Return a Custom HTTP 500 Reply Message</h3><p>You may want to return a custom reply message when something goes wrong, instead of the default reply message Camel <a shape="rect" href="jetty.html">Jetty</a> replies with. You could use a custom <strong><code>HttpBinding</code></strong> to be in control of the message mapping, but often it may be easier to use Camel's <a shape="rect" href="exception-clause.html">Exception Clause</a> to construct the custom reply message.</p><p>Example: return the message: <strong><code>Dude something went wrong</code></strong> for the HTTP error code <strong><code>500</code></strong>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>If you need more handlers, set the <strong><code>handlers</code></strong> option equal to a comma-separated list of bean IDs.</p><h3 id="Jetty-HowtoCustomizetheResponseonanHTTP500ServerError">How to Customize the Response on an <code>HTTP 500</code> Server Error</h3><p>You may want to return a custom reply message when something goes wrong, instead of the default reply message Camel <a shape="rect" href="jetty.html">Jetty</a> replies with. You could use a custom <strong><code>HttpBinding</code></strong> to be in control of the message mapping, but often it may be easier to use Camel's <a shape="rect" href="exception-clause.html">Exception Clause</a> to construct the custom reply message.</p><p>Example: return the message: <strong><code>Dude something went wrong</code></strong> for the HTTP error code <strong><code>500</code></strong>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
 from(&quot;jetty://http://localhost:{{port}}/myserver&quot;)
     // use onException to catch all exceptions and return a custom reply message
@@ -367,7 +363,51 @@ from(&quot;jetty://http://localhost:{{po
     // now just force an exception immediately
     .throwException(new IllegalArgumentException(&quot;I cannot do this&quot;));
 ]]></script>
-</div></div><h3 id="Jetty-Multi-PartFormsupport">Multi-Part Form support</h3><p>From <strong>Camel 2.3.0</strong>: <strong><code>camel-jetty</code></strong> support to multi-part form post out of box. The submitted form-data are mapped into the message header.&#160;<strong><code>camel-jetty</code></strong> creates an attachment for each uploaded file. The file name is mapped to the name of the attachment. The content type is set as the content type of the attachment file name. You can find the example here.</p><div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div><h3 id="Jetty-JettyJMXSupport">Jetty JMX Support</h3><p>From <strong>Camel 2.3.0</strong>:&#160;<strong><code>camel-jetty</code></strong> supports the enabling of Jetty's JMX capabilities at the component and endpoint level with the endpoint configuration taking priority.</p><p><strong>Note</strong>: JMX must be enabled within the Camel 
 context in order to enable JMX support in this component as the component provides Jetty with a reference to the&#160;<strong><code>MBeanServer</code></strong> registered with the Camel context.</p><p>As the&#160;<strong><code>camel-jetty</code></strong> component caches and reuses Jetty resources for a given protocol/host/port pairing, this configuration option will only be evaluated during the creation of the first endpoint to use a protocol/host/port pairing.</p><p><strong>Example</strong>: given two routes created from the following XML fragments, JMX support would remain enabled for all endpoints listening on: <strong><code>https://0.0.0.0</code></strong>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="Jetty-Multi-PartFormSupport">Multi-Part Form Support</h3><p>From <strong>Camel 2.3.0</strong>: <strong><code>camel-jetty</code></strong> support to multi-part form post out of box. The submitted form-data are mapped into the message header.&#160;<strong><code>camel-jetty</code></strong> creates an attachment for each uploaded file. The file name is mapped to the name of the attachment. The content type is set as the content type of the attachment file name. You can find the example here.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Note: getName() functions as shown below in versions 2.5 and higher. In earlier versions you receive the temporary file name for the attachment instead</b></div><div class="codeContent panelContent pdl">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+// Set the jetty temp directory which store the file for multi
+// part form
+// camel-jetty will clean up the file after it handled the
+// request.
+// The option works rightly from Camel 2.4.0
+getContext().getProperties().put(&quot;CamelJettyTempDir&quot;, &quot;target&quot;);
+
+from(&quot;jetty://http://localhost:{{port}}/test&quot;).process(new Processor() {
+
+    public void process(Exchange exchange) throws Exception {
+        Message in = exchange.getIn();
+        assertEquals(&quot;Get a wrong attachement size&quot;, 2, in.getAttachments().size());
+        // The file name is attachment id
+        DataHandler data = in.getAttachment(&quot;NOTICE.txt&quot;);
+
+        assertNotNull(&quot;Should get the DataHandle NOTICE.txt&quot;, data);
+        // This assert is wrong, but the correct content-type
+        // (application/octet-stream)
+        // will not be returned until Jetty makes it available -
+        // currently the content-type
+        // returned is just the default for FileDataHandler (for
+        // the implentation being used)
+        // assertEquals(&quot;Get a wrong content type&quot;,
+        // &quot;text/plain&quot;, data.getContentType());
+        assertEquals(&quot;Got the wrong name&quot;, &quot;NOTICE.txt&quot;, data.getName());
+
+        assertTrue(&quot;We should get the data from the DataHandle&quot;, data.getDataSource()
+            .getInputStream().available() &gt; 0);
+
+        // The other form date can be get from the message
+        // header
+
+        // For binary attachment, header should also be populated by DataHandler but not payload
+        Object header = in.getHeader(&quot;NOTICE.txt&quot;);
+        assertEquals(DataHandler.class, header.getClass());
+        assertEquals(data, header);
+
+        exchange.getOut().setBody(in.getHeader(&quot;comment&quot;));
+    }
+
+});
+]]></script>
+</div></div><h3 id="Jetty-JettyJMXSupport">Jetty JMX Support</h3><p>From <strong>Camel 2.3.0</strong>:&#160;<strong><code>camel-jetty</code></strong> supports the enabling of Jetty's JMX capabilities at the component and endpoint level with the endpoint configuration taking priority.</p><p><strong>Note</strong>: JMX must be enabled within the Camel context in order to enable JMX support in this component as the component provides Jetty with a reference to the&#160;<strong><code>MBeanServer</code></strong> registered with the Camel context.</p><p>As the&#160;<strong><code>camel-jetty</code></strong> component caches and reuses Jetty resources for a given protocol/host/port pairing, this configuration option will only be evaluated during the creation of the first endpoint to use a protocol/host/port pairing.</p><p><strong>Example</strong>: given two routes created from the following XML fragments, JMX support would remain enabled for all endpoints listening on: <strong><code>https://0
 .0.0.0</code></strong>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;from uri=&quot;jetty:https://0.0.0.0/myapp/myservice1/?enableJmx=true&quot;/&gt;
 ]]></script>
 </div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">