I use this Enum for available user roles types:
public enum Role implements GrantedAuthority {
ROLE_ADMIN, ROLE_CLIENT;
public String getAuthority() {
return name();
}
}
Full code: Github
But when I try to convert the list using this code:
claims.put("auth", roles.stream()
.map(s -> new SimpleGrantedAuthority(s.getAuthority()))
.filter(Objects::nonNull)
.collect(Collectors.toList())
);
I always get NPE when I try to get s.getAuthority()
. Do you know how I can fix this issue?