Hi Chris, You could call JettyHTTPServerEngine.getContextHandler to get the context for your specific URL and then call:
context.getSessionHandler().getSessionManager().setMaxInactiveInterval( timeout); I haven’t tested this so I'm not sure if it would work. Andrew On 25 July 2017 at 00:49, Horste Wens <[email protected]> wrote: > Hi Andrew, > > thanks a lot for your great support! It now works for me as well. I hoped > the JAASInterceptor would use the session to cache the login credentials, > but this is not case. If I store them myself in the session using a custom > interceptor, then the session and the session cookie is created. I don't > even need spring security for this anymore. > > The only thing missing now is a proper session timeout for the cookie. > Currently, it seems to be valid forever. > > Do you have any idea how to set a timeout? The Jetty param seems to be > "org.eclipse.jetty.servlet.MaxAge", but I couldn't figure out how to > configure it in this scenario. context.setInitParameter requires the > servlet context, which I don't have. > > Regards, > > Chris > > > > 2017-07-12 2:22 GMT+02:00 Andrew Dwyer <[email protected]>: > > > 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 > > >
