I'm building an app using Hibernate 3 (with JPA Annotations), Spring 2.5 and Spring Security 2.0.5.
I want to know what I need to put in my <authentication-provider>
tag in my spring security config file (applicationContext-security.xml) so that I can get Spring Security to use my existing Service layer class (AuthenticationService) which deals with my custom User and Role domain objects.
I understand that Spring Security requires two tables to be present with the following schema:
create table users(
username varchar_ignorecase(50) not null primary key,
password varchar_ignorecase(50) not null,
enabled boolean not null);
create table authorities (
username varchar_ignorecase(50) not null,
authority varchar_ignorecase(50) not null,
constraint fk_authorities_users foreign key(username) references users(username));
create unique index ix_auth_username on authorities (username,authority);;
but I want to use my own domain objects which are different to the above table definitions.
Could someone please point me in the right direction here? I can't find any useful documentation and I'm not sure whether what I want to do is actually possible.
Thanks!
You can implement a custom UserDetailsService
as a bridge between your domain and Spring Security. Then you supply Spring Security with it as follows (for Spring Security 2.x):
<security:authentication-provider user-service-ref='myUserDetailsService'/>
<bean id="myUserDetailsService" class="... your implementation ...">
...
</bean>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With