From 301b23e6e66c86698523b879cc5fd684dbfaa667 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Sun, 10 Aug 2025 00:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=98=BF=E9=87=8C=E4=BA=91?= =?UTF-8?q?=E6=8E=A8=E9=80=81=EF=BC=8C=E6=9C=AA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 20 ++++++++ .../interceptor/AuthHandshakeInterceptor.java | 5 +- .../videotablet/utils/PushUtils.java | 51 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 531abb2..c46e33f 100644 --- a/pom.xml +++ b/pom.xml @@ -123,6 +123,12 @@ runtime 8.0.33 + + com.google.code.gson + gson + 2.10.1 + + com.h2database @@ -144,6 +150,20 @@ 3.1.1 + + + com.aliyun + alibabacloud-push20160801 + 1.0.13 + + + + + com.aliyun + push20160801 + 1.0.17 + + io.jsonwebtoken diff --git a/src/main/java/com/onekeycall/videotablet/interceptor/AuthHandshakeInterceptor.java b/src/main/java/com/onekeycall/videotablet/interceptor/AuthHandshakeInterceptor.java index 898a1a1..4a32759 100644 --- a/src/main/java/com/onekeycall/videotablet/interceptor/AuthHandshakeInterceptor.java +++ b/src/main/java/com/onekeycall/videotablet/interceptor/AuthHandshakeInterceptor.java @@ -18,13 +18,14 @@ public class AuthHandshakeInterceptor implements HandshakeInterceptor { @Override public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map attributes) throws Exception { - String userId = request.getHeaders().getFirst("user_id"); String authHeader = request.getHeaders().getFirst("Authorization"); + String deviceId = request.getHeaders().getFirst("Device-ID"); + String userId = request.getHeaders().getFirst("user_id"); + if (authHeader == null || !authHeader.startsWith("Bearer ")) { return false; } String token = authHeader.substring(7); // 去掉 "Bearer " 前缀 - String deviceId = request.getHeaders().getFirst("Device-ID"); return jwtUtil.validateAccessToken(userId, token, deviceId); // 自定义校验逻辑 } diff --git a/src/main/java/com/onekeycall/videotablet/utils/PushUtils.java b/src/main/java/com/onekeycall/videotablet/utils/PushUtils.java index 0b25cba..d745cb7 100644 --- a/src/main/java/com/onekeycall/videotablet/utils/PushUtils.java +++ b/src/main/java/com/onekeycall/videotablet/utils/PushUtils.java @@ -1,4 +1,55 @@ package com.onekeycall.videotablet.utils; +import com.aliyun.auth.credentials.Credential; +import com.aliyun.auth.credentials.provider.StaticCredentialProvider; +import com.aliyun.credentials.models.Config; +import com.aliyun.sdk.service.dysmsapi20170525.AsyncClient; +import com.aliyun.sdk.service.push20160801.models.PushRequest; +import com.aliyun.sdk.service.push20160801.models.PushResponse; +import com.google.gson.Gson; +import darabonba.core.client.ClientOverrideConfiguration; + +import java.util.concurrent.CompletableFuture; +import com.aliyun.tea.*; +import com.aliyun.push20160801.*; +import com.aliyun.push20160801.models.*; +import com.aliyun.teaopenapi.*; +import com.aliyun.teaopenapi.models.*; +import com.aliyun.teautil.*; + public class PushUtils { +// public static com.aliyun.push20160801.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { +// Config config = new Config(); +// // 您的AccessKey ID +// config.accessKeyId = accessKeyId; +// // 您的AccessKey Secret +// config.accessKeySecret = accessKeySecret; +// config.regionId = "cn-hangzhou"; +// return new com.aliyun.push20160801.Client(config); +// } +// +// public static void aliyunAsyncPush( String message, String title) { +// +// java.util.List args = java.util.Arrays.asList(args_); +// com.aliyun.push20160801.Client client = Sample.createClient(com.aliyun.darabonba.env.EnvClient.getEnv("ACCESS_KEY_ID"), com.aliyun.darabonba.env.EnvClient.getEnv("ACCESS_KEY_SECRET")); +// PushRequest request = new PushRequest() +// .setAppKey(com.aliyun.darabonbanumber.Client.parseLong(args.get(0))) +// .setPushType("MESSAGE") +// .setDeviceType("ALL") +// .setStoreOffline(true) +// .setIOSRemind(true) +// .setAndroidRemind(true) +// .setTarget("DEVICE") +// .setTargetValue(args.get(1)) +// .setTitle(args.get(2)) +// .setBody(args.get(3)) +// .setIOSRemindBody(args.get(4)) +// .setAndroidPopupTitle(args.get(5)) +// .setAndroidPopupBody(args.get(6)); +// PushResponse response = client.push(request); +// com.aliyun.teaconsole.Client.log(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response.body))); +// } + + + }