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 40 logger.info(s.toString());
41 41  
42 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 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 5 import com.bsth.server_rs.exception.AesException;
6 6 import com.bsth.service.SystemParamService;
7 7 import com.bsth.service.UserService;
8   -import com.bsth.util.ThreadLocalUtils;
9 8 import org.apache.commons.lang3.StringEscapeUtils;
10 9 import org.apache.cxf.interceptor.Fault;
11 10 import org.apache.cxf.message.Message;
... ... @@ -134,7 +133,6 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor&lt;Message&gt; i
134 133 throw new AesException(AesException.SIGN_CHECK_FAIL);
135 134 }
136 135  
137   - ThreadLocalUtils.setPassword(map.get(PASSWORD));
138 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 20 import com.bsth.server_rs.gps.entity.GpsEntity;
21 21 import com.bsth.server_rs.gps.entity.HistoryArrivalEntity;
22 22 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK;
23   -import com.bsth.util.ThreadLocalUtils;
24 23 import org.apache.commons.lang3.StringUtils;
25 24 import org.joda.time.DateTime;
26 25 import org.joda.time.format.DateTimeFormat;
... ... @@ -30,7 +29,9 @@ import org.slf4j.LoggerFactory;
30 29 import org.springframework.beans.factory.annotation.Autowired;
31 30 import org.springframework.stereotype.Component;
32 31  
  32 +import javax.servlet.http.HttpServletRequest;
33 33 import javax.ws.rs.*;
  34 +import javax.ws.rs.core.Context;
34 35 import javax.ws.rs.core.MediaType;
35 36 import java.util.*;
36 37  
... ... @@ -62,9 +63,11 @@ public class BxRestService {
62 63  
63 64 @GET
64 65 @Path("/line")
65   - public List<Map<String, Object>> findAllLine() {
  66 + public List<Map<String, Object>> findAllLine(@Context HttpServletRequest request) {
66 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 71 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
69 72 if (limitLines == null || limitLines.isEmpty()) {
70 73 return result;
... ... @@ -103,9 +106,11 @@ public class BxRestService {
103 106  
104 107 @GET
105 108 @Path("/station")
106   - public List<Map<String, Object>> findAllStation() {
  109 + public List<Map<String, Object>> findAllStation(@Context HttpServletRequest request) {
107 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 114 Set<String> limitLines = new HashSet<>(authorizeInterceptorIn.getLimitLines(password));
110 115 if (limitLines == null || limitLines.isEmpty()) {
111 116 return result;
... ... @@ -163,10 +168,12 @@ public class BxRestService {
163 168  
164 169 @GET
165 170 @Path("/vehicle")
166   - public List<Map<String, Object>> findAllVehicle() {
  171 + public List<Map<String, Object>> findAllVehicle(@Context HttpServletRequest request) {
167 172 List<Map<String, Object>> result = new ArrayList<>();
168 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 177 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
171 178 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password);
172 179 if (limitLines == null || limitLines.isEmpty()) {
... ... @@ -199,9 +206,11 @@ public class BxRestService {
199 206  
200 207 @GET
201 208 @Path("/parking")
202   - public List<Map<String, Object>> findAllParking() {
  209 + public List<Map<String, Object>> findAllParking(@Context HttpServletRequest request) {
203 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 214 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
206 215 if (limitLines == null || limitLines.isEmpty()) {
207 216 return result;
... ... @@ -234,9 +243,11 @@ public class BxRestService {
234 243  
235 244 @GET
236 245 @Path("/gps/all")
237   - public List<Map<String, Object>> findAllGps() {
  246 + public List<Map<String, Object>> findAllGps(@Context HttpServletRequest request) {
238 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 251 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
241 252 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password);
242 253 if (limitLines == null || limitLines.isEmpty()) {
... ... @@ -267,9 +278,11 @@ public class BxRestService {
267 278 }
268 279 @GET
269 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 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 286 Set<String> limitLines = authorizeInterceptorIn.getLimitLines(password);
274 287 Set<String> limitDevices = authorizeInterceptorIn.getLimitDevices(password);
275 288 if (limitLines == null || limitLines.isEmpty()) {
... ... @@ -316,8 +329,10 @@ public class BxRestService {
316 329  
317 330 @GET
318 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 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   -}