[[_fuse_adapter_cxf_builtin]] ==== Secure Apache CXF Endpoint on default Jetty Engine Some services automatically come with deployed servlets on startup. One of such services is CXF servlet running on http://localhost:8181/cxf context. Securing such endpoints is quite tricky. The approach, which {{book.project.name}} is currently using, is providing ServletReregistrationService, which undeploys builtin servlet at startup, so you are able to re-deploy it again on context secured by {{book.project.name}}. This is how configuration file `OSGI-INF/blueprint/blueprint.xml` inside your application may look like. Note it adds JAX-RS `customerservice` endpoint, which is endpoint specific to your application, but more importantly, it secures whole `/cxf` context. [source,xml] ---- user ---- As a side effect, all other CXF services running on default CXF HTTP destination will be secured too. Similarly when the application is undeployed, then whole `/cxf` context will become unsecured too. For this reason, it's recommended to use your own Jetty engine for your apps like described in <> as then you have more control over security for each application individually. * You may need to have directory `WEB-INF` inside your project (even if your project is not web application) and create files `/WEB-INF/jetty-web.xml` and `/WEB-INF/keycloak.json` in similar way like it's in <>. Note you don't need `web.xml` as the security-constrains are declared in blueprint configuration file. * The `Import-Package` in `META-INF/MANIFEST.MF` needs to contain those imports: [source] ---- META-INF.cxf;version="[2.7,3.2)", META-INF.cxf.osgi;version="[2.7,3.2)";resolution:=optional, org.apache.cxf.transport.http;version="[2.7,3.2)", org.apache.cxf.*;version="[2.7,3.2)", com.fasterxml.jackson.jaxrs.json;version="[2.5,3)", org.eclipse.jetty.security;version="[8,10)", org.eclipse.jetty.util.security;version="[8,10)", org.keycloak.*;version="{{book.project.version}}", org.keycloak.adapters.jetty;version="{{book.project.version}}", *;resolution:=optional ----