@Override
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
logger.debug(
"==== Authenticating using FooAuthenticationProvider: " +
authentication);
// here goes username/password authentication for Foo
Response response = userService
.authenticateFoo(String.valueOf(authentication.getPrincipal()),
String.valueOf(authentication.getCredentials()));
if (response.isOk()) {
List<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("FOO_READ"));
authorities.add(new SimpleGrantedAuthority("FOO_WRITE"));
return new FooUsernamePasswordAuthenticationToken(
authentication.getPrincipal(), authentication.getCredentials(),
authorities);
} else {
throw new BadCredentialsException("Authentication failed.");
}
}
FooAuthenticationProvider.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:spring-auth-example
作者:
评论列表
文章目录