Reputation: 459
My application is based on Spring 3, Hibernate 3, MySQL. I read the Spring Security document and learnt that I can implement Authentication as given below,
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select username,password, enabled
from users where username=?"
authorities-by-username-query="
select u.username, ur.authority from users u, user_roles ur
where u.user_id = ur.user_id and u.username =? "
/>
</authentication-provider>
</authentication-manager>
I understood above part but my concern is, in my application user table doesn't only store the userName, password and enabled field. It also stores first and last name, emailID, phone etc. On successful authentication, I want next jsp to populate all user details automatically and not ask user the same information which it will ask to non-regirstered user.
Can someone kindly advice with good examples? any references to other posts will help too.
Upvotes: 2
Views: 1253
Reputation: 12084
As for now Spring Security is mostly configured without annotations, but you can use special XML namespace for simple customization of Spring Security.
You need to implement your own UserDetailsService
which will be responsible for loading details of the user from persistent store.
UserDetailsService
interface has just one method
UserDetails loadUserByUsername(String username) throws UsernameNotFoundException;
After implementing and creating bean of your component you need to inject it:
<authentication-manager>
<authentication-provider user-service-ref="myUserDetailsService"/>
</authentication-manager>
More in Spring Security Docs:
If you don't have information like enabled
in your database, you will always have to put true
value in your UserDetails
object for that field.
Upvotes: 1