增加阿里云推送,未完成
This commit is contained in:
20
pom.xml
20
pom.xml
@@ -123,6 +123,12 @@
|
||||
<scope>runtime</scope>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--添加数据库驱动依赖(根据实际数据库选择)-->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
@@ -144,6 +150,20 @@
|
||||
<version>3.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--异步推送-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibabacloud-push20160801</artifactId>
|
||||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
|
||||
<!--同步推送-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>push20160801</artifactId>
|
||||
<version>1.0.17</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JJWT (最新版) -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
|
||||
@@ -18,13 +18,14 @@ public class AuthHandshakeInterceptor implements HandshakeInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> 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); // 自定义校验逻辑
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String> 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)));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user