如何使用Hibernate 3 Annotated Classes配置Spring Security 2数据库身份验证?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何使用Hibernate 3 Annotated Classes配置Spring Security 2数据库身份验证?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1208字,纯文字阅读大概需要2分钟。
内容图文
![如何使用Hibernate 3 Annotated Classes配置Spring Security 2数据库身份验证?](/upload/InfoBanner/zyjiaocheng/900/9b0c6c545c4341319878b8c3d21ae7f4.jpg)
我正在使用Hibernate 3(带JPA Annotations),Spring 2.5和Spring Security 2.0.5构建应用程序.
我想知道我需要在我的< authentication-provider>中添加什么在我的spring安全配置文件(applicationContext-security.xml)中标记,以便我可以让Spring Security使用我现有的服务层类(AuthenticationService)来处理我的自定义用户和角色域对象.
据我所知,Spring Security要求两个表存在以下模式:
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);;
但我想使用自己的域对象,这些对象与上面的表定义不同.
有人可以指点我这里正确的方向吗?我找不到任何有用的文档,我不确定我想做的事情是否真的可行.
谢谢!
解决方法:
您可以将自定义UserDetailsService实现为域和Spring Security之间的桥梁.然后您按如下方式为Spring Security提供它(对于Spring Security 2.x):
<security:authentication-provider user-service-ref='myUserDetailsService'/>
<bean id="myUserDetailsService" class="... your implementation ...">
...
</bean>
内容总结
以上是互联网集市为您收集整理的如何使用Hibernate 3 Annotated Classes配置Spring Security 2数据库身份验证?全部内容,希望文章能够帮你解决如何使用Hibernate 3 Annotated Classes配置Spring Security 2数据库身份验证?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。