// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/mp/security/authentication/WeChatMpOAuth2AccessTokenAuthentication.java
// public class WeChatMpOAuth2AccessTokenAuthentication implements Authentication {
// 
//     private final WxMpOAuth2AccessToken accessToken;
// 
//     public WeChatMpOAuth2AccessTokenAuthentication(WxMpOAuth2AccessToken accessToken) {
//         this.accessToken = accessToken;
//     }
// 
//     @Override
//     public Collection<? extends GrantedAuthority> getAuthorities() {
//         return Collections.emptyList();
//     }
// 
//     @Override
//     public Object getCredentials() {
//         return null;
//     }
// 
//     @Override
//     public Object getDetails() {
//         return getOpenId();
//     }
// 
//     @Override
//     public Object getPrincipal() {
//         return getOpenId();
//     }
// 
//     @Override
//     public boolean isAuthenticated() {
//         return true;
//     }
// 
//     @Override
//     public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
// 
//     }
// 
//     @Override
//     public String getName() {
//         return accessToken.getOpenId();
//     }
// 
//     public OpenId getOpenId() {
//         return OpenId.valueOf(accessToken.getOpenId());
//     }
// }
// 
// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/oauth/OpenId.java
// @Value
// public class OpenId {
// 
//     private String value;
// 
//     private OpenId(String value) {
//         this.value = value;
//     }
// 
//     public static OpenId valueOf(String value) {
//         return new OpenId(value);
//     }
// }


import com.github.hippoom.wechat.mp.security.authentication.WeChatMpOAuth2AccessTokenAuthentication;
import com.github.hippoom.wechat.mp.web.bind.annotation.CurrentWeChatMpUser;
import com.github.hippoom.wechat.oauth.OpenId;
import org.springframework.core.MethodParameter;
import org.springframework.security.core.context.SecurityContextHolder;
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;
package com.github.hippoom.wechat.mp.web.method.support;


public class OpenIdHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {

    @Override
    public boolean supportsParameter(MethodParameter methodParameter) {
        return methodParameter.getParameterType().equals(OpenId.class);
    }

    @Override
    public Object resolveArgument(MethodParameter methodParameter,
        ModelAndViewContainer modelAndViewContainer,
        NativeWebRequest nativeWebRequest,
        WebDataBinderFactory webDataBinderFactory) throws Exception {

// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/mp/security/authentication/WeChatMpOAuth2AccessTokenAuthentication.java
// public class WeChatMpOAuth2AccessTokenAuthentication implements Authentication {
// 
//     private final WxMpOAuth2AccessToken accessToken;
// 
//     public WeChatMpOAuth2AccessTokenAuthentication(WxMpOAuth2AccessToken accessToken) {
//         this.accessToken = accessToken;
//     }
// 
//     @Override
//     public Collection<? extends GrantedAuthority> getAuthorities() {
//         return Collections.emptyList();
//     }
// 
//     @Override
//     public Object getCredentials() {
//         return null;
//     }
// 
//     @Override
//     public Object getDetails() {
//         return getOpenId();
//     }
// 
//     @Override
//     public Object getPrincipal() {
//         return getOpenId();
//     }
// 
//     @Override
//     public boolean isAuthenticated() {
//         return true;
//     }
// 
//     @Override
//     public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
// 
//     }
// 
//     @Override
//     public String getName() {
//         return accessToken.getOpenId();
//     }
// 
//     public OpenId getOpenId() {
//         return OpenId.valueOf(accessToken.getOpenId());
//     }
// }
// 
// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/oauth/OpenId.java
// @Value
// public class OpenId {
// 
//     private String value;
// 
//     private OpenId(String value) {
//         this.value = value;
//     }
// 
//     public static OpenId valueOf(String value) {
//         return new OpenId(value);
//     }
// }


// Path: wechat-mp-autoconfigure/src/main/java/com/github/hippoom/wechat/mp/web/method/support/OpenIdHandlerMethodArgumentResolver.java
import com.github.hippoom.wechat.mp.security.authentication.WeChatMpOAuth2AccessTokenAuthentication;
import com.github.hippoom.wechat.mp.web.bind.annotation.CurrentWeChatMpUser;
import com.github.hippoom.wechat.oauth.OpenId;
import org.springframework.core.MethodParameter;
import org.springframework.security.core.context.SecurityContextHolder;
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;

package com.github.hippoom.wechat.mp.web.method.support;


public class OpenIdHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {

    @Override
    public boolean supportsParameter(MethodParameter methodParameter) {
        return methodParameter.getParameterType().equals(OpenId.class);
    }

    @Override
    public Object resolveArgument(MethodParameter methodParameter,
        ModelAndViewContainer modelAndViewContainer,
        NativeWebRequest nativeWebRequest,
        WebDataBinderFactory webDataBinderFactory) throws Exception {

        WeChatMpOAuth2AccessTokenAuthentication user = (WeChatMpOAuth2AccessTokenAuthentication)