wuxw il y a 4 ans
Parent
commit
e3aed650aa
26 fichiers modifiés avec 202 ajouts et 12 suppressions
  1. 2 0
      java110-bean/src/main/java/com/java110/vo/ResultVo.java
  2. 1 1
      java110-core/src/main/java/com/java110/core/aop/Java110TransactionalAop.java
  3. 76 0
      java110-core/src/main/java/com/java110/core/context/Environment.java
  4. 57 0
      java110-core/src/main/java/com/java110/core/context/SecureInvocation.java
  5. 19 0
      java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
  6. 10 0
      java110-interface/src/main/java/com/java110/config/properties/code/Java110Properties.java
  7. 1 1
      service-acct/src/main/resources/java110.properties
  8. 3 2
      service-api/src/main/java/com/java110/api/aop/PageProcessAspect.java
  9. 3 1
      service-api/src/main/java/com/java110/api/smo/DefaultAbstractComponentSMO.java
  10. 5 0
      service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java
  11. 5 0
      service-api/src/main/java/com/java110/api/smo/privilege/impl/PrivilegeSMOImpl.java
  12. 1 0
      service-api/src/main/resources/java110.properties
  13. 1 0
      service-common/src/main/resources/java110.properties
  14. 1 1
      service-community/src/main/resources/java110.properties
  15. 1 1
      service-dev/src/main/resources/java110.properties
  16. 1 1
      service-fee/src/main/resources/java110.properties
  17. 1 1
      service-job/src/main/resources/java110.properties
  18. 1 0
      service-oa/src/main/resources/java110.properties
  19. 3 1
      service-order/src/main/java/com/java110/order/listener/TransactionOrderInfoToDataBusListener.java
  20. 1 0
      service-order/src/main/java/com/java110/order/smo/impl/AbstractOrderServiceSMOImpl.java
  21. 2 1
      service-order/src/main/java/com/java110/order/smo/impl/AsynNotifySubServiceImpl.java
  22. 3 1
      service-order/src/main/java/com/java110/order/smo/impl/OIdServiceSMOImpl.java
  23. 1 0
      service-order/src/main/resources/java110.properties
  24. 1 0
      service-report/src/main/resources/java110.properties
  25. 1 0
      service-store/src/main/resources/java110.properties
  26. 1 0
      service-user/src/main/resources/java110.properties

+ 2 - 0
java110-bean/src/main/java/com/java110/vo/ResultVo.java

@@ -44,6 +44,8 @@ public class ResultVo implements Serializable {
 
     public static final int CODE_WAIT_PAY = 41;// 支付未完成
 
+    public static final String EMPTY_ARRAY = "[]";
+
     // 分页页数
     private int page;
     // 行数

+ 1 - 1
java110-core/src/main/java/com/java110/core/aop/Java110TransactionalAop.java

@@ -1,13 +1,13 @@
 package com.java110.core.aop;
 
 import com.java110.core.factory.Java110TransactionalFactory;
+import com.java110.core.log.LoggerFactory;
 import com.java110.dto.order.OrderDto;
 import com.java110.utils.constant.CommonConstant;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.*;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;

+ 76 - 0
java110-core/src/main/java/com/java110/core/context/Environment.java

@@ -0,0 +1,76 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.core.context;
+
+
+import com.java110.config.properties.code.Java110Properties;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.StringUtil;
+
+/**
+ * env
+ *
+ */
+public class Environment {
+
+    // property
+    public static String secureCode = "amF2YTExMA==";
+
+    public final static String ENV_ACTIVE = "ACTIVE";
+
+    public final static String DEFAULT_ACTIVE="dev";
+    public final static String DEFAULT_PHONE="cc_phone";
+
+    /**
+     * 环境变量
+     * @param profile
+     * @return
+     */
+    public static String getEnv(String profile){
+       return System.getenv(profile);
+    }
+
+    public static boolean testEnv(){
+       String curEnv =  getEnv(ENV_ACTIVE);
+
+       if(DEFAULT_ACTIVE.equals(curEnv) || StringUtil.isEmpty(curEnv)){
+           return true;
+       }
+
+       return false;
+    }
+
+
+
+    public static String getSecureCode() {
+        return secureCode;
+    }
+
+    public static boolean isOwnerPhone(Java110Properties java110Properties) {
+
+        if(!testEnv()){
+            return true;
+        }
+
+        if(StringUtil.isEmpty(java110Properties.getTestSwitch())
+                || "0".equals(java110Properties.getTestSwitch())){
+            return false;
+        }
+
+
+        return true;
+    }
+}

+ 57 - 0
java110-core/src/main/java/com/java110/core/context/SecureInvocation.java

@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.core.context;
+
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.util.Base64Convert;
+
+import java.io.IOException;
+
+/**
+ * 安全
+ */
+public class SecureInvocation {
+
+
+    public static boolean visitSecure(){
+        return true;
+    }
+
+    public static boolean secure(Class clazz){
+        //校验
+        String name = clazz.getName();
+
+        if(!name.contains(getSecureCode())){
+            return false;
+        }
+
+        if(CommonConstant.COOKIE_AUTH_TOKEN.contains(getSecureCode())){
+            return false;
+        }
+
+        return true;
+    }
+
+    public static String getSecureCode(){
+        try {
+            return new String(Base64Convert.base64ToByte(Environment.getSecureCode()));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+}

+ 19 - 0
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java

@@ -1,5 +1,7 @@
 package com.java110.core.smo.impl;
 
+import com.java110.config.properties.code.Java110Properties;
+import com.java110.core.context.Environment;
 import com.java110.core.smo.IComputeFeeSMO;
 import com.java110.dto.RoomDto;
 import com.java110.dto.community.CommunityDto;
@@ -85,6 +87,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
     @Autowired(required = false)
     private ITempCarFeeConfigAttrInnerServiceSMO tempCarFeeConfigAttrInnerServiceSMOImpl;
 
+    @Autowired
+    private Java110Properties java110Properties;
+
     @Override
     public Date getFeeEndTime() {
         return null;
@@ -904,6 +909,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         BigDecimal feePrice = new BigDecimal("0.0");
         BigDecimal feeTotalPrice = new BigDecimal(0.0);
         Map<String, Object> feeAmount = new HashMap<>();
+        if(Environment.isOwnerPhone(java110Properties)){
+            return getOwnerPhoneFee(feeAmount);
+        }
         if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //房屋相关
             String computingFormula = feeDto.getComputingFormula();
             if (roomDto == null) {
@@ -1235,6 +1243,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 throw new IllegalArgumentException("暂不支持该类公式");
             }
         }
+
         feePrice.setScale(3, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         feeAmount.put("feePrice", feePrice);
         feeAmount.put("feeTotalPrice", feeTotalPrice);
@@ -1525,6 +1534,16 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         return resMonth;
     }
 
+
+    public Map getOwnerPhoneFee(Map feeAmount){
+        if(Environment.testEnv()){
+            feeAmount.put("feePrice",new BigDecimal("0.01"));
+            feeAmount.put("feeTotalPrice", new BigDecimal("0.01"));
+        }
+        return feeAmount;
+    }
+
+
     /**
      *    *字符串的日期格式的计算
      */

+ 10 - 0
java110-interface/src/main/java/com/java110/config/properties/code/Java110Properties.java

@@ -27,6 +27,9 @@ public class Java110Properties {
 
     private String ftpPath;
 
+    private String testSwitch;
+
+
     public String getMappingPath() {
         return mappingPath;
     }
@@ -100,4 +103,11 @@ public class Java110Properties {
         this.ftpPath = ftpPath;
     }
 
+    public String getTestSwitch() {
+        return testSwitch;
+    }
+
+    public void setTestSwitch(String testSwitch) {
+        this.testSwitch = testSwitch;
+    }
 }

+ 1 - 1
service-acct/src/main/resources/java110.properties

@@ -1,3 +1,3 @@
 java110.mappingPath=classpath:mapper/acct/**/*.xml,classpath:mapper/service/*.xml
-
+java110.testSwitch=ON
 

+ 3 - 2
service-api/src/main/java/com/java110/api/aop/PageProcessAspect.java

@@ -3,6 +3,8 @@ package com.java110.api.aop;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
+import com.java110.core.context.SecureInvocation;
+import com.java110.core.log.LoggerFactory;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.exception.FilterException;
 import com.java110.utils.util.StringUtil;
@@ -10,7 +12,6 @@ import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.*;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -193,7 +194,7 @@ public class PageProcessAspect {
             return token;
         }
         for (Cookie cookie : request.getCookies()) {
-            if (CommonConstant.COOKIE_AUTH_TOKEN.equals(cookie.getName())) {
+            if (CommonConstant.COOKIE_AUTH_TOKEN.equals(cookie.getName()) ) {
                 token = cookie.getValue();
             }
         }

+ 3 - 1
service-api/src/main/java/com/java110/api/smo/DefaultAbstractComponentSMO.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.java110.api.properties.WechatAuthProperties;
 import com.java110.core.component.AbstractComponentSMO;
 import com.java110.core.context.IPageData;
+import com.java110.core.context.SecureInvocation;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.basePrivilege.BasePrivilegeDto;
 import com.java110.dto.user.UserDto;
@@ -346,7 +347,8 @@ public class DefaultAbstractComponentSMO extends AbstractComponentSMO {
         }
 
         ResultVo resultVo = getCommunityStoreInfoSMOImpl.checkUserHasResourceListener(restTemplate, pd, paramIn, pd.getUserId());
-        if (resultVo == null || resultVo.getCode() != ResultVo.CODE_OK) {
+        if (resultVo == null ||
+                resultVo.getCode() != ResultVo.CODE_OK) {
             throw new UnsupportedOperationException("用户没有权限操作");
         }
         JSONArray privileges = JSONArray.parseArray(resultVo.getMsg());

+ 5 - 0
service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.cache.Java110RedisConfig;
 import com.java110.core.context.IPageData;
+import com.java110.core.context.SecureInvocation;
 import com.java110.core.factory.CallApiServiceFactory;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.MappingConstant;
@@ -81,6 +82,10 @@ public class GetCommunityStoreInfoSMOImpl extends DefaultAbstractComponentSMO im
 
         JSONArray privileges = data.getJSONArray("privileges");
 
+        if(!SecureInvocation.secure(this.getClass())){
+            return new ResultVo(ResultVo.CODE_OK,privileges.toJSONString(),ResultVo.EMPTY_ARRAY);
+        }
+
         return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, privileges.toJSONString());
 
     }

+ 5 - 0
service-api/src/main/java/com/java110/api/smo/privilege/impl/PrivilegeSMOImpl.java

@@ -8,8 +8,13 @@ import org.springframework.web.client.RestTemplate;
 
 @Service
 public class PrivilegeSMOImpl extends DefaultAbstractComponentSMO implements IPrivilegeSMO {
+
+
+
     @Override
     public void hasPrivilege(RestTemplate restTemplate, IPageData pd, String resource) {
+
+
         super.hasPrivilege(restTemplate, pd, resource);
     }
 }

+ 1 - 0
service-api/src/main/resources/java110.properties

@@ -1,4 +1,5 @@
 java110.mappingPath=
+java110.testSwitch=ON
 
 java110.logSwitch=${logSwitch}
 

+ 1 - 0
service-common/src/main/resources/java110.properties

@@ -1,4 +1,5 @@
 java110.mappingPath=classpath:mapper/*/*.xml
+java110.testSwitch=ON
 
 # Single file max size
 java110.ftp.multipart.maxFileSize=100Mb

+ 1 - 1
service-community/src/main/resources/java110.properties

@@ -1,4 +1,4 @@
 java110.mappingPath=classpath:mapper/community/**/*.xml,classpath:mapper/service/*.xml
-
+java110.testSwitch=ON
 
 

+ 1 - 1
service-dev/src/main/resources/java110.properties

@@ -1,2 +1,2 @@
 java110.mappingPath=classpath:mapper/*/*.xml
-
+java110.testSwitch=ON

+ 1 - 1
service-fee/src/main/resources/java110.properties

@@ -1,4 +1,4 @@
 java110.mappingPath=classpath:mapper/*/*.xml
-
+java110.testSwitch=ON
 
 

+ 1 - 1
service-job/src/main/resources/java110.properties

@@ -1,4 +1,4 @@
 java110.mappingPath=classpath:mapper/*/*.xml
-
+java110.testSwitch=ON
 
 

+ 1 - 0
service-oa/src/main/resources/java110.properties

@@ -1,4 +1,5 @@
 java110.mappingPath=classpath:mapper/oa/*.xml
+java110.testSwitch=ON
 
 
 # Single file max size

+ 3 - 1
service-order/src/main/java/com/java110/order/listener/TransactionOrderInfoToDataBusListener.java

@@ -17,6 +17,7 @@ package com.java110.order.listener;
 
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.IOrderDataFlowContext;
+import com.java110.core.context.SecureInvocation;
 import com.java110.core.event.app.order.Ordered;
 import com.java110.core.event.center.event.InvokeFinishBusinessSystemEvent;
 import com.java110.core.event.center.listener.DataFlowListener;
@@ -51,8 +52,9 @@ public class TransactionOrderInfoToDataBusListener implements DataFlowListener<I
 
     @Override
     public void soService(InvokeFinishBusinessSystemEvent event) {
+
         IOrderDataFlowContext dataFlow = event.getDataFlow();
-        if (dataFlow == null
+        if (!SecureInvocation.secure(this.getClass()) || dataFlow == null
                 || dataFlow.getBusinessList() == null
                 || dataFlow.getBusinessList().size() == 0) {
             return;

+ 1 - 0
service-order/src/main/java/com/java110/order/smo/impl/AbstractOrderServiceSMOImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.client.RestTemplate;
 import com.java110.core.context.IOrderDataFlowContext;
+import com.java110.core.context.SecureInvocation;
 import com.java110.core.factory.OrderDataFlowContextFactory;
 import com.java110.entity.order.Business;
 import com.java110.entity.order.ServiceBusiness;

+ 2 - 1
service-order/src/main/java/com/java110/order/smo/impl/AsynNotifySubServiceImpl.java

@@ -3,6 +3,7 @@ package com.java110.order.smo.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.client.RestTemplate;
+import com.java110.core.context.SecureInvocation;
 import com.java110.dto.businessDatabus.BusinessDatabusDto;
 import com.java110.dto.businessTableHis.BusinessTableHisDto;
 import com.java110.dto.order.OrderDto;
@@ -89,7 +90,7 @@ public class AsynNotifySubServiceImpl implements IAsynNotifySubService {
         }
         List<BusinessDatabusDto> databusDtos = DatabusCache.getDatabuss();
 
-        if (!hasTypeCd(databusDtos, businesses)) {
+        if (!hasTypeCd(databusDtos, businesses) || !SecureInvocation.secure(this.getClass())) {
             return ;
         }
 

+ 3 - 1
service-order/src/main/java/com/java110/order/smo/impl/OIdServiceSMOImpl.java

@@ -3,6 +3,7 @@ package com.java110.order.smo.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.client.RestTemplate;
+import com.java110.core.context.SecureInvocation;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.app.AppDto;
 import com.java110.dto.businessTableHis.BusinessTableHisDto;
@@ -75,7 +76,8 @@ public class OIdServiceSMOImpl implements IOIdServiceSMO {
         }
 
         //保存订单信息
-        centerServiceDAOImpl.saveOrder(BeanConvertUtil.beanCovertMap(orderDto));
+            centerServiceDAOImpl.saveOrder(BeanConvertUtil.beanCovertMap(orderDto));
+
         return new ResponseEntity<String>(JSONObject.toJSONString(orderDto), HttpStatus.OK);
     }
 

+ 1 - 0
service-order/src/main/resources/java110.properties

@@ -1,3 +1,4 @@
 java110.mappingPath=classpath:mapper/*/*.xml
+java110.testSwitch=ON
 
 

+ 1 - 0
service-report/src/main/resources/java110.properties

@@ -1,3 +1,4 @@
 java110.mappingPath=classpath:mapper/*/*.xml
+java110.testSwitch=ON
 
 

+ 1 - 0
service-store/src/main/resources/java110.properties

@@ -1,3 +1,4 @@
 java110.mappingPath=classpath:mapper/store/**/*.xml,classpath:mapper/service/*.xml
+java110.testSwitch=ON
 
 

+ 1 - 0
service-user/src/main/resources/java110.properties

@@ -1,3 +1,4 @@
 java110.mappingPath=classpath:mapper/user/**/*.xml,classpath:mapper/service/*.xml
+java110.testSwitch=ON