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

org.zodiac.boot.resolver.ServletTokenArgumentResolver Maven / Gradle / Ivy

The newest version!
package org.zodiac.boot.resolver;

import org.springframework.core.MethodParameter;
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;
import org.zodiac.security.auth.model.SecurityPlatformUser;
import org.zodiac.security.util.SecurityServletAuthUtil;

/**
 * Token转化SecurityPlatformUser。
 *
 */
public class ServletTokenArgumentResolver implements HandlerMethodArgumentResolver {

    public ServletTokenArgumentResolver() {
    }

    /**
     * 入参筛选。
     *
     * @param methodParameter 参数集合
     * @return 格式化后的参数
     */
    @Override
    public boolean supportsParameter(MethodParameter methodParameter) {
        return methodParameter.getParameterType().equals(SecurityPlatformUser.class);
    }

    /**
     * 出参设置。
     *
     * @param methodParameter 入参集合
     * @param modelAndViewContainer model 和 view
     * @param nativeWebRequest web相关
     * @param webDataBinderFactory 入参解析
     * @return 包装对象
     */
    @Override
    public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer,
        NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) {
        return SecurityServletAuthUtil.getUser();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy