pref: NEZ-3215 nz-talon jdk&springboot 版本升级
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
package net.geedge.confagent.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import net.geedge.confagent.annotation.UnCheckToken;
|
||||
import net.geedge.confagent.entity.AuthEntity;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value={"/auth"})
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.geedge.confagent.controller;
|
||||
|
||||
|
||||
import net.geedge.confagent.util.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.geedge.confagent.util.OSHIUtils;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.geedge.confagent.controller;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
@@ -11,8 +12,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -2,16 +2,18 @@ package net.geedge.confagent.controller;
|
||||
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.net.url.UrlPath;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpConnection;
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.geedge.confagent.annotation.UnCheckToken;
|
||||
import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -24,11 +26,6 @@ import java.net.HttpURLConnection;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/promtail")
|
||||
public class PromtailController extends BaseController{
|
||||
@@ -203,7 +200,7 @@ public class PromtailController extends BaseController{
|
||||
}
|
||||
|
||||
public void requestProm(String host, int port, String path, HttpServletRequest request, HttpServletResponse response) {
|
||||
String queryString = ReflectUtil.invoke(request, "getQueryString");
|
||||
String queryString = request.getQueryString();
|
||||
queryString = StrUtil.isNotBlank(queryString)?queryString:"";
|
||||
String url = UrlBuilder.create().setScheme("http").setHost(host).setPort(port).setPath(UrlPath.of(path, Charset.forName("UTF-8"))).toURL().toString() + "?" + queryString;
|
||||
|
||||
@@ -224,7 +221,7 @@ public class PromtailController extends BaseController{
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String hn = headerNames.nextElement();
|
||||
if(!"authorization".equalsIgnoreCase(hn)) {
|
||||
ReflectUtil.invoke(conn,"addRequestProperty",hn,request.getHeader(hn));
|
||||
conn.addRequestProperty(hn, request.getHeader(hn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,10 +242,12 @@ public class PromtailController extends BaseController{
|
||||
String key = en.getKey();
|
||||
if (Tool.StrUtil.isEmpty(key) || "Transfer-Encoding".equals(key)) continue;
|
||||
List<String> value = en.getValue();
|
||||
ReflectUtil.invoke(response,"addHeader",key,Tool.StrUtil.join("; ",value));
|
||||
response.addHeader(key, Tool.StrUtil.join("; ", value));
|
||||
}
|
||||
response.setStatus(responseCode);
|
||||
if (responseCode > 400) {
|
||||
response.sendError(responseCode, responseMessage);
|
||||
}
|
||||
ReflectUtil.invoke(response, "setStatus", responseCode, responseMessage);
|
||||
|
||||
Tool.IoUtil.copy(connInputStream, resOutputStream);
|
||||
resOutputStream.flush();//flush 输出流
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
package net.geedge.confagent.interceptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.geedge.confagent.annotation.UnCheckToken;
|
||||
import net.geedge.confagent.util.ConfagentUtil;
|
||||
import net.geedge.confagent.util.R;
|
||||
import net.geedge.confagent.util.RCode;
|
||||
import net.geedge.confagent.util.Tool;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@Component
|
||||
public class TokenInterceptor implements HandlerInterceptor {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package net.geedge.confagent.util;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.log.Log;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -8,15 +15,6 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.log.Log;
|
||||
|
||||
@Configuration
|
||||
@Order(value = 1)
|
||||
public class ConfagentUtil {
|
||||
|
||||
@@ -3,7 +3,10 @@ package net.geedge.confagent.util;
|
||||
import cn.hutool.log.Log;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.*;
|
||||
import oshi.software.os.*;
|
||||
import oshi.software.os.InternetProtocolStats;
|
||||
import oshi.software.os.NetworkParams;
|
||||
import oshi.software.os.OSProcess;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package net.geedge.confagent.util;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import net.geedge.confagent.ConfagentApplication;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Robot;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.ref.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLDecoder;
|
||||
@@ -26,13 +26,6 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Spliterator;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
public class Tool {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user