Hi Andrew,

thanks for the very quick reply. I've just tried out the proposal.
Unfortunately, it has no effect so far. The server still won't issue
session cookies. I have already tried a similar approach:

      org.apache.cxf.endpoint.Server cxfServer = sf.create();

      JettyHTTPDestination jettyDestination = (JettyHTTPDestination)
cxfServer.getDestination();

      JettyHTTPServerEngine serverEngine = (JettyHTTPServerEngine)
jettyDestination.getEngine();

      serverEngine.setSessionSupport(true);


Using Spring Security I could make it work, but not with the ServerFactory.
There was a code snippet in my last mail for this approach. Find below the
corresponding WebSecurity config. Note that it was important to configure
the SessionCreatenPolicy as part of the configure method. I wonder if the
Jetty server can be configured directly this way.

@Configuration

@EnableWebSecurity

@EnableGlobalMethodSecurity( securedEnabled = true )

public class InMemorySecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired

    public void configureGlobal(AuthenticationManagerBuilder auth) throws
Exception {

        auth.inMemoryAuthentication()

            .withUser("me").password("me").roles("USER").and().withUser(
"admin").password("me").roles("USER", "ADMIN");

    }

    @Override

    protected void configure( HttpSecurity http ) throws Exception {

        http.httpBasic().and()


.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.ALWAYS
).and()

            .authorizeRequests().antMatchers("/**").hasRole( "USER" );

    }

}


Regards,


Christof



2017-07-11 8:39 GMT+02:00 Andrew Dwyer <andrewrdw...@gmail.com>:

>  Are you using spring? These pages may assist:
> http://cxf.apache.org/docs/jaxrs-services-configuration.html
> http://cxf.apache.org/docs/standalone-http-transport.html
>
> The code below should set up an embedded jetty engine with session support.
> When you create your jaxrs service on the same port it should start the
> engine:
>
> JettyHTTPServerEngineFactory engineFactory = new
> JettyHTTPServerEngineFactory();
> JettyHTTPServerEngine jettyHTTPServerEngine =
> engineFactory.createJettyHTTPServerEngine("localhost", 9000, "http");
> jettyHTTPServerEngine.setSessionSupport(true);
> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> ...
> sf.setAddress("http://localhost:9000/";);
> Server server = sf.create();
>
> Cheers
> Andrew
>

Reply via email to