修改单点登录

This commit is contained in:
chy
2026-03-11 00:08:12 +08:00
parent d7aa0de3be
commit 94a7c9e000
8 changed files with 114 additions and 17 deletions

View File

@@ -106,6 +106,14 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -1,6 +1,12 @@
package top.lidee.taie.http;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import top.lidee.taie.http.ssl.SslSocketClient;
import okhttp3.*;
@@ -135,4 +141,40 @@ public class HttpClientUtils {
Request request = new Request.Builder().url(url).headers(headers).delete().build();
httpClient.newCall(request).enqueue(callback);
}
public static String getPost(String url,String Token)
{
try {
// 创建HttpClient实例
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建POST请求
HttpPost httpPost = new HttpPost(url);
// 设置请求体
StringEntity params = new StringEntity("refreshToken="+Token);
httpPost.setEntity(params);
httpPost.setHeader("Authorization",Token);
// 发送请求并获取响应
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
// 获取响应状态码
System.out.println(response.getStatusLine().getStatusCode());
// 获取响应体内容
String result = EntityUtils.toString(response.getEntity());
System.out.println(result);
return result;
} finally {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
}