All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cloud.agileframework.security.UserDetailHandlerMethodArgumentResolver Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package cloud.agileframework.security;

import cloud.agileframework.spring.util.SecurityUtil;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

/**
 * @author 佟盟
 * 日期 2020/6/1 14:17
 * 描述 Agile参数解析器
 * @version 1.0
 * @since 1.0
 */
public class UserDetailHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
    @Override
    public boolean supportsParameter(MethodParameter methodParameter) {
        return UserDetails.class.isAssignableFrom(methodParameter.getParameterType());
    }

    @Override
    @Nullable
    public Object resolveArgument(@Nullable MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
        return SecurityUtil.currentUser();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy