File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Custom credentials in spring security" Watch "Custom credentials in spring security" New topic
Author

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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom credentials in spring security