| | |
| | | |
| | | try { |
| | | String json = body instanceof String ? (String) body : new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(body); |
| | | System.out.println("加密前:" + json); |
| | | return CryptoUtil.encrypt(json); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("响应加密失败", e); |
| | |
| | | |
| | | String body = new BufferedReader(httpRequest.getReader()).lines() |
| | | .collect(Collectors.joining(System.lineSeparator())); |
| | | System.out.println("请求数据:"+body); |
| | | try { |
| | | String decryptedBody = CryptoUtil.decrypt(body); |
| | | System.out.println("解密后:"+decryptedBody); |
| | | DecryptRequestWrapper wrappedRequest = new DecryptRequestWrapper(httpRequest, decryptedBody); |
| | | chain.doFilter(wrappedRequest, response); |
| | | } catch (Exception e) { |