Skip to content

Commit 2be08f9

Browse files
committed
fix: check if claims is null to avoid null pointer exception
1 parent 0c4fb7a commit 2be08f9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/fr/insee/genesis/configuration/auth/security/OIDCSecurityConfig.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ public Collection<GrantedAuthority> convert(Jwt source) {
8585
String[] claimPath = inseeSecurityTokenProperties.getOidcClaimRole().split("\\.");
8686
Map<String, Object> claims = source.getClaims();
8787
try {
88-
if (!claims.isEmpty()) {
89-
for (int i = 0; i < claimPath.length - 1; i++) {
90-
claims = (Map<String, Object>) claims.get(claimPath[i]);
91-
}
92-
88+
for (int i = 0; i < claimPath.length - 1; i++) {
89+
claims = (Map<String, Object>) claims.get(claimPath[i]);
90+
}
91+
if (claims != null) {
9392
List<String> tokenClaims = (List<String>) claims.getOrDefault(claimPath[claimPath.length - 1], List.of());
9493
// Collect distinct values from mapping associated with input keys
9594
List<String> claimedRoles = tokenClaims.stream()

0 commit comments

Comments
 (0)