| 
					
				 | 
			
			
				@ -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; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -65,6 +67,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 +127,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ZhongShanSMSService zhongShanSMSService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private OauthCaConfigSerivce oauthCaConfigSerivce; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private OauthWjwConfigService oauthWjwConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostConstruct 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -752,9 +757,80 @@ 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 base64 = URLDecoder.decode(authCode,"UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("base64 :"+base64); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //固定秘钥解密 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String key = "FEA5049E4CCD16A9"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String data = AES.decrypt(key,base64); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("wjwLogin :"+data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO patientDO = oauthWjwConfigService.savePatient(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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"); 
			 |