Hi,

Ok, thanks to the hints itt I have solved my two most pressing issues, with 
some links/insights below. 

JAAS:

This helped me immensely to bridge JAAS and JAX-RS: 
https://github.com/andyphillips404/awplab-core/blob/master/rest/service/src/main/java/com/awplab/core/rest/service/security/BasicAuthKarafSecurityRequestFilter.java
 
The Cxf JAASLoginInterceptor and the Filter that uses it have issues (for me) I 
didn’t want to solve for my new Jax-Rs only setup, as illustrated by this 
thread: 
http://karaf.922171.n3.nabble.com/Security-Subject-from-AccessControlContext-is-null-when-using-JAAS-and-CXF-JAASAuthenticationFilter-td4037821.html

Cors:

This here helped me understand how to do Cors correctly including Preflight: 
https://github.com/resteasy/Resteasy/blob/master/resteasy-core/src/main/java/org/jboss/resteasy/plugins/interceptors/CorsFilter.java

I just added (JAX-RS)Features and ConfigAdmin, some DS and Jax-rs Whiteboard 
annotations (the spec really helps), and am now in happy component land. 

So it really looks like that the new Jax-rs stuff in R7 helps me with cleaner 
code, dependency streamlining and modularity.

Thanks, especially to Tim for the original pointer to the Aries implementation 
and a happy new year.

Best regards,

Oliver


> Le 2 janv. 2019 à 13:13, Tim Ward <[email protected]> a écrit :
> 
>>> 1. Some of the providers I configure programmatically implement JAX-RS
>>> interfaces and are provided by CXF or other frameworks,
>>> e.g. CrossOriginResourceSharingFilter, MultipartProvider, 
>>> JacksonJsonProvider, WebApplicationExceptionMapper.
>>> How do I make these known to my JAX-RS Whiteboard  (Whiteboard service)
>>> ?Just derive a new class, annotate as a Component and JaxrsExtension?
> 
> You have several options here, some of which have already been described, but 
> there are some which have been overlooked.
> 
> Some extensions (such as support for Jackson’s JSON) are already available 
> for the whiteboard. For example this integration project comes from Aries.
> You can make use of the JAX-RS whiteboard’s dependency system to build your 
> own JAX-RS feature which you then rely on.
> 
> For example:
> 
> @Component
> @JaxrsName(“myFeature")
> @JaxrsExtension
> public class MyFeature implements Feature {
> 
>     @Override
>     public boolean configure(FeatureContext fc) {
>         fc.register(CrossOriginResourceSharingFilter.class);
>     }
> 
> } 
> 
> You can then add requirements for this feature to your resources (ideally 
> using config admin) using the osgi.jaxrs.extension.select property described 
> in 
> https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html#service.jaxrs.common.properties
> 
> 
>>> 2. Swagger2Feature, JAASLoginInterceptor, FastInfosetFeature, GZIPFeature, 
>>> CORSPreflightInterceptor (my
>>> code, extends AbstractPhaseInterceptor<Message>) are provided by CXF and
>>> implement CXF interfaces. I gather I can't use these directly with the
>>> Whiteboard? What do I do with those?  Reimplement/port to JAX-RS?
> 
> There are ways to make these existing features work, but it is a much better 
> idea to port to the standard JAX-RS APIs, otherwise you’ll end up coupled to 
> CXF unnecessarily.
> 
> Best Regards,
> 
> Tim
> 
> 
>> On 28 Dec 2018, at 17:51, Jean-Baptiste Onofré <[email protected]> wrote:
>> 
>> Hi,
>> 
>> you can take a look on the Karaf JAXRS Whiteboard sample:
>> 
>> https://github.com/apache/karaf/pull/697
>> 
>> I gonna merge it tonight or tomorrow morning.
>> 
>> Regards
>> JB
>> 
>>> On 28/12/2018 16:23, Oliver Schweitzer wrote:
>>> Hi,
>>> 
>>> I have an existing REST JAX-RS Application based on CXF mechanics. that
>>> is the Resources are lifecycle managed by a programmatically setup
>>> JAXRSServerFactoryBean, which itself gets started and stopped by an
>>> immediate @Component
>>> 
>>> Now I want to build new entrypoints (and eventually migrate old ones)
>>> using the JAX-RS whiteboard, as discussed e.g.
>>> here 
>>> http://karaf.922171.n3.nabble.com/Aries-JAX-RS-Whiteboard-td4054440.html,
>>> and go full dynamically discovered declarative services with my REST API
>>> and application. 
>>> 
>>> The basic setup (without extensions) works very well,  now I want to
>>> replace all my programmatic CXF configuration with @Components annotated
>>> with @JaxrsExtension, use only JAX-RS/Whiteboard mechanics and no more
>>> CXF specialties if possible.
>>> 
>>> Now for the questions: 
>>> 
>>> 1. Some of the providers I configure programmatically implement JAX-RS
>>> interfaces and are provided by CXF or other frameworks,
>>> e.g. CrossOriginResourceSharingFilter, MultipartProvider, 
>>> JacksonJsonProvider, WebApplicationExceptionMapper.
>>> How do I make these known to my JAX-RS Whiteboard  (Whiteboard service)
>>> ?Just derive a new class, annotate as a Component and JaxrsExtension?
>>> 
>>> 2. Swagger2Feature, JAASLoginInterceptor, FastInfosetFeature, GZIPFeature, 
>>> CORSPreflightInterceptor (my
>>> code, extends AbstractPhaseInterceptor<Message>) are provided by CXF and
>>> implement CXF interfaces. I gather I can't use these directly with the
>>> Whiteboard? What do I do with those?  Reimplement/port to JAX-RS?
>>> 
>>> Best regards,
>>> 
>>> Oliver
>>> 
>>> 
>>> 
>>> 
>> 
>> -- 
>> Jean-Baptiste Onofré
>> [email protected]
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
> 

Reply via email to