Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

Spring Security 3.0 – Part 3

Posted by Pankil Patel on April 14, 2010

How to pass extra parameter(s) from login page in Spring Security 3.0?
OR
How to create “Custom EntryPoint” or “Custom authenticationProcessingFilter” or ” Custom UsernamePasswordAuthenticationFilter” in Spring Security 3.0?

Step 1:
Add you extra parameter into your jsp / html page along with “j_username” and “j_password”. like:

Step 2:
Create new java file Say named “MyAuthenticationProcessingFilter.java” which will extends “org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter”.

Override method setDetails in MyAuthenticationProcessingFilter Class in that method you have request and from that request you can easily get your extra parameter passed from your jsp / html via Spring Security.

@Override
protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) {
super.setDetails(request, authRequest);
String selectedLanguage = request.getParameter(“request_locale”);
}

Step 3:
To achieve this Custom UsernamePasswordAuthentication you must change you “applicationContext-security.xml” file like:

Please Note: Here in “applicationContext-security.xml” file effective changes than Spring Security 3.0 – Part 1 are:
1) http start tage ‘ auto-config=”false” entry-point-ref=”authenticationProcessingFilterEntryPoint” ‘
2) “form-login” removed from http section
3) “custom-filter” added into http section
4) Added Two more Spring Bean definition “languageProcessingFilter” and “authenticationProcessingFilterEntryPoint”

All Set for these Customization……..
Hureeeeeeeeeeee Ready to use Customized spring Security 3.0.

BEST OF LUCK

Advertisements

3 Responses to “Spring Security 3.0 – Part 3”

  1. […] Category Cloud Core Java EMAIL Hibernate Javascript JSF Other Performance SMS Spring Struts 2 « Spring Security 3.0 – Part 3 […]

  2. […] Here languageProcessingFilter is the same as explained in post Spring Security 3 .0 – Part 3. […]

  3. tesnep said

    Excellent work! This just works.

    You don’t by chance have anything on using remember-me with a cookie?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: