From 2db2928464f515ffdf45ba881cf12b34768987aa Mon Sep 17 00:00:00 2001 From: YJ1211 <1056025931@qq.com> Date: Wed, 23 Mar 2022 11:02:32 +0800 Subject: [PATCH] =?UTF-8?q?0.2.6=20=E4=BF=AE=E5=A4=8D=E5=AE=89=E5=8D=937?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E8=99=8E=E7=89=99=E5=BC=B9=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/logic/danmu/DanmuUtils.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/sunnyweather/android/logic/danmu/DanmuUtils.java b/app/src/main/java/com/sunnyweather/android/logic/danmu/DanmuUtils.java index 125c91d..cbb5c19 100644 --- a/app/src/main/java/com/sunnyweather/android/logic/danmu/DanmuUtils.java +++ b/app/src/main/java/com/sunnyweather/android/logic/danmu/DanmuUtils.java @@ -1,13 +1,13 @@ package com.sunnyweather.android.logic.danmu; +import android.util.Log; + import androidx.lifecycle.MutableLiveData; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.annotation.JSONField; -import com.auth0.jwt.JWT; -import com.auth0.jwt.algorithms.Algorithm; import com.sunnyweather.android.ui.liveRoom.LiveRoomViewModel; import java.io.ByteArrayInputStream; @@ -29,6 +29,9 @@ import java.util.zip.DataFormatException; import java.util.zip.Inflater; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.io.Decoders; +import io.jsonwebtoken.security.Keys; import okhttp3.Request; import okhttp3.WebSocket; import okio.ByteString; @@ -146,14 +149,13 @@ public static Map getWebSocketJwtParamsMap(String appId, String header.put("typ", "JWT"); //生成JWT凭证 - Algorithm algorithm = Algorithm.HMAC256(secret); //开发者密钥 - String sToken = JWT.create() - .withHeader(header) //JWT声明 - .withIssuedAt(iat) //jwt凭证生成时间 - .withExpiresAt(exp) //jwt凭证超时时间 - .withClaim("appId", appId) //开发者ID - .sign(algorithm); - + String sToken = Jwts.builder() + .setHeader(header) + .setIssuedAt(iat) + .setExpiration(exp) + .claim("appId", appId) + .signWith(Keys.hmacShaKeyFor(secret.getBytes(StandardCharsets.UTF_8))) + .compact(); Map authMap = new HashMap(); authMap.put("iat", currentTimeMillis / 1000); //jwt凭证生成时间戳(秒)