呵呵,刚才又解决个小问题,如何来判断老密码是否是正确的。因为我用的是JPA的高级权限验证模式,所以密码都是经过hash的MD5加密过的,所以要想从数据库里面读出来,然后再转化,这种方法显然行不通。
就介绍个简单的方法:在JpaIdentityStore类中有这样一个方法.
boolean authenticate(String username, String password)
描述:Authenticates the specified user, using the specified password.
这样就用它啦! 不过要注意用@In引入的时候要注意了:
@In
private JpaIdentityStore identityStore;后面一定是identityStore哦,不要乱写。因为在API中是这样定义这个类的。
@Name(value="org.jboss.seam.security.identityStore")
@Install(precedence=0,value=false)
@Scope(value=APPLICATION)
@BypassInterceptors
public class JpaIdentityStoreextends Object implements IdentityStore, Serializable
所以就看@Name后面的identityStore了。这个我都试过了。
就介绍个简单的方法:在JpaIdentityStore类中有这样一个方法.
boolean authenticate(String username, String password)
描述:Authenticates the specified user, using the specified password.
这样就用它啦! 不过要注意用@In引入的时候要注意了:
@In
private JpaIdentityStore identityStore;后面一定是identityStore哦,不要乱写。因为在API中是这样定义这个类的。
@Name(value="org.jboss.seam.security.identityStore")
@Install(precedence=0,value=false)
@Scope(value=APPLICATION)
@BypassInterceptors
public class JpaIdentityStoreextends Object implements IdentityStore, Serializable
所以就看@Name后面的identityStore了。这个我都试过了。
本文介绍了使用JPA高级权限验证模式下如何判断用户输入的老密码是否正确。由于密码经过MD5加密存储,直接比对不可行。文章推荐使用JpaIdentityStore类中的authenticate方法进行验证。
8

被折叠的 条评论
为什么被折叠?



