Hi
Thanks, the remaining piece of the puzzle is probably about wiring in
SpringSecurity with the embedded Jetty somehow, probably one needs to
register a CXF interceptor which will use SpringSecurity
AuthenticationManager/etc
Sergey
On 12/07/17 01:22, Andrew Dwyer wrote:
I had a quick play around and I can confirm sessions are working for me.
I'm running CXF 3.1.5 in Jboss Fuse. Have you checked that the client
you're using has sessions enabled?
The code that I used is below:
== Spring config ==
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:httpj="
http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns="http://www.springframework.org/schema/beans"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<httpj:engine-factory bus="cxf" id="my-engine">
<httpj:engine port="8686">
<httpj:sessionSupport>true</httpj:sessionSupport>
</httpj:engine>
</httpj:engine-factory>
<bean id="testBean" class="testing.Service" />
<jaxrs:server id="cxfJaxrsServer" address="http://0.0.0.0:8686/test"
depends-on="my-engine">
<jaxrs:providers>
<bean
class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
</jaxrs:providers>
<jaxrs:serviceBeans>
<ref bean="customerBean" />
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
== Sample service ==
@Path("/service")
public class Service
{
@Context
private HttpServletRequest httpRequest;
@Path("/set")
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String test()
{
httpRequest.getSession().setAttribute("test", "test value");
return "bundle2";
}
@Path("/get")
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String test2()
{
return (String)httpRequest.getSession().getAttribute("test");
}
}
== CXF dependencies ==
cxf-rt-frontend-jaxrs, cxf-rt-transports-http-jetty,
cxf-rt-rs-extension-providers
Cheers
Andrew