---
title: "用seam如何来获取原始密码的问题"
author: "duyunfengsolo"
date: "2009-06-24T15:50:12Z"
tags: ["JBoss", "JPA", "Seam", "Security"]
slug: "seam"
draft: false
lastmod: "2009-06-24T15:50:12Z"
id: 414227
url: "https://solodu.iteye.com/blog/414227"
---

  呵呵，刚才又解决个小问题，如何来判断老密码是否是正确的。因为我用的是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了。这个我都试过了。