更新应用工具类与连接模型命名空间。

This commit is contained in:
2026-01-15 15:39:26 +08:00
parent 45302788f7
commit 7908444252
6 changed files with 50 additions and 30 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 15 06:52:22 GMT 2026
#Thu Jan 15 07:38:30 GMT 2026
stageCount=0
libraryProject=library
baseVersion=15.0
publishVersion=15.0.0
buildCount=54
buildCount=56
baseBetaVersion=15.0.1

View File

@@ -16,10 +16,10 @@ import cc.winboll.LogUtils;
import cc.winboll.library.model.AuthDataModel;
import cc.winboll.library.utils.AuthUtils;
import cc.winboll.library.utils.NFCUtils;
import cc.winboll.library.utils.ServerUtils;
import cc.winboll.studio.authcenterapp.R;
import cc.winboll.studio.authcenterapp.activities.AuthTestActivity;
import cc.winboll.studio.authcenterapp.manager.HeartbeatManager;
import cc.winboll.studio.authcenterapp.utils.AppUtils;
import cc.winboll.studio.authcenterapp.utils.StorageUtils;
import java.security.KeyPair;
import java.security.PrivateKey;
@@ -191,7 +191,7 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
}
// 初始化服务器地址
ServerUtils.initServerUrl(serverUrl);
AppUtils.initServerUrl(serverUrl);
updateStatus("步骤1成功邮箱+服务地址校验通过");
LogUtils.i(TAG, "testStep1CheckInput步骤1执行成功服务器地址已初始化");
}
@@ -217,7 +217,7 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
}
// 调用服务器接口发送验证码
String result = ServerUtils.sendVerifyCode(email);
String result = AppUtils.sendVerifyCode(email);
if (result != null && result.contains("success")) {
updateStatus("步骤2成功验证码已发送请注意查收");
LogUtils.i(TAG, "testStep2SendVerifyCode步骤2执行成功验证码发送成功");
@@ -249,7 +249,7 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
}
// 调用服务器接口校验验证码
String result = ServerUtils.verifyCode(email, code);
String result = AppUtils.verifyCode(email, code);
if (result != null && result.contains("success")) {
updateStatus("步骤3成功验证码校验通过");
LogUtils.i(TAG, "testStep3VerifyCode步骤3执行成功验证码校验通过");
@@ -336,7 +336,7 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
LogUtils.d(TAG, "testStep5SubmitPublicKey入参-email=" + email + ",应用公钥已准备");
// 1. 提交应用公钥到服务器获取加密PONG数据
String encryptPong = ServerUtils.submitAppPublicKey(email, appPublicKeyStr);
String encryptPong = AppUtils.submitAppPublicKey(email, appPublicKeyStr);
if (encryptPong == null) {
updateStatus("步骤5失败提交公钥失败服务无响应");
LogUtils.e(TAG, "testStep5SubmitPublicKey提交应用公钥到服务器失败服务无响应");
@@ -428,13 +428,13 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
LogUtils.w(TAG, "testAllStep-步骤1执行失败邮箱或服务地址格式无效");
return;
}
ServerUtils.initServerUrl(serverUrl);
AppUtils.initServerUrl(serverUrl);
updateStatus("全流程-步骤1校验通过");
LogUtils.d(TAG, "testAllStep-步骤1执行成功");
sleep(1000);
// 步骤2发送验证码
String sendResult = ServerUtils.sendVerifyCode(email);
String sendResult = AppUtils.sendVerifyCode(email);
if (sendResult == null || !sendResult.contains("success")) {
updateStatus("全流程失败步骤2验证码发送失败");
LogUtils.w(TAG, "testAllStep-步骤2执行失败验证码发送失败服务返回=" + sendResult);
@@ -446,7 +446,7 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
// 步骤3验证码校验需用户提前输入
String code = etVerifyCode.getText().toString().trim();
String verifyResult = ServerUtils.verifyCode(email, code);
String verifyResult = AppUtils.verifyCode(email, code);
LogUtils.d(TAG, "testAllStep-步骤3入参-code=" + code);
if (verifyResult == null || !verifyResult.contains("success")) {
updateStatus("全流程失败步骤3验证码校验失败");
@@ -485,7 +485,7 @@ public class AuthTestActivity extends BaseWinBoLLActivity implements View.OnClic
sleep(1000);
// 步骤5提交公钥与鉴权登录
String encryptPong = ServerUtils.submitAppPublicKey(email, appPublicKeyStr);
String encryptPong = AppUtils.submitAppPublicKey(email, appPublicKeyStr);
String privateKeyStr = AuthUtils.decryptByPrivateKey(encryptPrivateKey, SERVER_PUBLIC_KEY);
String pongJson = AuthUtils.decryptByPrivateKey(encryptPong, privateKeyStr);
AuthDataModel pongModel = AuthDataModel.parsePongJson(pongJson);

View File

@@ -2,7 +2,7 @@ package cc.winboll.studio.authcenterapp.manager;
import cc.winboll.LogUtils;
import cc.winboll.library.model.AuthDataModel;
import cc.winboll.library.utils.AuthUtils;
import cc.winboll.library.utils.ServerUtils;
import cc.winboll.studio.authcenterapp.utils.AppUtils;
import java.util.Timer;
import java.util.TimerTask;
@@ -78,7 +78,7 @@ public class HeartbeatManager {
return;
}
// 发送请求
String response = ServerUtils.sendPingRequest(encryptPing);
String response = AppUtils.sendPingRequest(encryptPing);
if (response != null) {
handlePongResponse(response);
} else {

View File

@@ -1,4 +1,4 @@
package cc.winboll.library.utils;
package cc.winboll.studio.authcenterapp.utils;
import cc.winboll.LogUtils;
import java.io.BufferedReader;
@@ -11,11 +11,13 @@ import java.util.Map;
/**
* 纯服务器交互工具类仅负责封装HTTP请求调用远程接口无监听能力
* 适配Java7语法兼容Android API30环境
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026-01-15 18:00:00
* @LastEditTime 2026-01-15 23:45:00
* @Date 2026/01/16 00:00:00
* @LastEditTime 2026/01/16 00:45:00
*/
public class ServerUtils {
public class AppUtils {
// 基础属性
private static final String TAG = "ServerUtils";
private static final int CONNECT_TIMEOUT = 5000;
private static final int READ_TIMEOUT = 5000;
@@ -25,6 +27,7 @@ public class ServerUtils {
* 初始化服务器基础地址
*/
public static void initServerUrl(String url) {
LogUtils.d(TAG, "调用initServerUrl传入地址" + url);
serverBaseUrl = url;
LogUtils.d(TAG, "服务器地址初始化完成:" + serverBaseUrl);
}
@@ -33,8 +36,9 @@ public class ServerUtils {
* 发送验证码请求POST
*/
public static String sendVerifyCode(String email) {
LogUtils.d(TAG, "调用sendVerifyCode邮箱参数" + email);
String url = serverBaseUrl + "/api/sendVerifyCode";
Map<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<String, String>();
params.put("email", email);
return sendPostRequest(url, params);
}
@@ -43,8 +47,9 @@ public class ServerUtils {
* 校验验证码请求POST
*/
public static String verifyCode(String email, String code) {
LogUtils.d(TAG, "调用verifyCode参数邮箱[" + email + "] 验证码[" + code + "]");
String url = serverBaseUrl + "/api/verifyCode";
Map<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<String, String>();
params.put("email", email);
params.put("code", code);
return sendPostRequest(url, params);
@@ -54,8 +59,9 @@ public class ServerUtils {
* 提交应用公钥请求POST
*/
public static String submitAppPublicKey(String email, String publicKey) {
LogUtils.d(TAG, "调用submitAppPublicKey参数邮箱[" + email + "] 公钥[" + publicKey + "]");
String url = serverBaseUrl + "/api/submitPublicKey";
Map<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<String, String>();
params.put("email", email);
params.put("appPublicKey", publicKey);
return sendPostRequest(url, params);
@@ -65,20 +71,31 @@ public class ServerUtils {
* 发送心跳PING请求POST加密数据
*/
public static String sendPingRequest(String encryptPingData) {
LogUtils.d(TAG, "调用sendPingRequest加密数据" + encryptPingData);
String url = serverBaseUrl + "/api/heartbeat/ping";
Map<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap<String, String>();
params.put("encryptData", encryptPingData);
return sendPostRequest(url, params);
}
/**
* 获取当前初始化的服务器基础地址
*/
public static String getServerBaseUrl() {
LogUtils.d(TAG, "调用getServerBaseUrl当前地址" + serverBaseUrl);
return serverBaseUrl;
}
/**
* 通用POST请求封装
*/
private static String sendPostRequest(String urlStr, Map<String, String> params) {
LogUtils.d(TAG, "调用sendPostRequest请求地址" + urlStr);
if (urlStr == null || params == null) {
LogUtils.w(TAG, "POST请求参数为空");
return null;
}
HttpURLConnection conn = null;
try {
URL url = new URL(urlStr);
@@ -111,6 +128,7 @@ public class ServerUtils {
response.append(line);
}
br.close();
LogUtils.d(TAG, "POST请求成功响应内容" + response.toString());
return response.toString();
} else {
LogUtils.w(TAG, "POST请求失败响应码" + conn.getResponseCode());
@@ -124,12 +142,5 @@ public class ServerUtils {
}
return null;
}
/**
* 获取当前初始化的服务器基础地址
*/
public static String getServerBaseUrl() {
return serverBaseUrl;
}
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 15 06:52:22 GMT 2026
#Thu Jan 15 07:38:30 GMT 2026
stageCount=0
libraryProject=library
baseVersion=15.0
publishVersion=15.0.0
buildCount=54
buildCount=56
baseBetaVersion=15.0.1

View File

@@ -0,0 +1,9 @@
package cc.winboll.library.model;
public class HttpServerConnectionModel {
// 公网访问认证信息
public static final String CONNECTION_AUTH_NAME = "console";
public static final String CONNECTION_PASSWORD = "JeNJKJxriEcafMxd";
public static final String PUBLIC_SERVER_URL = "https://console.winboll.cc/authcenter/ping";
}