|  | @ -19,8 +19,10 @@ import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.service.OauthCaConfigSerivce;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.service.OauthWjwConfigService;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.service.OauthWlyyConfigService;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.service.OauthYlzConfigService;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.utils.AES;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.utils.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.security.utils.SerializeUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.sms.service.ZhongShanSMSService;
 | 
	
	
		
			
				|  | @ -47,10 +49,7 @@ import org.springframework.security.oauth2.provider.error.WebResponseExceptionTr
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
 | 
	
		
			
				|  |  | import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
 | 
	
		
			
				|  |  | import org.springframework.util.Assert;
 | 
	
		
			
				|  |  | import org.springframework.util.LinkedMultiValueMap;
 | 
	
		
			
				|  |  | import org.springframework.util.MultiValueMap;
 | 
	
		
			
				|  |  | import org.springframework.util.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.util.*;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | import org.springframework.web.client.RestTemplate;
 | 
	
		
			
				|  |  | import org.springframework.web.context.request.RequestContextHolder;
 | 
	
	
		
			
				|  | @ -65,6 +64,7 @@ import javax.servlet.http.HttpSession;
 | 
	
		
			
				|  |  | import java.awt.image.BufferedImage;
 | 
	
		
			
				|  |  | import java.io.ByteArrayOutputStream;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.net.URLDecoder;
 | 
	
		
			
				|  |  | import java.security.KeyPair;
 | 
	
		
			
				|  |  | import java.security.PrivateKey;
 | 
	
		
			
				|  |  | import java.security.interfaces.RSAPrivateKey;
 | 
	
	
		
			
				|  | @ -124,6 +124,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
 | 
	
		
			
				|  |  |     private ZhongShanSMSService zhongShanSMSService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OauthCaConfigSerivce oauthCaConfigSerivce;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OauthWjwConfigService oauthWjwConfigService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostConstruct
 | 
	
	
		
			
				|  | @ -752,9 +754,83 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取易联众授权码
 | 
	
		
			
				|  |  |      * 卫健委授权登录
 | 
	
		
			
				|  |  |      * @param authCode
 | 
	
		
			
				|  |  |      * @param client_id
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/oauth/wjwLogin", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |     public ObjEnvelop getWjwDecrypt(String authCode,String client_id) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(client_id)) {
 | 
	
		
			
				|  |  |             throw new InvalidRequestException("client_id is null");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             logger.info("authCode :"+authCode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String str = URLDecoder.decode(authCode,"UTF-8");
 | 
	
		
			
				|  |  |             logger.info("base64 :"+str);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String data = new String(Base64Utils.decode((str.getBytes())));
 | 
	
		
			
				|  |  |             //固定秘钥解密
 | 
	
		
			
				|  |  |             String key = "FEA5049E4CCD16A9";
 | 
	
		
			
				|  |  |             String result = AES.decrypt(key,data);
 | 
	
		
			
				|  |  |             logger.info("wjwLogin :"+result);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
 | 
	
		
			
				|  |  |             if(patientDO == null){
 | 
	
		
			
				|  |  |                 return ObjEnvelop.getError("授权登录失败!");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, String> parameters = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             parameters.put("username",patientDO.getIdcard());
 | 
	
		
			
				|  |  |             parameters.put("grant_type", "ihealthCode");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
 | 
	
		
			
				|  |  |             if (authenticatedClient != null) {
 | 
	
		
			
				|  |  |                 oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
 | 
	
		
			
				|  |  |             if (token == null) {
 | 
	
		
			
				|  |  |                 throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
 | 
	
		
			
				|  |  |             wlyyUserSimple.setAccessToken(token.getValue());
 | 
	
		
			
				|  |  |             wlyyUserSimple.setTokenType(token.getTokenType());
 | 
	
		
			
				|  |  |             wlyyUserSimple.setExpiresIn(token.getExpiresIn());
 | 
	
		
			
				|  |  |             wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
 | 
	
		
			
				|  |  |             wlyyUserSimple.setUser(parameters.get("username"));
 | 
	
		
			
				|  |  |             String loginType = parameters.get("login_type");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
 | 
	
		
			
				|  |  |             userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             baseLoginLogDO.setUserId(wlyyUserSimple.getId());
 | 
	
		
			
				|  |  |             baseLoginLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             String userAgent = JSONObject.toJSONString(wlyyUserSimple);
 | 
	
		
			
				|  |  |             baseLoginLogDO.setUserAgent(userAgent);
 | 
	
		
			
				|  |  |             baseLoginLogDO.setLoginType(loginType);
 | 
	
		
			
				|  |  |             baseLoginLogService.save(baseLoginLogDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return ObjEnvelop.getSuccess("success",wlyyUserSimple);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             logger.error(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getError("登录失败!");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         /**
 | 
	
		
			
				|  |  |          * 获取易联众授权码
 | 
	
		
			
				|  |  |          * @return
 | 
	
		
			
				|  |  |          */
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/oauth/getOauthQRCode", method = RequestMethod.GET)
 | 
	
		
			
				|  |  |     public ObjEnvelop getOauthQRCode(){
 | 
	
		
			
				|  |  |         logger.info("/oauth/getOauthQRCode");
 |