Skip to content

Commit 11a0b1d

Browse files
committed
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 <[email protected]>
1 parent 3396890 commit 11a0b1d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

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

1717
package org.springframework.security.authentication;
1818

19+
import org.jspecify.annotations.Nullable;
1920
import org.springframework.security.core.Authentication;
2021

2122
/**
@@ -37,7 +38,7 @@ public interface AuthenticationTrustResolver {
3738
* @return <code>true</code> the passed authentication token represented an anonymous
3839
* principal, <code>false</code> otherwise
3940
*/
40-
boolean isAnonymous(Authentication authentication);
41+
boolean isAnonymous(@Nullable Authentication authentication);
4142

4243
/**
4344
* Indicates whether the passed <code>Authentication</code> token represents user that
@@ -51,7 +52,7 @@ public interface AuthenticationTrustResolver {
5152
* @return <code>true</code> the passed authentication token represented a principal
5253
* authenticated using a remember-me token, <code>false</code> otherwise
5354
*/
54-
boolean isRememberMe(Authentication authentication);
55+
boolean isRememberMe(@Nullable Authentication authentication);
5556

5657
/**
5758
* Indicates whether the passed <code>Authentication</code> token represents a fully
@@ -66,7 +67,7 @@ public interface AuthenticationTrustResolver {
6667
* {@link #isRememberMe(Authentication)}, <code>false</code> otherwise
6768
* @since 6.1
6869
*/
69-
default boolean isFullyAuthenticated(Authentication authentication) {
70+
default boolean isFullyAuthenticated(@Nullable Authentication authentication) {
7071
return isAuthenticated(authentication) && !isRememberMe(authentication);
7172
}
7273

@@ -78,7 +79,7 @@ default boolean isFullyAuthenticated(Authentication authentication) {
7879
* {@link Authentication#isAuthenticated()} is true.
7980
* @since 6.1.7
8081
*/
81-
default boolean isAuthenticated(Authentication authentication) {
82+
default boolean isAuthenticated(@Nullable Authentication authentication) {
8283
return authentication != null && authentication.isAuthenticated() && !isAnonymous(authentication);
8384
}
8485

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

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

1717
package org.springframework.security.authentication;
1818

19+
import org.jspecify.annotations.Nullable;
1920
import org.springframework.security.core.Authentication;
2021

2122
/**
@@ -44,15 +45,15 @@ Class<? extends Authentication> getRememberMeClass() {
4445
}
4546

4647
@Override
47-
public boolean isAnonymous(Authentication authentication) {
48+
public boolean isAnonymous(@Nullable Authentication authentication) {
4849
if ((this.anonymousClass == null) || (authentication == null)) {
4950
return false;
5051
}
5152
return this.anonymousClass.isAssignableFrom(authentication.getClass());
5253
}
5354

5455
@Override
55-
public boolean isRememberMe(Authentication authentication) {
56+
public boolean isRememberMe(@Nullable Authentication authentication) {
5657
if ((this.rememberMeClass == null) || (authentication == null)) {
5758
return false;
5859
}

0 commit comments

Comments
 (0)