protected UserDetails loadUserDetails(Assertion assertion) {
String username = assertion.getPrincipal().getName();
if (!StringUtils.hasText(username)) {
throw new UsernameNotFoundException("Unable to retrieve username from CAS assertion");
}
List<GrantedAuthority> authorities = Arrays
.stream(attributes)
.map(a -> assertion.getPrincipal().getAttributes().get(a))
.filter(Objects::nonNull)
.flatMap(v -> (v instanceof Collection) ? ((Collection<?>) v).stream() : Stream.of(v))
.map(v -> toUppercase ? v.toString().toUpperCase() : v.toString())
.map(r -> r.replaceFirst("^ROLE_", ""))
.map(r -> new SimpleGrantedAuthority("ROLE_" + r))
.collect(Collectors.toList());
authorities.addAll(defaultGrantedAuthorities);
return new User(username, NON_EXISTENT_PASSWORD_VALUE, authorities);
}
GrantedAuthoritiesFromAssertionAttributesWithDefaultRolesUserDetailsService.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:cas-security-spring-boot-starter
作者:
评论列表
文章目录