Monday, December 10, 2012

Spring Social with JavaConfig (Part 4)


In the previous section, we have discussed the Spring Social-related configuration. In this section we will focus on Spring Security for securing our application.

Table of Contents

Click on a link to jump to that section:
  1. Functional Specs
  2. Generate OAuth keys
    • Facebook
    • Twitter
  3. Spring Social configuration
  4. Spring Security configuration
  5. JavaConfig
  6. View with Thymeleaf
  7. Layers
    • Domain
    • Repository
    • Service
    • Controller
  8. Running the application
    • Clone from GitHub
    • Create the Database
    • Run with Maven and Tomcat 7
    • Run with Maven and Jetty 8
    • Import to Eclipse
    • Validate with W3C

Spring Security

What is Spring Security?

Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications.

Spring Security is one of the most mature and widely used Spring projects. Founded in 2003 and actively maintained by SpringSource since, today it is used to secure numerous demanding environments including government agencies, military applications and central banks. It is released under an Apache 2.0 license so you can confidently use it in your projects.


Here's our Spring Security configuration:

First, we declare a DelegatingFilterProxy bean using JavaConfig. This allows Spring Security to intercept requests to our application and verify if the required authentication and authorization are met. This bean needs to be registered in the web.xml (or ApplicationInitializer) as a filter (see next section).

Second, we declare the usual XML-based configuration. This allows us to define the intercept-url patterns. Why are we not using JavaConfig here? Because the XML-based configuration is simpler, less-verbose, and easier:


For an in-depth explanation of this configuration, please see my tutorial on Spring Security 3.1 - Implement UserDetailsService with Spring Data JPA


In the next section, we will study the remaining JavaConfig-based configuration. Click here to proceed.
StumpleUpon DiggIt! Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google I'm reading: Spring Social with JavaConfig (Part 4) ~ Twitter FaceBook

Subscribe by reader Subscribe by email Share


  1. Hi sir This is very nice blog.
    This helped me alot.

    Sir i want JAAS Integration with SpringMVC frame work. Can you please help me out

  2. Your blog is so helpful, ever since I found it I have spent scountless hours on it and it is so easy to follow. You are the reason I was able to complete a lot of my projects at work with very little downtime.
    Thank you so much for taking the time to explain every minute detail.

  3. generate OAuth keys for Facebook and Twitter (Online Java Training) Generate OAuth keys Java Training in Chennai Consumer key and Consumer secret values: J2EE Training in Chennai

  4. I have read your blog its very attractive and impressive. I like it your blog.

    Spring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training

    spring training in chennai spring hibernate training in chennai


  5. More than wonderful article Dear Sir, Please continue what I have invented It is really very special with my greetings
    العاب تلبيس بنات 2018
    العاب طبخ فلاش
    العاب سيارات

  6. If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (no matter why you broke up) you got to watch this video
    right away...

    (VIDEO) Why your ex will NEVER get back...

  7. Are you looking for free Google+ Circles?
    Did you know that you can get them ON AUTO-PILOT AND ABSOLUTELY FOR FREE by registering on Like 4 Like?


    Get professional trading signals delivered to your cell phone every day.

    Start following our signals today and gain up to 270% a day.

  9. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    core java training in Electronic City

    Hibernate Training in electronic city

    spring training in electronic city

    java j2ee training in electronic city