我们已经从 3.0.7 spring security 迁移到 3.1.2,我们使用 in-memory-config 的一项测试因凭据错误而失败。
我们没有做任何特别的事情,只需使用纯文本用户名和密码验证其中一个用户。一旦通过身份验证,我们就会填充我们的权限。
代码:
public Authentication authenticate(UserDetails userDetails)
throws AuthenticationException {
try {
org.springframework.security.core.Authentication authenticate = authenticationManager.authenticate(createAuthenticationRequest(userDetails));
if (!authenticate.isAuthenticated()) {
throw new AuthenticationException("Authentication failed for user ["+userDetails.getUsername()+"]");
}
Collection<? extends GrantedAuthority> grantedAuthorities = authenticate.getAuthorities();
...
} catch(Exception exception) {
throw new AuthenticationException(exception);
}
代码:
<bean id="daoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="daoUserDetailsService" />
</bean>
<bean id="daoUserDetailsService" class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl">
<property name="userMap">
<value>
Edward = koala, READ_ONLY
</value>
</property>
</bean>
我们在调用身份验证时收到以下异常:
Caused by: org.springframework.security.authentication.BadCre dentialsException: Bad credentials
at org.springframework.security.authentication.dao.Da oAuthenticationProvider.additionalAuthenticationCh ecks(DaoAuthenticationProvider.java:67)
at org.springframework.security.authentication.dao.Ab stractUserDetailsAuthenticationProvider.authentica te(AbstractUserDetailsAuthenticationProvider.java: 149)
at org.springframework.security.authentication.Provid erManager.authenticate(ProviderManager.java:156)
at org.openspaces.security.spring.SpringSecurityManag er.authenticate(SpringSecurityManager.java:117)
... 11 more
有什么想法可以解决它,或者是否有补丁解决这个问题?