Skip to content

Commit 3f11622

Browse files
committed
Polish Status Codes
Adjusted code styling to avoid nested ifs Closes gh-11725
1 parent 6e45e65 commit 3f11622

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/OpenSaml4AuthenticationProvider.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,26 +414,25 @@ public static Converter<ResponseToken, Saml2ResponseValidatorResult> createDefau
414414

415415
private static List<String> getStatusCodes(Response response) {
416416
if (response.getStatus() == null) {
417-
return Arrays.asList(StatusCode.SUCCESS);
417+
return List.of(StatusCode.SUCCESS);
418418
}
419419
if (response.getStatus().getStatusCode() == null) {
420-
return Arrays.asList(StatusCode.SUCCESS);
420+
return List.of(StatusCode.SUCCESS);
421421
}
422-
423422
StatusCode parentStatusCode = response.getStatus().getStatusCode();
424423
String parentStatusCodeValue = parentStatusCode.getValue();
425-
if (includeChildStatusCodes.contains(parentStatusCodeValue)) {
426-
StatusCode statusCode = parentStatusCode.getStatusCode();
427-
if (statusCode != null) {
428-
String childStatusCodeValue = statusCode.getValue();
429-
if (childStatusCodeValue != null) {
430-
return Arrays.asList(parentStatusCodeValue, childStatusCodeValue);
431-
}
432-
}
433-
return Arrays.asList(parentStatusCodeValue);
424+
if (!includeChildStatusCodes.contains(parentStatusCodeValue)) {
425+
return List.of(parentStatusCodeValue);
434426
}
435-
436-
return Arrays.asList(parentStatusCodeValue);
427+
StatusCode childStatusCode = parentStatusCode.getStatusCode();
428+
if (childStatusCode == null) {
429+
return List.of(parentStatusCodeValue);
430+
}
431+
String childStatusCodeValue = childStatusCode.getValue();
432+
if (childStatusCodeValue == null) {
433+
return List.of(parentStatusCodeValue);
434+
}
435+
return List.of(parentStatusCodeValue, childStatusCodeValue);
437436
}
438437

439438
private static boolean isSuccess(List<String> statusCodes) {

0 commit comments

Comments
 (0)