From b6e604f2449bb65dfaafb0f0741ba54ff0d2f9c2 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 30 四月 2024 15:20:03 +0800
Subject: [PATCH] 修改云端录像详情页使用直接访问zlm的方式播放录像
---
src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java | 36 ++++++++++++------------------------
1 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
index 949bcba..eacff18 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
@@ -24,14 +24,9 @@
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
@@ -86,29 +81,22 @@
/**
* 鍒涘缓瀵嗛挜瀵�
+ *
* @throws JoseException JoseException
*/
private RsaJsonWebKey generateRsaJsonWebKey() throws JoseException {
RsaJsonWebKey rsaJsonWebKey = null;
- try {
- URL url = getClass().getClassLoader().getResource("jwk.json");
- if (url != null) {
- URI uri = url.toURI();
- Path path = Paths.get(uri);
- if (Files.exists(path)) {
- byte[] allBytes = Files.readAllBytes(path);
- String jwkJson = new String(allBytes, StandardCharsets.UTF_8);
- final JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(jwkJson);
- List<JsonWebKey> jsonWebKeys = jsonWebKeySet.getJsonWebKeys();
- if (!jsonWebKeys.isEmpty()) {
- JsonWebKey jsonWebKey = jsonWebKeys.get(0);
- if (jsonWebKey instanceof RsaJsonWebKey) {
- rsaJsonWebKey = (RsaJsonWebKey) jsonWebKey;
- }
- }
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("/jwk.json"), StandardCharsets.UTF_8))) {
+ String jwkJson = reader.readLine();
+ JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(jwkJson);
+ List<JsonWebKey> jsonWebKeys = jsonWebKeySet.getJsonWebKeys();
+ if (!jsonWebKeys.isEmpty()) {
+ JsonWebKey jsonWebKey = jsonWebKeys.get(0);
+ if (jsonWebKey instanceof RsaJsonWebKey) {
+ rsaJsonWebKey = (RsaJsonWebKey) jsonWebKey;
}
}
- } catch (URISyntaxException | IOException e) {
+ } catch (Exception e) {
// ignored
}
if (rsaJsonWebKey == null) {
--
Gitblit v1.8.0