Add AuthenticationTrustResolver.isAuthenticated
This commit is contained in:
committed by
Marcus Hert Da Coregio
parent
3093908a6e
commit
750cb30ce4
@@ -147,7 +147,7 @@ public abstract class SecurityExpressionRoot implements SecurityExpressionOperat
|
||||
|
||||
@Override
|
||||
public final boolean isAuthenticated() {
|
||||
return !isAnonymous();
|
||||
return this.trustResolver.isAuthenticated(getAuthentication());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,13 +61,25 @@ public interface AuthenticationTrustResolver {
|
||||
* <p>
|
||||
* @param authentication to test (may be <code>null</code> in which case the method
|
||||
* will always return <code>false</code>)
|
||||
* @return <code>true</code> the passed authentication token represented an anonymous
|
||||
* principal and is authenticated using a remember-me token, <code>false</code>
|
||||
* otherwise
|
||||
* @return <code>true</code> the passed authentication token represented an
|
||||
* authenticated user ({@link #isAuthenticated(Authentication)} and not
|
||||
* {@link #isRememberMe(Authentication)}, <code>false</code> otherwise
|
||||
* @since 6.1
|
||||
*/
|
||||
default boolean isFullyAuthenticated(Authentication authentication) {
|
||||
return !isAnonymous(authentication) && !isRememberMe(authentication);
|
||||
return isAuthenticated(authentication) && !isRememberMe(authentication);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the {@link Authentication} is not null, authenticated, and not anonymous.
|
||||
* @param authentication the {@link Authentication} to check.
|
||||
* @return true if the {@link Authentication} is not null,
|
||||
* {@link #isAnonymous(Authentication)} returns false, &
|
||||
* {@link Authentication#isAuthenticated()} is true.
|
||||
* @since 6.1.7
|
||||
*/
|
||||
default boolean isAuthenticated(Authentication authentication) {
|
||||
return authentication != null && authentication.isAuthenticated() && !isAnonymous(authentication);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -133,8 +133,7 @@ public final class AuthenticatedAuthorizationManager<T> implements Authorization
|
||||
|
||||
@Override
|
||||
boolean isGranted(Authentication authentication) {
|
||||
return authentication != null && !this.trustResolver.isAnonymous(authentication)
|
||||
&& authentication.isAuthenticated();
|
||||
return this.trustResolver.isAuthenticated(authentication);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -143,7 +142,7 @@ public final class AuthenticatedAuthorizationManager<T> implements Authorization
|
||||
|
||||
@Override
|
||||
boolean isGranted(Authentication authentication) {
|
||||
return authentication != null && this.trustResolver.isFullyAuthenticated(authentication);
|
||||
return this.trustResolver.isFullyAuthenticated(authentication);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user