// // 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()); } }