| 
					
				 | 
			
			
				@ -1,15 +1,20 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.care.endpoint; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.common.BaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.OnenetService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.OneNetUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.OnenetPushUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import static com.yihu.jw.care.util.OneNetUtil.token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created with IntelliJ IDEA. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -23,9 +28,9 @@ import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class OnenetController extends BaseController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static Logger logger = LoggerFactory.getLogger(OnenetController.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private OnenetService onenetService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //用户自定义token和OneNet第三方平台配置里的token一致(配置http推送时使用) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static String token ="jkzl2021"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 功能描述:第三方平台数据接收。<p> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -51,6 +56,8 @@ public class OnenetController extends BaseController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (obj != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean dataRight = OnenetPushUtil.checkSignature(obj, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (dataRight){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("data receive: content" + obj.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("data receive: signature error"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -99,7 +106,7 @@ public class OnenetController extends BaseController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        @RequestParam(value = "signature") String signature) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("url&token check: msg:{} nonce{} signature:{}",msg,nonce,signature); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (OnenetPushUtil.checkToken(msg,nonce,signature,token)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (OnenetPushUtil.checkToken(msg,nonce,signature,OneNetUtil.token)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return msg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "error"; 
			 |