|  | @ -29,6 +29,8 @@ public class ExternalAppAuthServiceImpl implements ExternalAppAuthService { | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private ExternalAppSecretDao externalAppSecretDao; |  |  |     private ExternalAppSecretDao externalAppSecretDao; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private int diffMillins = 1000 * 60 * 5; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public ExternalAppAuthResultDTO auth(String appId, String token) { |  |  |     public ExternalAppAuthResultDTO auth(String appId, String token) { | 
			
		
	
		
		
			
				
					|  |  |         String secret; |  |  |         String secret; | 
			
		
	
	
		
		
			
				
					|  | @ -47,6 +49,18 @@ public class ExternalAppAuthServiceImpl implements ExternalAppAuthService { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         String appIdIn = (String)claim.get("appId"); |  |  |         String appIdIn = (String)claim.get("appId"); | 
			
		
	
		
		
			
				
					|  |  |         String customerId = (String)claim.get("customerId"); |  |  |         String customerId = (String)claim.get("customerId"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Long timestamp = (Long)claim.get("ts"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //校验时间戳,允许5分钟误差
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (StringUtils.isAnyBlank(appIdIn, customerId) || timestamp == null) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             logger.error("access token不完整。{},{},{}", appIdIn, customerId, timestamp); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return fillAuthResult(false, "access token不完整。", null); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!validTimeStamp(timestamp)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             logger.error("服务器存在时差过大,请求被拒绝", appId, appIdIn); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return fillAuthResult(false, "服务器存在时差过大,请求被拒绝", null); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         if (!appId.equals(appIdIn)) { |  |  |         if (!appId.equals(appIdIn)) { | 
			
		
	
		
		
			
				
					|  |  |             logger.error("AppId不对应,token外部的:{}, token内部解析出来的:{}", appId, appIdIn); |  |  |             logger.error("AppId不对应,token外部的:{}, token内部解析出来的:{}", appId, appIdIn); | 
			
		
	
	
		
		
			
				
					|  | @ -55,6 +69,15 @@ public class ExternalAppAuthServiceImpl implements ExternalAppAuthService { | 
			
		
	
		
		
			
				
					|  |  |         return fillAuthResult(true, "解析成功", customerId); |  |  |         return fillAuthResult(true, "解析成功", customerId); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private boolean validTimeStamp(Long timestamp) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         long now = System.currentTimeMillis(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | //        System.out.println(new Date(timestamp));
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (Math.abs(now - timestamp) > diffMillins) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return false; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return true; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * 通过APP ID查询对应的秘钥 |  |  |      * 通过APP ID查询对应的秘钥 | 
			
		
	
		
		
			
				
					|  |  |      * @param appId |  |  |      * @param appId | 
			
		
	
	
		
		
			
				
					|  | 
 |