From b9b58b9ef261cb290d93465f88a2cbd814b576f0 Mon Sep 17 00:00:00 2001 From: fei.wang <wf18701153496@163.com> Date: 星期一, 13 五月 2024 17:51:44 +0800 Subject: [PATCH] 更改 --- src/main/java/com/flow/controller/ProxyHandler.java | 64 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/flow/controller/ProxyHandler.java b/src/main/java/com/flow/controller/ProxyHandler.java new file mode 100644 index 0000000..d796eb6 --- /dev/null +++ b/src/main/java/com/flow/controller/ProxyHandler.java @@ -0,0 +1,64 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.flow.controller; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.servlet.http.HttpServletResponse; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping({"/hxzk"}) +public class ProxyHandler { + public ProxyHandler() { + } + + @GetMapping({"wlk"}) + public void wlk(HttpServletResponse response, String Timestamp, String Nonce, String targetUrl, String targetUrl1) throws IOException, NoSuchAlgorithmException, InvalidKeyException { + String accessKey = "448c2cedcdce41428a290d144e81ab6e"; + String stringSignTemp = accessKey + Nonce + Timestamp; + String accessSecret = "RgoIWycMYGmQfrLwLuT2VWawAhwMO8w7P9zh2dZp"; + Mac sha256Hmac = Mac.getInstance("HmacSHA256"); + SecretKeySpec secretKeySpec = new SecretKeySpec(accessSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"); + sha256Hmac.init(secretKeySpec); + byte[] hmacBytes = sha256Hmac.doFinal(stringSignTemp.getBytes(StandardCharsets.UTF_8)); + String sign = Base64.getEncoder().encodeToString(hmacBytes); + targetUrl = targetUrl + targetUrl1; + URL url = new URL(targetUrl); + HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + connection.setRequestProperty("Accept-Charset", "UTF-8"); + connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + connection.setRequestProperty("Access-Control-Allow-Origin", "http://localhost:8080"); + connection.setRequestProperty("AccessKey", accessKey); + connection.setRequestProperty("Nonce", Nonce); + connection.setRequestProperty("Timestamp", Timestamp); + connection.setRequestProperty("Sign", sign); + connection.connect(); + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); + StringBuilder response1 = new StringBuilder(); + + String line; + while((line = reader.readLine()) != null) { + response1.append(line); + } + + reader.close(); + connection.disconnect(); + response.setContentType("application/json; charset=UTF-8"); + response.getWriter().write(response1.toString()); + } +} -- Gitblit v1.9.3