Skip to content

Commit

Permalink
Fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Nov 9, 2021
1 parent 86ff5e5 commit de9ecd6
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class CustomClaimConverter implements Converter<Map<String, Object>, Map<
public Map<String, Object> convert(Map<String, Object> claims) {
Map<String, Object> convertedClaims = this.delegate.convert(claims);
if (RequestContextHolder.getRequestAttributes() != null) {
if (RequestContextHolder.getRequestAttributes() != null && ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) != null) {
// Retrieve and set the token
String token = bearerTokenResolver.resolve(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
HttpHeaders headers = new HttpHeaders();
Expand All @@ -89,14 +89,13 @@ public class CustomClaimConverter implements Converter<Map<String, Object>, Map<
.collect(Collectors.toList());
convertedClaims.put("groups", groups);
}
}

if (user.has(SecurityUtils.CLAIMS_NAMESPACE + "roles")) {
List<String> roles = StreamSupport
.stream(user.get(SecurityUtils.CLAIMS_NAMESPACE + "roles").spliterator(), false)
.map(JsonNode::asText)
.collect(Collectors.toList());
convertedClaims.put("roles", roles);
if (user.has(SecurityUtils.CLAIMS_NAMESPACE + "roles")) {
List<String> roles = StreamSupport
.stream(user.get(SecurityUtils.CLAIMS_NAMESPACE + "roles").spliterator(), false)
.map(JsonNode::asText)
.collect(Collectors.toList());
convertedClaims.put("roles", roles);
}
}
}
return convertedClaims;
Expand Down

0 comments on commit de9ecd6

Please sign in to comment.