Ste*_*fan 5 java web-services spring-security
目前我正在使用Spring Security编写Web应用程序.我们有一个Web服务,通过用户名和密码验证用户.
网络服务:
String[] login(String username, String password);
如何配置Spring Security以将提供的用户名和密码传递给Web服务?
我写了一个UserDetailsService只收到用户名的.
我认为问题在于你的xml.你关掉了自动配置吗?你的类是否扩展了AbstractUserDetailsAuthenticationProvider?
扩展org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider
/**
* @author rodrigoap
*
*/
public class WebServiceUserDetailsAuthenticationProvider extends
AbstractUserDetailsAuthenticationProvider {
@Override
protected UserDetails retrieveUser(String username,
UsernamePasswordAuthenticationToken authentication)
throws AuthenticationException {
//Improve this line:
String password = authentication.getCredentials().toString();
// Invoke your webservice here
GrantedAuthority[] grantedAuth = loginWebService.login(username, password);
// create UserDetails. Warning: User is deprecated!
UserDetails userDetails = new User(username, password, grantedAuth);
return userDetails;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8940 次 |
| 最近记录: |