public class AuthenticationPrincipalArgumentResolver extends Object implements HandlerMethodArgumentResolver
Authentication.getPrincipal() from Spring Security
context via SecurityContext.getAuthentication() for parameters
annotated with AuthenticationPrincipal.
The resolver checks both ThreadLocal context via SecurityContextHolder
for Spring MVC applications, and ReactiveSecurityContextHolder for
Spring WebFlux applications.
| Constructor and Description |
|---|
AuthenticationPrincipalArgumentResolver(BeanResolver beanResolver)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
resolveArgument(MethodParameter parameter,
DataFetchingEnvironment environment)
Resolve a method parameter to a value.
|
boolean |
supportsParameter(MethodParameter parameter)
Whether this resolver supports the given
MethodParameter. |
public AuthenticationPrincipalArgumentResolver(BeanResolver beanResolver)
beanResolver - the BeanResolver used for resolving beans in SpEL expressions. Cannot be null.public boolean supportsParameter(MethodParameter parameter)
HandlerMethodArgumentResolverMethodParameter.supportsParameter in interface HandlerMethodArgumentResolverpublic Object resolveArgument(MethodParameter parameter, DataFetchingEnvironment environment) throws Exception
HandlerMethodArgumentResolverresolveArgument in interface HandlerMethodArgumentResolverparameter - the method parameter to resolve. This parameter must
have previously checked via HandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter).environment - the environment to use to resolve the valuenull if not resolved;
the value may also be a Mono if it
requires asynchronous resolution.Exception - in case of errors with the preparation of argument values