Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.security.authentication;

import org.jspecify.annotations.Nullable;

import org.springframework.security.core.Authentication;

/**
Expand All @@ -37,7 +39,7 @@ public interface AuthenticationTrustResolver {
* @return <code>true</code> the passed authentication token represented an anonymous
* principal, <code>false</code> otherwise
*/
boolean isAnonymous(Authentication authentication);
boolean isAnonymous(@Nullable Authentication authentication);

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

/**
* Indicates whether the passed <code>Authentication</code> token represents a fully
Expand All @@ -66,7 +68,7 @@ public interface AuthenticationTrustResolver {
* {@link #isRememberMe(Authentication)}, <code>false</code> otherwise
* @since 6.1
*/
default boolean isFullyAuthenticated(Authentication authentication) {
default boolean isFullyAuthenticated(@Nullable Authentication authentication) {
return isAuthenticated(authentication) && !isRememberMe(authentication);
}

Expand All @@ -78,7 +80,7 @@ default boolean isFullyAuthenticated(Authentication authentication) {
* {@link Authentication#isAuthenticated()} is true.
* @since 6.1.7
*/
default boolean isAuthenticated(Authentication authentication) {
default boolean isAuthenticated(@Nullable Authentication authentication) {
return authentication != null && authentication.isAuthenticated() && !isAnonymous(authentication);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.security.authentication;

import org.jspecify.annotations.Nullable;

import org.springframework.security.core.Authentication;

/**
Expand Down Expand Up @@ -44,15 +46,15 @@ Class<? extends Authentication> getRememberMeClass() {
}

@Override
public boolean isAnonymous(Authentication authentication) {
public boolean isAnonymous(@Nullable Authentication authentication) {
if ((this.anonymousClass == null) || (authentication == null)) {
return false;
}
return this.anonymousClass.isAssignableFrom(authentication.getClass());
}

@Override
public boolean isRememberMe(Authentication authentication) {
public boolean isRememberMe(@Nullable Authentication authentication) {
if ((this.rememberMeClass == null) || (authentication == null)) {
return false;
}
Expand Down