Java 在Spring webapp中使用Seam webapp中的用户登录信息
我有一个基于Seam框架构建的webapp,目前我正在用一个基于Spring构建的新webapp替换它。我们的用户登录信息存储在数据库中,并使用salted散列加密。这些是Seam应用程序中当前生成的:Java 在Spring webapp中使用Seam webapp中的用户登录信息,java,spring,seam,password-encryption,Java,Spring,Seam,Password Encryption,我有一个基于Seam框架构建的webapp,目前我正在用一个基于Spring构建的新webapp替换它。我们的用户登录信息存储在数据库中,并使用salted散列加密。这些是Seam应用程序中当前生成的: PasswordHash.instance().generateSaltedHash(plainTextPassword, saltPhrase, "SHA") 我遇到的问题是,新的Spring应用程序必须使用相同的登录名,而且我在复制密码哈希时遇到了问题。我目前拥有此SecurityConf
PasswordHash.instance().generateSaltedHash(plainTextPassword, saltPhrase, "SHA")
我遇到的问题是,新的Spring应用程序必须使用相同的登录名,而且我在复制密码哈希时遇到了问题。我目前拥有此SecurityConfig类:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDAO userDAO;
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
for (AdminUser u : userDAO.getAdminUsers()) {
System.out.println("Granting access to login: " + u.getLogin()
+ " password: " + u.getPassword());
auth.inMemoryAuthentication().withUser(u.getLogin())
.password(u.getPassword()).roles("USER");
}
}
}
任何帮助都将不胜感激。如果需要查看任何额外的代码,只需添加注释。配置spring security以从给定表读取用户的方法是通过DaoAuthenticationProvider,请参见此处 支持定义如何进行哈希和盐析,下面是XML的外观:
<bean id="daoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="inMemoryDaoImpl"/>
<property name="saltSource" ref="saltSource"/>
<property name="passwordEncoder" ref="passwordEncoder"/>
</bean>
在Java配置中,在configure方法中,可以实例化DaoAuthenticationProvider,对其进行配置,并使用API auth.authenticationProvider将其传递给AuthenticationManagerBuilder