【问题标题】:Integration of Spring Security 3 authentication with Hibernate 3(JPA) annotationSpring Security 3 身份验证与 Hibernate 3(JPA) 注释的集成
【发布时间】:2012-01-24 09:09:54
【问题描述】:

我正在寻找一些基于注释(即 JPA)和来自数据库的用户凭据的 最新 Spring 框架安全性与 Hibernate 集成的示例。我怎样才能做到这一点?我可以使用 Spring 进行密码编码和解码吗?

可用的解决方案之一是链接here,但这是基于带有 XML 配置的 Spring 2.5。我想避免使用 xml 并使用注释。

【问题讨论】:

    标签: hibernate spring-security


    【解决方案1】:

    使用Spring source documentation。您需要的一切都在文档中提供。是的!您可以使用 spring 进行密码编码和解码。只需编写将扩展 org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder 的编码类。

    public class MyPassEncoder extends org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder
    {
       MyPassEncoder(){
       super("MD5");
    }
    public String encodePassword(String rawPass, Object salt) {
       String encPass =  super.encodePassword(rawPass, salt);
       return encPass;
    }
    }
    

    【讨论】:

    猜你喜欢
    • 2012-10-26
    • 2011-02-10
    • 2014-02-26
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 2012-11-18
    相关资源
    最近更新 更多