diff --git a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java index 7efdf8e939..0bb9c4d28b 100644 --- a/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java +++ b/cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java @@ -115,15 +115,8 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken implemen if (!super.equals(obj)) { return false; } - if (obj instanceof CasAuthenticationToken) { - CasAuthenticationToken test = (CasAuthenticationToken) obj; - if (!this.assertion.equals(test.getAssertion())) { - return false; - } - if (this.getKeyHash() != test.getKeyHash()) { - return false; - } - return true; + if (obj instanceof CasAuthenticationToken test) { + return this.assertion.equals(test.getAssertion()) && this.getKeyHash() == test.getKeyHash(); } return false; } diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToListStringConverter.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToListStringConverter.java index c1a70f9651..f6e9b3c291 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToListStringConverter.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToListStringConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,12 +43,9 @@ final class ObjectToListStringConverter implements ConditionalGenericConverter { @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { - if (targetType.getElementTypeDescriptor() == null - || targetType.getElementTypeDescriptor().getType().equals(String.class) || sourceType == null - || ClassUtils.isAssignable(sourceType.getType(), targetType.getElementTypeDescriptor().getType())) { - return true; - } - return false; + TypeDescriptor typeDescriptor = targetType.getElementTypeDescriptor(); + return typeDescriptor == null || typeDescriptor.getType().equals(String.class) || sourceType == null + || ClassUtils.isAssignable(sourceType.getType(), typeDescriptor.getType()); } @Override diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToMapStringObjectConverter.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToMapStringObjectConverter.java index 2a6e241812..863c36f4db 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToMapStringObjectConverter.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/converter/ObjectToMapStringObjectConverter.java @@ -37,11 +37,8 @@ final class ObjectToMapStringObjectConverter implements ConditionalGenericConver @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { - if (targetType.getElementTypeDescriptor() == null - || targetType.getMapKeyTypeDescriptor().getType().equals(String.class)) { - return true; - } - return false; + return targetType.getElementTypeDescriptor() == null + || targetType.getMapKeyTypeDescriptor().getType().equals(String.class); } @Override diff --git a/web/src/main/java/org/springframework/security/web/access/intercept/AuthorizationFilter.java b/web/src/main/java/org/springframework/security/web/access/intercept/AuthorizationFilter.java index 80659363f2..d6fb9286c4 100644 --- a/web/src/main/java/org/springframework/security/web/access/intercept/AuthorizationFilter.java +++ b/web/src/main/java/org/springframework/security/web/access/intercept/AuthorizationFilter.java @@ -109,10 +109,8 @@ public class AuthorizationFilter extends GenericFilterBean { if (DispatcherType.ERROR.equals(request.getDispatcherType()) && !this.filterErrorDispatch) { return true; } - if (DispatcherType.ASYNC.equals(request.getDispatcherType()) && !this.filterAsyncDispatch) { - return true; - } - return false; + + return DispatcherType.ASYNC.equals(request.getDispatcherType()) && !this.filterAsyncDispatch; } private boolean isApplied(HttpServletRequest request) { diff --git a/web/src/main/java/org/springframework/security/web/firewall/DefaultHttpFirewall.java b/web/src/main/java/org/springframework/security/web/firewall/DefaultHttpFirewall.java index 1bed1d74c2..224d9fa18c 100644 --- a/web/src/main/java/org/springframework/security/web/firewall/DefaultHttpFirewall.java +++ b/web/src/main/java/org/springframework/security/web/firewall/DefaultHttpFirewall.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,10 +87,7 @@ public class DefaultHttpFirewall implements HttpFirewall { if (this.allowUrlEncodedSlash || uri == null) { return false; } - if (uri.contains("%2f") || uri.contains("%2F")) { - return true; - } - return false; + return uri.contains("%2f") || uri.contains("%2F"); } /** diff --git a/web/src/main/java/org/springframework/security/web/firewall/StrictHttpFirewall.java b/web/src/main/java/org/springframework/security/web/firewall/StrictHttpFirewall.java index 601de7b0f8..6bc13540ad 100644 --- a/web/src/main/java/org/springframework/security/web/firewall/StrictHttpFirewall.java +++ b/web/src/main/java/org/springframework/security/web/firewall/StrictHttpFirewall.java @@ -611,10 +611,7 @@ public class StrictHttpFirewall implements HttpFirewall { if (valueContains(request.getServletPath(), value)) { return true; } - if (valueContains(request.getPathInfo(), value)) { - return true; - } - return false; + return valueContains(request.getPathInfo(), value); } private static boolean containsOnlyPrintableAsciiCharacters(String uri) { diff --git a/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java b/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java index 47d7b8cad1..e221477e72 100644 --- a/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java +++ b/web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -354,10 +354,7 @@ public class DefaultSavedRequest implements SavedRequest { if (arg1 == null || arg2 == null) { return false; } - if (arg1.equals(arg2)) { - return true; - } - return false; + return arg1.equals(arg2); } @Override