Spring MVC: How to use a request-scoped bean inside a spawned thread?

OK, by reading the code in SimpleThreadScope that comes with Spring I think you can create a SimpleInheritableThreadScope by using an InheritableThreadLocal instead. Then just use a bit of xml to register your custom scope: <bean class=”org.springframework.beans.factory.config.CustomScopeConfigurer”> <property name=”scopes”> <map> <entry key=”thread-inherited”> <bean class=”org.mael.spring.context.support.SimpleInheritableThreadScope”/> </entry> </map> </property> </bean> This means that when you create a … Read more

Integrate Spring Security OAuth2 and Spring Social

I had a similar problem on a JHipster-generated web application. Finally I decided to go with the SocialAuthenticationFilter option from Spring Social (via the SpringSocialConfigurer). After a successful social login, the server automatically generates and returns the “own” access token via redirection to the client app. Here’s my try: @Configuration @EnableResourceServer protected static class ResourceServerConfiguration … Read more

How to do rest authentication with Spring Social?

So you want to use Oauth2 in your application, and you want to use the password flow. You can use the spring security oauth2-resource-server project to implement a resource server. In your resource server you can use the ResourceOwnerPasswordResourceDetails to provide the client_id, client_secret, username and password, The Oauth2RestTemplate can be used to call the … Read more