Skip to content

Commit 47be93e

Browse files
therepanicrwinch
authored andcommitted
Annotate AuthenticationTrustResolver methods with @Nullable
Since AuthenticationTrustResolver can handle null arguments (this is also stated in the implementation of this interface), we should mark these arguments as `@Nullable`. Closes: gh-17764 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
1 parent 9310153 commit 47be93e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolver.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.authentication;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.security.core.Authentication;
2022

2123
/**
@@ -37,7 +39,7 @@ public interface AuthenticationTrustResolver {
3739
* @return <code>true</code> the passed authentication token represented an anonymous
3840
* principal, <code>false</code> otherwise
3941
*/
40-
boolean isAnonymous(Authentication authentication);
42+
boolean isAnonymous(@Nullable Authentication authentication);
4143

4244
/**
4345
* Indicates whether the passed <code>Authentication</code> token represents user that
@@ -51,7 +53,7 @@ public interface AuthenticationTrustResolver {
5153
* @return <code>true</code> the passed authentication token represented a principal
5254
* authenticated using a remember-me token, <code>false</code> otherwise
5355
*/
54-
boolean isRememberMe(Authentication authentication);
56+
boolean isRememberMe(@Nullable Authentication authentication);
5557

5658
/**
5759
* Indicates whether the passed <code>Authentication</code> token represents a fully
@@ -66,7 +68,7 @@ public interface AuthenticationTrustResolver {
6668
* {@link #isRememberMe(Authentication)}, <code>false</code> otherwise
6769
* @since 6.1
6870
*/
69-
default boolean isFullyAuthenticated(Authentication authentication) {
71+
default boolean isFullyAuthenticated(@Nullable Authentication authentication) {
7072
return isAuthenticated(authentication) && !isRememberMe(authentication);
7173
}
7274

@@ -78,7 +80,7 @@ default boolean isFullyAuthenticated(Authentication authentication) {
7880
* {@link Authentication#isAuthenticated()} is true.
7981
* @since 6.1.7
8082
*/
81-
default boolean isAuthenticated(Authentication authentication) {
83+
default boolean isAuthenticated(@Nullable Authentication authentication) {
8284
return authentication != null && authentication.isAuthenticated() && !isAnonymous(authentication);
8385
}
8486

core/src/main/java/org/springframework/security/authentication/AuthenticationTrustResolverImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.authentication;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.security.core.Authentication;
2022

2123
/**
@@ -44,15 +46,15 @@ Class<? extends Authentication> getRememberMeClass() {
4446
}
4547

4648
@Override
47-
public boolean isAnonymous(Authentication authentication) {
49+
public boolean isAnonymous(@Nullable Authentication authentication) {
4850
if ((this.anonymousClass == null) || (authentication == null)) {
4951
return false;
5052
}
5153
return this.anonymousClass.isAssignableFrom(authentication.getClass());
5254
}
5355

5456
@Override
55-
public boolean isRememberMe(Authentication authentication) {
57+
public boolean isRememberMe(@Nullable Authentication authentication) {
5658
if ((this.rememberMeClass == null) || (authentication == null)) {
5759
return false;
5860
}

0 commit comments

Comments
 (0)