Commit aa9c5bb70042d2923bdaac7a3f6b766a14565b32
1 parent
558a646e
1.IP白名单相关
Showing
6 changed files
with
177 additions
and
14 deletions
src/main/java/com/bsth/XDApplication.java
| @@ -308,8 +308,8 @@ public class XDApplication implements CommandLineRunner { | @@ -308,8 +308,8 @@ public class XDApplication implements CommandLineRunner { | ||
| 308 | sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) | 308 | sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) |
| 309 | 309 | ||
| 310 | //运管处静态数据提交 | 310 | //运管处静态数据提交 |
| 311 | - log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); | ||
| 312 | - sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | 311 | + //log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); |
| 312 | + //sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | ||
| 313 | //计算油、公里加注 | 313 | //计算油、公里加注 |
| 314 | sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | 314 | sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); |
| 315 | 315 |
src/main/java/com/bsth/filter/WhiteIpFilter.java
| @@ -14,9 +14,9 @@ import org.slf4j.LoggerFactory; | @@ -14,9 +14,9 @@ import org.slf4j.LoggerFactory; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.core.annotation.Order; | 15 | import org.springframework.core.annotation.Order; |
| 16 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
| 17 | +import org.springframework.web.context.WebApplicationContext; | ||
| 17 | 18 | ||
| 18 | -import javax.servlet.FilterChain; | ||
| 19 | -import javax.servlet.ServletException; | 19 | +import javax.servlet.*; |
| 20 | import javax.servlet.http.HttpServletRequest; | 20 | import javax.servlet.http.HttpServletRequest; |
| 21 | import javax.servlet.http.HttpServletResponse; | 21 | import javax.servlet.http.HttpServletResponse; |
| 22 | import java.io.IOException; | 22 | import java.io.IOException; |
| @@ -28,21 +28,26 @@ import java.util.Map; | @@ -28,21 +28,26 @@ import java.util.Map; | ||
| 28 | * IP白名单过滤器 | 28 | * IP白名单过滤器 |
| 29 | * @author Hill | 29 | * @author Hill |
| 30 | */ | 30 | */ |
| 31 | -@Component | ||
| 32 | -@Order(1) | ||
| 33 | -public class WhiteIpFilter extends BaseFilter { | 31 | +public class WhiteIpFilter implements Filter { |
| 34 | 32 | ||
| 35 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 33 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 36 | 34 | ||
| 37 | - @Autowired | ||
| 38 | private Setting setting; | 35 | private Setting setting; |
| 39 | 36 | ||
| 37 | + public Setting getSetting() { | ||
| 38 | + return setting; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setSetting(Setting setting) { | ||
| 42 | + this.setting = setting; | ||
| 43 | + } | ||
| 44 | + | ||
| 40 | @Override | 45 | @Override |
| 41 | - public void doFilter(HttpServletRequest request, | ||
| 42 | - HttpServletResponse response, FilterChain chain) | ||
| 43 | - throws IOException, ServletException { | 46 | + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| 47 | + HttpServletRequest req = (HttpServletRequest)request; | ||
| 48 | + HttpServletResponse res = (HttpServletResponse)response; | ||
| 44 | 49 | ||
| 45 | - String ip = IpUtils.getIpAddr(request); | 50 | + String ip = IpUtils.getIpAddr(req); |
| 46 | boolean isMatch = false; | 51 | boolean isMatch = false; |
| 47 | List<WhiteIp> whiteIps = BasicData.whiteIpList; | 52 | List<WhiteIp> whiteIps = BasicData.whiteIpList; |
| 48 | if (whiteIps != null) { | 53 | if (whiteIps != null) { |
| @@ -56,7 +61,7 @@ public class WhiteIpFilter extends BaseFilter { | @@ -56,7 +61,7 @@ public class WhiteIpFilter extends BaseFilter { | ||
| 56 | chain.doFilter(request, response); | 61 | chain.doFilter(request, response); |
| 57 | } else { | 62 | } else { |
| 58 | logger.info(ip + "未在白名单中,不予访问"); | 63 | logger.info(ip + "未在白名单中,不予访问"); |
| 59 | - response.setStatus(404); | 64 | + res.setStatus(404); |
| 60 | return; | 65 | return; |
| 61 | } | 66 | } |
| 62 | } | 67 | } |
src/main/java/com/bsth/security/WebSecurityConfig.java
| 1 | package com.bsth.security; | 1 | package com.bsth.security; |
| 2 | 2 | ||
| 3 | +import com.bsth.common.Setting; | ||
| 4 | +import com.bsth.filter.WhiteIpFilter; | ||
| 3 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 4 | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; | 6 | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; |
| 5 | import org.springframework.context.annotation.Bean; | 7 | import org.springframework.context.annotation.Bean; |
| @@ -33,11 +35,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -33,11 +35,13 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 33 | @Autowired | 35 | @Autowired |
| 34 | SecurityMetadataSourceService securityMetadataSourceService; | 36 | SecurityMetadataSourceService securityMetadataSourceService; |
| 35 | 37 | ||
| 38 | + @Autowired | ||
| 39 | + Setting setting; | ||
| 36 | 40 | ||
| 37 | @Override | 41 | @Override |
| 38 | public void configure(WebSecurity web) throws Exception { | 42 | public void configure(WebSecurity web) throws Exception { |
| 39 | // 白名单 | 43 | // 白名单 |
| 40 | - web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, | 44 | + web.ignoring().antMatchers(Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, |
| 41 | Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT); | 45 | Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT); |
| 42 | } | 46 | } |
| 43 | 47 | ||
| @@ -70,6 +74,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -70,6 +74,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 70 | .maxSessionsPreventsLogin(false)//让之前的登录过期 | 74 | .maxSessionsPreventsLogin(false)//让之前的登录过期 |
| 71 | .sessionRegistry(sessionRegistry()); | 75 | .sessionRegistry(sessionRegistry()); |
| 72 | 76 | ||
| 77 | + WhiteIpFilter whiteIpFilter = new WhiteIpFilter(); | ||
| 78 | + whiteIpFilter.setSetting(setting); | ||
| 79 | + http.addFilterBefore(whiteIpFilter, FilterSecurityInterceptor.class); | ||
| 73 | http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class); | 80 | http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class); |
| 74 | http.addFilter(filterSecurityInterceptor()); | 81 | http.addFilter(filterSecurityInterceptor()); |
| 75 | } | 82 | } |
src/main/resources/application-cloud.properties
0 → 100644
| 1 | +server.port=9088 | ||
| 2 | + | ||
| 3 | +# dubbo����ʹ�ÿ���flag | ||
| 4 | +dubbo.use=false | ||
| 5 | + | ||
| 6 | +#JPA | ||
| 7 | +spring.jpa.hibernate.ddl-auto= none | ||
| 8 | +spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl | ||
| 9 | +spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy | ||
| 10 | +spring.jpa.database= MYSQL | ||
| 11 | +spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true | ||
| 12 | +spring.jpa.show-sql= false | ||
| 13 | + | ||
| 14 | +#DATABASE | ||
| 15 | +spring.datasource.driver-class-name= com.mysql.jdbc.Driver | ||
| 16 | +spring.datasource.url= jdbc:mysql://192.170.100.132/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | ||
| 17 | +spring.datasource.username= root | ||
| 18 | +spring.datasource.password= root2jsp | ||
| 19 | +spring.datasource.type= com.zaxxer.hikari.HikariDataSource | ||
| 20 | + | ||
| 21 | +#DATASOURCE SETTING | ||
| 22 | +spring.datasource.hikari.minimum-idle= 8 | ||
| 23 | +spring.datasource.hikari.maximum-pool-size= 100 | ||
| 24 | +#spring.datasource.hikari.auto-commit= true | ||
| 25 | +spring.datasource.hikari.idle-timeout= 60000 | ||
| 26 | +#spring.datasource.hikari.pool-name= HikariPool | ||
| 27 | +spring.datasource.hikari.max-lifetime= 1800000 | ||
| 28 | +spring.datasource.hikari.connection-timeout= 3000 | ||
| 29 | +spring.datasource.hikari.connection-test-query= SELECT 1 | ||
| 30 | +spring.datasource.hikari.validation-timeout= 3000 | ||
| 31 | +spring.datasource.hikari.register-mbeans=true | ||
| 32 | + | ||
| 33 | +## gps client data | ||
| 34 | +http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all | ||
| 35 | +## gateway real data | ||
| 36 | +http.gps.real.url= http://192.170.100.252:8080/transport_server/rtgps/ | ||
| 37 | +## gateway send directive | ||
| 38 | +http.send.directive = http://192.170.100.252:8080/transport_server/message/ | ||
| 39 | +## rfid data | ||
| 40 | +http.rfid.url= http://114.80.178.12:29000/rfid | ||
| 41 | +## http ticketing interface | ||
| 42 | +http.ticketing.interface= http://112.64.187.3:1080/gjService/request | ||
| 43 | +## first last generate | ||
| 44 | +ms.fl.generate=true | ||
| 45 | +## dsm ack interface | ||
| 46 | +dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | ||
| 47 | +## cp ack interface | ||
| 48 | +cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 49 | +## admin mail | ||
| 50 | +admin.mail= 113252620@qq.com | ||
| 51 | +## enabled | ||
| 52 | +enabled.whiteip= false | ||
| 0 | \ No newline at end of file | 53 | \ No newline at end of file |
src/main/resources/datatools/config-cloud.properties
0 → 100644
| 1 | +# 配置数据导入导出用到的配置信息 | ||
| 2 | + | ||
| 3 | +# 1、kettle配置文件路径(类路径) | ||
| 4 | +datatools.kettle_properties=/datatools/kettle.properties | ||
| 5 | +# 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正) | ||
| 6 | + | ||
| 7 | +#数据库ip地址 | ||
| 8 | +datatools.kvars_dbip=192.170.100.132 | ||
| 9 | +#数据库用户名 | ||
| 10 | +datatools.kvars_dbuname=root | ||
| 11 | +#数据库密码 | ||
| 12 | +datatools.kvars_dbpwd=root2jsp | ||
| 13 | +#数据库库名 | ||
| 14 | +datatools.kvars_dbdname=control | ||
| 15 | + | ||
| 16 | +# 3、上传数据配置信息 | ||
| 17 | +# 上传文件目录配置(根据不同的环境需要修正) | ||
| 18 | +datatools.fileupload_dir=/home/bsth_control_u_d_files | ||
| 19 | +# ktr转换文件,中配置的错误输出目录(根据不同的环境需要修正) | ||
| 20 | +datatools.trans_errordir=/home/bsth_control_u_d_files/erroroutput | ||
| 21 | +# 临时输出文件目录 | ||
| 22 | +datatools.trans_tempdir=/home/bsth_control_u_d_files/temp | ||
| 23 | +# 模版文件目录 | ||
| 24 | +datatools.trans_templatedir=/home/bsth_control_u_d_files/template | ||
| 25 | + | ||
| 26 | +##---------------------------- 导入数据ktr ----------------------------## | ||
| 27 | +# 车辆信息导入ktr转换 | ||
| 28 | +datatools.cars_datainputktr=/datatools/ktrs/carsDataInput.ktr | ||
| 29 | +# 人员信息导入 | ||
| 30 | +datatools.employees_datainputktr=/datatools/ktrs/employeesDataInput.ktr | ||
| 31 | +# 路牌信息导入 | ||
| 32 | +datatools.guideboards_datainputktr=/datatools/ktrs/guideboardDataInput.ktr | ||
| 33 | +# 时刻表基础信息导入 | ||
| 34 | +datatools.ttinfo_datainputktr=/datatools/ktrs/ttinfoDataInput.ktr | ||
| 35 | +# 时刻表明细信息导入(元数据) | ||
| 36 | +datatools.ttinfodetail_metadatainputktr=/datatools/ktrs/ttinfodetailDataInputMetaData.ktr | ||
| 37 | +# 时刻表明细编辑用数据 | ||
| 38 | +datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr | ||
| 39 | +# 时刻表明细信息导入 | ||
| 40 | +datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr | ||
| 41 | +# 时刻表明细信息导入2 | ||
| 42 | +datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr | ||
| 43 | +# 时刻表明细信息导入2(版本化) | ||
| 44 | +datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr | ||
| 45 | +# 时刻表明细信息导入2(版本化),使用生成时刻表格式 | ||
| 46 | +datatools.ttinfodetail_datainputktr2version2=/datatools/ktrs/ttinfodetailDataInput2_version_2.ktr | ||
| 47 | + | ||
| 48 | +# 车辆配置信息导入 | ||
| 49 | +datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr | ||
| 50 | +# 人员配置信息导入 | ||
| 51 | +datatools.employeesconfig_datainputktr=/datatools/ktrs/employeesConfigDataInput.ktr | ||
| 52 | + | ||
| 53 | +# 排版规则信息导入 | ||
| 54 | +datatools.schedulerule_datainputktr=/datatools/ktrs/scheduleRuleDataInput.ktr | ||
| 55 | + | ||
| 56 | +# 4、数据导出配置信息 | ||
| 57 | +# 导出数据文件目录配置(根据不同的环境需要修正) | ||
| 58 | +datatools.fileoutput_dir=/home/bsth_control_u_d_files | ||
| 59 | + | ||
| 60 | +##---------------------------- 导出数据ktr -----------------------------## | ||
| 61 | +# 车辆信息导出ktr转换 | ||
| 62 | +datatools.cars_dataoutputktr=/datatools/ktrs/carsDataOutput.ktr | ||
| 63 | +# 人员信息导出ktr转换 | ||
| 64 | +datatools.employees_dataoutputktr=/datatools/ktrs/employeesDataOutput.ktr | ||
| 65 | +# 时刻表导出元数据ktr转换 | ||
| 66 | +datatools.ttinfodetail_metaoutput=/datatools/ktrs/ttinfodetailDataOutputMetaData.ktr | ||
| 67 | +# 时刻表导出数据ktr转换 | ||
| 68 | +datatools.ttinfodetail_output=/datatools/ktrs/ttinfodetailDataOutput.ktr | ||
| 69 | +# 排版规则导出数据ktr转换 | ||
| 70 | +datatools.schedulerule_output=/datatools/ktrs/scheduleRuleDataOutput.ktr | ||
| 71 | + | ||
| 72 | +# 车辆配置信息导出ktr转换 | ||
| 73 | +datatools.carsconfig_dataoutputktr=/datatools/ktrs/carsConfigDataOutput.ktr | ||
| 74 | +# 人员配置信息导出ktr转换 | ||
| 75 | +datatools.employeesconfig_dataoutputktr=/datatools/ktrs/employeesConfigDataOutput.ktr | ||
| 76 | + | ||
| 77 | +# 路牌信息导出 | ||
| 78 | +datatools.guideboards_dataoutputktr=/datatools/ktrs/guideboardDataOutput.ktr | ||
| 79 | + | ||
| 80 | +##--------------------------- 数据同步ktr ------------------------## | ||
| 81 | +datatools.vehicle_datasyncktr=/datatools/ktrs/vehicleDataSync.ktr | ||
| 82 | + | ||
| 83 | +# TODO: |
src/main/resources/dubbo/config-cloud.properties
0 → 100644
| 1 | +# application名字 | ||
| 2 | +spring.dubbo.application.name=bsth_control_v_multi_service | ||
| 3 | +# zookeeper注册中心地址 | ||
| 4 | +spring.dubbo.registry=zookeeper://127.0.0.1:2181 | ||
| 5 | +# protocol配置 | ||
| 6 | +spring.dubbo.protocol.name=dubbo | ||
| 7 | +spring.dubbo.protocol.port=30881 | ||
| 8 | + | ||
| 9 | +#----------- dubbo:consumer 性能调优选项 -------------# | ||
| 10 | +# 远程服务调用超时时间,单位毫秒,这里设置30分钟 | ||
| 11 | +spring.dubbo.consumer.timeout=1800000 | ||
| 12 | +# 远程服务调用重试次数,0表示不需要重试 | ||
| 13 | +spring.dubbo.consumer.retries=0 | ||
| 14 | +#----------- dubbo:consumer 服务治理选项 -------------# | ||
| 15 | +# 启动不检查提供者是否存在 | ||
| 16 | +spring.dubbo.consumer.check=false |