mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-01 10:59:16 +00:00
Fix docs that cause unchecked assignment and NPE
This commit is contained in:
parent
8b8267e1fe
commit
96d82ecbf2
@ -464,10 +464,11 @@ static class GrantedAuthoritiesExtractor
|
||||
implements Converter<Jwt, Collection<GrantedAuthority>> {
|
||||
|
||||
public Collection<GrantedAuthority> convert(Jwt jwt) {
|
||||
Collection<String> authorities = (Collection<String>)
|
||||
jwt.getClaims().get("mycustomclaim");
|
||||
Collection<?> authorities = (Collection<?>)
|
||||
jwt.getClaims().getOrDefault("mycustomclaim", Collections.emptyList());
|
||||
|
||||
return authorities.stream()
|
||||
.map(Object::toString)
|
||||
.map(SimpleGrantedAuthority::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -496,10 +496,11 @@ static class GrantedAuthoritiesExtractor
|
||||
implements Converter<Jwt, Collection<GrantedAuthority>> {
|
||||
|
||||
public Collection<GrantedAuthority> convert(Jwt jwt) {
|
||||
Collection<String> authorities = (Collection<String>)
|
||||
jwt.getClaims().get("mycustomclaim");
|
||||
Collection<?> authorities = (Collection<?>)
|
||||
jwt.getClaims().getOrDefault("mycustomclaim", Collections.emptyList());
|
||||
|
||||
return authorities.stream()
|
||||
.map(Object::toString)
|
||||
.map(SimpleGrantedAuthority::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user