Replace deprecated #check calls with #authorize
Closes gh-16936 Signed-off-by: Evgeniy Cheban <mister.cheban@gmail.com>
This commit is contained in:
committed by
Josh Cummings
parent
e3add59550
commit
b0cecb37d2
+16
-2
@@ -30,6 +30,7 @@ import org.springframework.security.authorization.AuthenticatedAuthorizationMana
|
||||
import org.springframework.security.authorization.AuthorityAuthorizationManager;
|
||||
import org.springframework.security.authorization.AuthorizationDecision;
|
||||
import org.springframework.security.authorization.AuthorizationManager;
|
||||
import org.springframework.security.authorization.AuthorizationResult;
|
||||
import org.springframework.security.authorization.SingleResultAuthorizationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.util.UrlUtils;
|
||||
@@ -69,11 +70,24 @@ public final class RequestMatcherDelegatingAuthorizationManager implements Autho
|
||||
* @return an {@link AuthorizationDecision}. If there is no {@link RequestMatcher}
|
||||
* matching the request, or the {@link AuthorizationManager} could not decide, then
|
||||
* null is returned
|
||||
* @deprecated please use {@link #authorize(Supplier, Object)} instead
|
||||
* @deprecated please use {@link #authorize(Supplier, HttpServletRequest)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public AuthorizationDecision check(Supplier<Authentication> authentication, HttpServletRequest request) {
|
||||
AuthorizationResult result = authorize(authentication, request);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
if (result instanceof AuthorizationDecision decision) {
|
||||
return decision;
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"Please call #authorize or ensure that the returned result is of type AuthorizationDecision");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorizationResult authorize(Supplier<Authentication> authentication, HttpServletRequest request) {
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace(LogMessage.format("Authorizing %s", requestLine(request)));
|
||||
}
|
||||
@@ -87,7 +101,7 @@ public final class RequestMatcherDelegatingAuthorizationManager implements Autho
|
||||
this.logger.trace(
|
||||
LogMessage.format("Checking authorization on %s using %s", requestLine(request), manager));
|
||||
}
|
||||
return manager.check(authentication,
|
||||
return manager.authorize(authentication,
|
||||
new RequestAuthorizationContext(request, matchResult.getVariables()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user