aspose file tools
The moose likes Spring and the fly likes Custom credentials in spring security Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Custom credentials in spring security" Watch "Custom credentials in spring security" New topic

Custom credentials in spring security

shanthi naidu
Ranch Hand

Joined: Nov 13, 2008
Posts: 39
Hi all,

Im new to spring security; the applcation im working on uses the default authentication manager which takes
user name and password as credentials.

Now my requirement is that i have to login using user id instead of username;
For this do i need to add my custom authentication manager provider?

In that case what classes i have to create by extending the existing classes (like AuthenticationManager, Authentication)

Please suggest me

Thanks & Regards,
Shanthi Naidu

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17260

Username, user id, login name, they all mean the same thing to me.

Why do you see it meaning something different?

Which UserDetailsService are you using, JDBC, LDAP, etc?
For JDBC just change the userByUserName property or authoritiesByUserName property to go to the name of the fields in the database that you have that don't match the default built in queries.

Remember the userByUserName property query has to return three fields; username(userID), password, and boolean for enabled.
The authoritiesByUserName query has to return two fields; username(UserID), role
For the role field, make sure it is prefixed with "ROLE_"

Good Luck


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Have you tried LearnNowOnline?
subject: Custom credentials in spring security