Commit a611b6271cae6dc7e39f88b9abefba8cebd0d53d

Authored by 王通
1 parent dd8abac8

1./external相关接口

src/main/java/com/bsth/filter/AccessFilter.java
@@ -40,8 +40,8 @@ public class AccessFilter extends BaseFilter{ @@ -40,8 +40,8 @@ public class AccessFilter extends BaseFilter{
40 logger.info(s.toString()); 40 logger.info(s.toString());
41 41
42 chain.doFilter(request, response); 42 chain.doFilter(request, response);
43 - s.append("<time:").append(System.currentTimeMillis() - start).append(">");  
44 - logger.info(s.toString()); 43 + //s.append("<time:").append(System.currentTimeMillis() - start).append(">");
  44 + //logger.info(s.toString());
45 } 45 }
46 46
47 private String getParams(HttpServletRequest request) throws JsonProcessingException { 47 private String getParams(HttpServletRequest request) throws JsonProcessingException {
src/main/java/com/bsth/server_rs/AuthorizeInterceptor_IN.java
@@ -5,7 +5,6 @@ import com.bsth.entity.Resource; @@ -5,7 +5,6 @@ import com.bsth.entity.Resource;
5 import com.bsth.server_rs.exception.AesException; 5 import com.bsth.server_rs.exception.AesException;
6 import com.bsth.service.SystemParamService; 6 import com.bsth.service.SystemParamService;
7 import com.bsth.service.UserService; 7 import com.bsth.service.UserService;
8 -import com.bsth.util.ThreadLocalUtils;  
9 import org.apache.commons.lang3.StringEscapeUtils; 8 import org.apache.commons.lang3.StringEscapeUtils;
10 import org.apache.cxf.interceptor.Fault; 9 import org.apache.cxf.interceptor.Fault;
11 import org.apache.cxf.message.Message; 10 import org.apache.cxf.message.Message;
@@ -134,7 +133,6 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor&lt;Message&gt; i @@ -134,7 +133,6 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor&lt;Message&gt; i
134 throw new AesException(AesException.SIGN_CHECK_FAIL); 133 throw new AesException(AesException.SIGN_CHECK_FAIL);
135 } 134 }
136 135
137 - ThreadLocalUtils.setPassword(map.get(PASSWORD));  
138 validate(map, message); 136 validate(map, message);
139 } 137 }
140 138
src/main/java/com/bsth/server_rs/dks/BxRestService.java
@@ -20,7 +20,6 @@ import com.bsth.server_rs.gps.dao.HistoryGpsDao; @@ -20,7 +20,6 @@ import com.bsth.server_rs.gps.dao.HistoryGpsDao;
20 import com.bsth.server_rs.gps.entity.GpsEntity; 20 import com.bsth.server_rs.gps.entity.GpsEntity;
21 import com.bsth.server_rs.gps.entity.HistoryArrivalEntity; 21 import com.bsth.server_rs.gps.entity.HistoryArrivalEntity;
22 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; 22 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK;
23 -import com.bsth.util.ThreadLocalUtils;  
24 import org.apache.commons.lang3.StringUtils; 23 import org.apache.commons.lang3.StringUtils;
25 import org.joda.time.DateTime; 24 import org.joda.time.DateTime;
26 import org.joda.time.format.DateTimeFormat; 25 import org.joda.time.format.DateTimeFormat;
@@ -30,7 +29,9 @@ import org.slf4j.LoggerFactory; @@ -30,7 +29,9 @@ import org.slf4j.LoggerFactory;
30 import org.springframework.beans.factory.annotation.Autowired; 29 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Component; 30 import org.springframework.stereotype.Component;
32 31
  32 +import javax.servlet.http.HttpServletRequest;
33 import javax.ws.rs.*; 33 import javax.ws.rs.*;
  34 +import javax.ws.rs.core.Context;
34 import javax.ws.rs.core.MediaType; 35 import javax.ws.rs.core.MediaType;
35 import java.util.*; 36 import java.util.*;
36 37
@@ -62,9 +63,11 @@ public class BxRestService { @@ -62,9 +63,11 @@ public class BxRestService {
62 63
63 @GET 64 @GET
64 @Path("/line") 65 @Path("/line")
65 - public List<Map<String, Object>> findAllLine() { 66 + public List<Map<String, Object>> findAllLine(@Context HttpServletRequest request) {
66 List<Map<String, Object>> result = new ArrayList<>(); 67 List<Map<String, Object>> result = new ArrayList<>();
67 - String password = ThreadLocalUtils.getPassword(); 68 + String password = request.getParameter("password");
  69 + log.error("log password: {}", password);
  70 + System.out.println("stdio password: " + password);
68 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password); 71 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
69 if (limitLines == null || limitLines.isEmpty()) { 72 if (limitLines == null || limitLines.isEmpty()) {
70 return result; 73 return result;
@@ -103,9 +106,11 @@ public class BxRestService { @@ -103,9 +106,11 @@ public class BxRestService {
103 106
104 @GET 107 @GET
105 @Path("/station") 108 @Path("/station")
106 - public List<Map<String, Object>> findAllStation() { 109 + public List<Map<String, Object>> findAllStation(@Context HttpServletRequest request) {
107 List<Map<String, Object>> result = new ArrayList<>(); 110 List<Map<String, Object>> result = new ArrayList<>();
108 - String password = ThreadLocalUtils.getPassword(); 111 + String password = request.getParameter("password");
  112 + log.error("log password: {}", password);
  113 + System.out.println("stdio password: " + password);
109 Set<String> limitLines = new HashSet<>(authorizeInterceptorIn.getLimitLines(password)); 114 Set<String> limitLines = new HashSet<>(authorizeInterceptorIn.getLimitLines(password));
110 if (limitLines == null || limitLines.isEmpty()) { 115 if (limitLines == null || limitLines.isEmpty()) {
111 return result; 116 return result;
@@ -163,10 +168,12 @@ public class BxRestService { @@ -163,10 +168,12 @@ public class BxRestService {
163 168
164 @GET 169 @GET
165 @Path("/vehicle") 170 @Path("/vehicle")
166 - public List<Map<String, Object>> findAllVehicle() { 171 + public List<Map<String, Object>> findAllVehicle(@Context HttpServletRequest request) {
167 List<Map<String, Object>> result = new ArrayList<>(); 172 List<Map<String, Object>> result = new ArrayList<>();
168 Map<String, String> device2line = GpsRealDataBuffer.getDevice2Line(); 173 Map<String, String> device2line = GpsRealDataBuffer.getDevice2Line();
169 - String password = ThreadLocalUtils.getPassword(); 174 + String password = request.getParameter("password");
  175 + log.error("log password: {}", password);
  176 + System.out.println("stdio password: " + password);
170 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password); 177 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
171 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password); 178 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password);
172 if (limitLines == null || limitLines.isEmpty()) { 179 if (limitLines == null || limitLines.isEmpty()) {
@@ -199,9 +206,11 @@ public class BxRestService { @@ -199,9 +206,11 @@ public class BxRestService {
199 206
200 @GET 207 @GET
201 @Path("/parking") 208 @Path("/parking")
202 - public List<Map<String, Object>> findAllParking() { 209 + public List<Map<String, Object>> findAllParking(@Context HttpServletRequest request) {
203 List<Map<String, Object>> result = new ArrayList<>(); 210 List<Map<String, Object>> result = new ArrayList<>();
204 - String password = ThreadLocalUtils.getPassword(); 211 + String password = request.getParameter("password");
  212 + log.error("log password: {}", password);
  213 + System.out.println("stdio password: " + password);
205 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password); 214 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
206 if (limitLines == null || limitLines.isEmpty()) { 215 if (limitLines == null || limitLines.isEmpty()) {
207 return result; 216 return result;
@@ -234,9 +243,11 @@ public class BxRestService { @@ -234,9 +243,11 @@ public class BxRestService {
234 243
235 @GET 244 @GET
236 @Path("/gps/all") 245 @Path("/gps/all")
237 - public List<Map<String, Object>> findAllGps() { 246 + public List<Map<String, Object>> findAllGps(@Context HttpServletRequest request) {
238 List<Map<String, Object>> result = new ArrayList<>(); 247 List<Map<String, Object>> result = new ArrayList<>();
239 - String password = ThreadLocalUtils.getPassword(); 248 + String password = request.getParameter("password");
  249 + log.error("log password: {}", password);
  250 + System.out.println("stdio password: " + password);
240 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password); 251 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
241 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password); 252 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password);
242 if (limitLines == null || limitLines.isEmpty()) { 253 if (limitLines == null || limitLines.isEmpty()) {
@@ -267,9 +278,11 @@ public class BxRestService { @@ -267,9 +278,11 @@ public class BxRestService {
267 } 278 }
268 @GET 279 @GET
269 @Path("/history-arrival/{line}/{st}/{et}") 280 @Path("/history-arrival/{line}/{st}/{et}")
270 - public List<HistoryArrivalEntity> historyArrival(@PathParam("line") String line, @PathParam("st") String st, @PathParam("et") String et) { 281 + public List<HistoryArrivalEntity> historyArrival(@PathParam("line") String line, @PathParam("st") String st, @PathParam("et") String et, @Context HttpServletRequest request) {
271 List<HistoryArrivalEntity> result = new ArrayList<>(); 282 List<HistoryArrivalEntity> result = new ArrayList<>();
272 - String password = ThreadLocalUtils.getPassword(); 283 + String password = request.getParameter("password");
  284 + log.error("log password: {}", password);
  285 + System.out.println("stdio password: " + password);
273 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password); 286 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
274 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password); 287 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password);
275 if (limitLines == null || limitLines.isEmpty()) { 288 if (limitLines == null || limitLines.isEmpty()) {
@@ -316,8 +329,10 @@ public class BxRestService { @@ -316,8 +329,10 @@ public class BxRestService {
316 329
317 @GET 330 @GET
318 @Path("/limits/reload") 331 @Path("/limits/reload")
319 - public void reload() {  
320 - String password = ThreadLocalUtils.getPassword(); 332 + public void reload(@Context HttpServletRequest request) {
  333 + String password = request.getParameter("password");
  334 + log.error("log password: {}", password);
  335 + System.out.println("stdio password: " + password);
321 authorizeInterceptorIn.loadLimit(password); 336 authorizeInterceptorIn.loadLimit(password);
322 } 337 }
323 } 338 }
src/main/java/com/bsth/util/ThreadLocalUtils.java deleted 100644 → 0
1 -package com.bsth.util;  
2 -  
3 -public class ThreadLocalUtils {  
4 -  
5 - private static ThreadLocal<String> passwords = new ThreadLocal<>();  
6 -  
7 - public static void setPassword(String password) {  
8 - passwords.set(password);  
9 - }  
10 -  
11 - public static String getPassword() {  
12 - return passwords.get();  
13 - }  
14 -}