Our application is using sparkjava http://sparkjava.com/ as the REST framework. The jetty server is embedded in the application (sparkjava default). We are also using spring for dependency injection.
For providing AD authentication, we need to integrate the waffle's NegotiateSecurityFilter.
As per waffle documentation and several online resources including stackoverflow, a DelegatingFilterProxy is required with the name springSecurityFilterChain.
But since we are not using spring MVC, I have to add it as follows:
ServletContextHandler sparkContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
sparkContext.addFilter(new FilterHolder( new DelegatingFilterProxy( "springSecurityFilterChain" ) ),"/*", EnumSet.allOf( DispatcherType.class ));
And since a ContextLoaderListener does not already exist, need to add in the following manner:
sparkContext.addEventListener( new ContextLoaderListener() );
But it gives the error "Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader" at time of server startup.
Please let me know a solution in this scenario if you have successfully integrated spring-security DelegatingFilterProxy with embedded jetty and sparkjava (without using spring MVC).
This is how I achieved it finally:
In the main method where I have access to the sparkContext:
And the implementing methods are as:
Add the following properties to the holder: