Demonstrates adding spring-social and spring-social-security capability to a Roo generated project using SocialSignin ProviderService modules for component-scanning configuration and to provide a thin API access abstraction layer. Also showcases spring-social-roo-connection-repository, a Roo-persitence backed ConnectionRepository implementation
Java CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This project demonstrates how to add spring-social capability to a Roo generated project, using a number of SocialSignin projects to help developers to get up and running quickly:

  • spring-social-security is used for local-user authentication based on third party connection status, removing the need for local username/password account management

  • socialsignin-provider modules are used, allowing

    • developers to obtain and interact with spring-social APIs directly for a number of common-use cases, rather than dealing with lower-level spring-social connection API

    • easy configuration and registration of spring-social components through component-scanning

  • spring-social-roo-connection-repository is used to enable Roo-backed JPA persistence to be used to store connections instead of using the Jdbc versions in the spring-social-core library.

To run this application:

This project was created using Roo as follows:

project --topLevelPackage org.socialsignin.roo.showcase --projectName socialsignin-roo-showcase --java 6 --packaging JAR
web mvc setup
security setup
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

  • SocialSignIn repo and dependencies added to pom:
        <url> </url>
 <!-- Start SocialSignin dependencies -->
        <!-- End SocialSignin dependencies -->

  • Showcase code created:

  • View modifications to support this showcase code

    Added showcase instructions and a link to ShowcaseController url to index.jspx

    Created sociallogin.jspx to support a user logging in via a third-party-provider and signUpForm.jspx for username selection on signup, made some minor amendments to existing header to display logged in status, and added messages to to support these views. Created corresponding tiles view definitions.

    AuthenticationDetailViewPreparer component created and wired into default.jspx default.jspx, so as to make authentication information available to all views.

  • Config modifications to support this showcase code

    Properties file created

    SocialConfig configuration class created


    added to persistence.xml

    Modified applicationContext.xml, applicationContext-security.xml and webmvc-config.xml as follows:

    In applicationContext.xml, component scan for SocialSignIn Provider modules, Spring Social Security and Roo-based UsersConnectionRepository

        <context:component-scan base-package="org.socialsignin.provider"/>
        <!--  Component scan for Spring Social Security  -->
        <context:component-scan base-package=""/>
        <!--  Component scan for Roo managed peristence for ConnectionRepository  -->
        <context:component-scan base-package="">
            <context:exclude-filter expression=".*_Roo_.*" type="regex"/>

    In applicationContext-security.xml

    Create an entry point for your security

        <beans:bean id="springSocialSecurityEntryPoint" class="">
    <beans:property name="loginFormUrl" value="/sociallogin"/>

    Replace form-login element with

    <custom-filter position="FORM_LOGIN_FILTER" ref="springSocialSecurityAuthenticationFilter" />

    set autoconfig= false and add entry-point-ref="springSocialSecurityEntryPoint".

    Add reference to spring-social-security access denied handler for provider-specific access denied pages

    <access-denied-handler ref="springSocialSecurityAccessDeniedHandler"/>

    Remove authenticated provider definition from the authentication manager bean

    Protect our resources:

        <intercept-url pattern="/myTweets" access="hasRole('ROLE_USER_TWITTER')" />
        <intercept-url pattern="/promote" access="hasRole('ROLE_USER_TWITTER')" />
        <intercept-url pattern="/announce" access="hasRole('ROLE_USER_TWITTER')" />

    Add optional remember-me support

    In webmvc-config.xml

    Added component scan for package to allow SignUpController to be registered

    Added property placeholder configuration to allow our file to be picked up by web components.

    Added a preparer factory to tiles configurer, allowing application to use view preparer spring beans to provide auth information to all views.

    <property name="preparerFactoryClass" value= "org.springframework.web.servlet.view.tiles2.SpringBeanPreparerFactory"/>

    Added Spring-Social's ProviderSignInController and ConnectController to allow application to perform OAuth-dance.

    <bean class="">
            <property name="interceptors" ref="connectInterceptorList" />
        <bean class="" >
        <property name="signUpUrl" value="/signup" />
        <property name="postSignInUrl" value="/authenticate" />

    Note that here we are wiring in spring-social-security's connectInterceptorList to ensure uniqueness of social connections amonsgt users and to add provider-specific authentication roles to be granted to the user. We send the postSignInUrl to "/authenticate" which is the url registered for our authentication filter.

    Changed "login" to "sociallogin" in view-controller path so our social login view is accessible